How avicted/social-platform-2000-backend works
Main Components
• API Layer (sp2000.API): This is the entry point for the application. It contains the controllers (e.g., AuthenticationController, CategoriesController, CommentsController, PostsController), Program.cs, and configuration files. It is responsible for handling HTTP requests, routing them to the appropriate services, and managing authentication.
• Application Layer (sp2000.Application): This layer holds the business logic. It includes Data Transfer Objects (DTOs), service interfaces and implementations (like CategoriesService, CommentsService, PostService), dependency injection setup, mapping configurations, and utility helpers. This layer abstracts the domain logic from infrastructure concerns.
• Infrastructure Layer (sp2000.Infrastructure): This layer is focused on persistence and external integrations. It contains the ApplicationDbContext, Entity Framework Core migrations, repository implementations (e.g., ApplicationUsersRepository, CategoriesRepository, etc.), identity management (JWT, cookies, IdentityService), and additional services (such as the DateTimeService). Its purpose is to handle data access and platform-specific implementations.
• Unit Test Project (sp2000.UnitTests): This project contains tests for controllers and services, ensuring the components work as expected.
Relationships and Interactions
• The sp2000.API (controllers) interacts with the sp2000.Application layer by calling its services and using DTOs to send/receive data.
• The sp2000.Application layer defines interfaces for repositories and business services, which are implemented by sp2000.Infrastructure. Dependency Injection (configured within both Application and Infrastructure projects) creates loose coupling.
• The Infrastructure layer manages database connections, migrations, and interactions with the persistence layer through Entity Framework Core.
• Unit tests validate the functionality of both the API controllers and the Application services, simulating and asserting real-world flows.
Architectural Patterns and Design Principles
• Layered (or Clean) Architecture: Each project (API, Application, Infrastructure) encapsulates distinct concerns, simplifying maintenance and testing.
• Dependency Injection: The Application and Infrastructure layers both have DI configurations to inject dependencies (e.g., repositories, current user services) into consuming classes.
• Repository Pattern: Abstracts database operations behind repository interfaces (defined in Application) and implemented in Infrastructure.
• DTO and Mapping: The Application layer consistently uses Data Transfer Objects and mapping configurations to decouple internal domain models from external representations.
Incorporate Relevant Technologies and Frameworks
• .NET (C#) with ASP.NET Core for the API.
• Entity Framework Core for data access and migrations.
• Docker for development container configurations (see .devcontainer folder).
• GitHub Actions for CI/CD (workflows in .github/workflows).
• VSCode remote development environment setup.