ASP.NET Core Web API implementing Clean Architecture principles for anime data management with integrated machine learning recommendations and Single Page Application client.
graph TB
A[Angular SPA<br/><em>In Development</em>]
B[YARP Proxy<br/><em>Planned</em>]
C[ASP.NET Core API<br/><strong>This Solution</strong>]
E[FastAPI Recommender<br/><em>In Development</em>]
D[(PostgreSQL Database)]
%% Connections
A -.->|HTTP Requests| B
B -.->|Proxied Requests| C
C -->|SQL Queries| D
C -.->|REST API Calls| E
%% Styling
classDef planned fill:#9e9e9e,stroke:#757575,stroke-width:2px,color:#fff,stroke-dasharray: 5 5
classDef backend fill:#5c2d91,stroke:#4a2372,stroke-width:3px,color:#fff
classDef database fill:#00758f,stroke:#005d73,stroke-width:2px,color:#fff
class A planned
class B planned
class C backend
class E planned
class D database
Current Status: The Angular frontend, YARP reverse proxy, and FastAPI recommender service are in development. This repository contains the complete, production-ready REST API solution.
This solution follows Clean Architecture principles with clear separation of concerns across four projects
graph TB
Core["AnimeApi.Server.Core
• Abstractions & Interfaces
• Models & DTOs
• Shared Objects"]
DataAccess["AnimeApi.Server.DataAccess
• EF Core DbContext
• Repository Implementations
• Migrations"]
Business["AnimeApi.Server.Business
• Business Logic Services
• Validation (FluentValidation)
• Mapping Extensions
• Authentication (JWT)"]
Server["AnimeApi.Server (API)
• Controllers & Endpoints
• Middleware (Auth, Logging)
• Swagger / OpenAPI
• DI & Configuration"]
Test["AnimeApi.Server.Test
• Unit Tests (xUnit)
• Mocking (Moq)"]
Core --> |Models - interfaces| DataAccess
Core --> |Dto - interfaces - Object wrappers| Business
DataAccess --> |Entities| Business
Business --> |Dto| Server
Test --> |Business logic unit tests| Business
classDef core fill:#5c2d91,stroke:#4a2372,stroke-width:3px,color:#fff
classDef data fill:#00758f,stroke:#005d73,stroke-width:2px,color:#fff
classDef business fill:#9e9e9e,stroke:#757575,stroke-width:2px,color:#fff
classDef api fill:#ff9800,stroke:#e68900,stroke-width:2px,color:#fff
classDef test fill:#4caf50,stroke:#357a38,stroke-width:2px,color:#fff
class Core core
class DataAccess data
class Business business
class Server api
class Test test
Purpose: Defines contracts and shared objects across all layers
- Interfaces: Repository abstractions (
IRepository<T>, domain service contracts) - Models: Domain entities and data models
- DTOs: Data transfer objects for API communication
- Shared Objects: Search parameters, constants, enumerations
- Dependencies: Completely independent from other projects to ensure loose coupling
Purpose: Implements data persistence using Entity Framework Core
- Repository Implementation: Concrete implementations of Core interfaces
- Database Context: EF Core
DbContextconfiguration - Dependency Injection:
ServiceCollectionExtensions.csfor DI registration - Dependencies:
AnimeApi.Server.Core
Purpose: Encapsulates business logic and orchestration
- Business Services: Domain logic implementation
- Mapping Extensions: Entity to DTO transformation methods
- Validators: Input validation using FluentValidation
- Authentication: JWT token services and identity management
- Dependency Injection: Service registration extensions
- Dependencies:
AnimeApi.Server.Coreonly (no DataAccess reference)
Purpose: Web API layer and application entry point
- Controllers: RESTful API endpoints
- Middleware: Authentication, logging, exception handling
- Configuration: Dependency injection wiring and application setup
- Swagger: API documentation and testing interface
- Dependencies: All other projects for DI container configuration
Purpose: Comprehensive unit testing suite
- Business Logic Tests: Validation of business layer functionality
- Test Framework: xUnit with Moq for mocking
- Coverage: Business layer methods and service implementations
- Independence: Core layer has zero dependencies, enabling flexibility
- Testability: Business logic isolated from infrastructure concerns
- Maintainability: Clear separation allows independent evolution of layers
- Dependency Inversion: Higher-level modules don't depend on lower-level modules
| Layer | Technologies |
|---|---|
| Web API | ASP.NET Core, Swagger/OpenAPI |
| Business Logic | FluentValidation, Google Oauth2 |
| Data Access | Entity Framework Core, Postgre |
| Authentication | JWT Bearer tokens |
| Testing | xUnit, Moq |
- Provider: PostgreSQL with Entity Framework Core
- Migrations: EF migrations
- Connection Management: Managed through ASP.NET Core DI
PostgreSQL allows for very efficient full text search.
- RESTful Design: Standard HTTP methods and status codes
- Authentication: JWT-based security
- Validation: Input validation through FluentValidation
- Documentation: Swagger UI
- Error Handling: Consistent error response format
- .NET 8.0 SDK
- PostgreSQL 16.0+
- IDE (Visual Studio, VS Code, or Rider)
git clone https://github.com/jklzz02/Anime-Rest-API
cd Anime-Rest-APIRestore dependencies & update database:
dotnet restore
dotnet ef database update --project AnimeApi.Server.DataAccess --startup-project AnimeApi.ServerSetup secrets & config:
There's a comprehensive sample file to setup the web project secrets such as
- Google client secret
- Secret key
and also domains for external services and the client, to avoid cors issues and to hard code domains.
- Recommender domain
- Client domain
Run the Web project:
dotnet run --project AnimeApi.Serverdotnet test AnimeApi.Server.Test
- Generators are used to create testing data
- Theories and interface mocks are the preferred approach
- Domain Changes: Start with Core project if needed (abstractions)
- Data Layer: Implement repositories in DataAccess project
- Business Logic: Add services or repositories to helpers in Business project
- API Endpoints: Create controllers in Server project
- Testing: Write unit tests in Test project