An ASP.NET Core 9 web application that allows users to register/login, view/manage books, write reviews, and vote (like/dislike) on reviews. It includes both an MVC UI and a RESTful API with JWT authentication and PostgreSQL persistence followin N-Tier architecture.
- 🔐 User registration & login (ASP.NET Identity)
- 📘 Book and review management (MVC + Razor Views)
- 👍👎 One vote per review per user
- ⚙️ RESTful API for books & reviews
- 🧪 Unit tested services & repositories
- 🌐 Swagger UI with JWT token authorization
- 🐘 PostgreSQL database via Docker
- .NET 9 SDK
- Docker Desktop
- Optional: Postman for API testing
docker run -d -p 5433:5432 --name bookreview-postgres \
-e POSTGRES_USER=bookadmin \
-e POSTGRES_PASSWORD=SuperSecure123 \
-e POSTGRES_DB=bookreviewdb \
postgres:latestYou must set the following JWT & PostgreSQL database configuration as User environment variables: Run as Admin Powershell and type:
[System.Environment]::SetEnvironmentVariable("BOOKREVIEW_DB_CONNECTION", "Host=localhost;Port=5433;Database=bookreviewdb;Username=bookadmin;Password=SuperSecure123", "Machine")
[System.Environment]::SetEnvironmentVariable("BookAPP_JWT_ISSUER", "test.gr", "User")
[System.Environment]::SetEnvironmentVariable("BookAPP_JWT_AUDIENCE", "test", "User")
[System.Environment]::SetEnvironmentVariable("BookAPP_JWT_KEY", "justADummyTokenKeyForDummyTest2025!", "User")
[System.Environment]::SetEnvironmentVariable("BookAPP_JWT_EXPIRY_MINUTES", "60", "User")📌 Tip: Restart your IDE or terminal after setting them or even Visual Studio so that it will work.
From your solution directory:
dotnet ef migrations add Init --project BookReviewApp.DataAccess --startup-project BookReviewApp.WebUI
dotnet ef database update --project BookReviewApp.DataAccess --startup-project BookReviewApp.WebUI- Use the
/api/auth/loginendpoint to obtain a JWT token. - Open Swagger UI at:
https://localhost:{PORT}/swagger - Click "Authorize" at the top right.
- Paste the token as:
Bearer {your_token_here}
Example:
Bearer eyJhbGciOiJIUzI1NiIsInR5cCI...
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/books |
List books (with optional filters) |
| GET | /api/books/{id} |
Book details |
| POST | /api/books |
Add new book (Admin only) |
| GET | /api/books/{id}/reviews |
Get reviews for a book |
| POST | /api/reviews |
Add review (Customer only) |
| POST | /api/reviews/{id}/vote |
Like/Dislike a review |
| POST | /api/auth/login |
Authenticate and get token |
- Admin: Full control over books
- Customer: Can review and vote
- Anonymous: Read-only access
- Unit tests exist under
BookReviewApp.Tests - Services like
BookService,ReviewServiceare covered using mocks - Run via:
dotnet test- ASP.NET Core 9 MVC & API
- Entity Framework Core 9
- PostgreSQL
- Docker
- Swagger / Swashbuckle
- JWT Bearer Authentication
- Razor Views
- XUnit & Moq for unit tests