Skip to content

Book Reviews REST API in C#/.NET 8 with EF Core (SQLite), featuring Repository & Unit-of-Work, custom exception handling, structured logging, FluentValidation, and full unit & integration tests.

License

Notifications You must be signed in to change notification settings

Jcarchboldd/BookAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

99 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📚 BookAPI

A testable and well-structured REST API built with ASP.NET Core 8 for managing books, users, and reviews. Features include JWT authentication, FluentValidation, centralized error handling, and detailed logging.


🔧 Tech Stack

  • .NET 8 (ASP.NET Core Web API)
  • Entity Framework Core 9 (with SQLite + InMemory for tests)
  • JWT Authentication
  • FluentValidation
  • xUnit, AutoFixture, FakeItEasy (for testing)
  • Swagger / OpenAPI
  • Mapster (for lightweight object mapping)

🧱 Project Structure

BookAPI/
├── Controllers/              # API controllers (Book, Auth)
├── Identity/                 # Identity logic (models, services, JWT, validation)
├── Infrastructure/           # Data access, EF configs, UoW, DbContext
├── Contracts/                # DTOs for Books & Auth
├── Services/                 # Application services & validators
├── Middleware/               # Request logging, exception handling
├── Exceptions/               # Custom exception classes & handler
├── Program.cs                # Entry point & DI config

tests/
├── UnitTests/                # Unit tests for services, validators, controllers
└── IntegrationTests/         # Integration tests for API endpoints

🚀 Running the App

dotnet run --project ./BookAPI

Swagger UI: http://localhost:5177/swagger/index.html


✅ Testing

Run unit and integration tests:

dotnet test

🔐 Authentication

JWT-based authentication is enabled. After registering via /api/auth/register, you can log in at /api/auth/login to receive a token. Include the token in requests:

Authorization: Bearer {token}

Creating, updating, or deleting books and reviews requires authentication.


🧪 Example JSON Payloads

Register

{
  "firstName": "Jane",
  "lastName": "Doe",
  "email": "jane@example.com",
  "password": "P@ssw0rd!"
}

Create Book

{
  "title": "One Hundred Years of Solitude",
  "author": "Gabriel García Márquez"
}

🧠 Features Implemented

  • ✅ JWT Authentication
  • ✅ Repository + Unit of Work Pattern
  • ✅ Global Exception Handling with ProblemDetails
  • ✅ FluentValidation
  • ✅ Auto-generated Swagger docs
  • ✅ Full unit + integration testing coverage

📄 License

MIT

About

Book Reviews REST API in C#/.NET 8 with EF Core (SQLite), featuring Repository & Unit-of-Work, custom exception handling, structured logging, FluentValidation, and full unit & integration tests.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages