How justin-at-straker/taskmanagerapi works
Main Components
• Client/Consumer: Although this project is an API, its clients (like Swagger UI, Postman, or any front-end consuming the API) should be represented.
• Controllers: Represent the API endpoints. The Controllers folder (e.g., AuthController.cs, TasksController.cs) is where client requests are handled.
• Services: This layer (TaskService.cs, ITaskService.cs) implements the business logic.
• Repositories: Components (TaskRepository.cs, IRepository.cs) responsible for data access logic.
• Data Layer: The AppDbContext.cs within Data folder, which manages the in-memory database using Entity Framework Core.
• Models: The domain/data models for tasks and users (Task.cs, User.cs).
• Authorization: Separate logic (Authorization folder with RoleRequirement.cs) that implements JWT and role-based access policies.
• Configuration/Infrastructure: This includes the main entry point (Program.cs) and configuration files (appsettings.json) that define JWT, environment variables, and database settings.
• External Services/Tools: Swagger/OpenAPI which exposes the API documentation and JWT for your security.
Relationships and Interactions
• How requests flow from the client into Controllers.
• From Controllers, illustrate the delegation to the Services layer, which applies business logic.
• The Services layer then interacts with the Repositories to persist or fetch data from the database (the Data layer using AppDbContext.cs).
• The Authorization layer should be illustrated as integrated with the Controllers and potentially the Services to handle validation of JWT tokens and role requirements.
• Use of JWT authentication by drawing a dedicated component or label (e.g., “JWT Provider”) that verifies tokens on incoming requests.
Architectural Patterns and Design Principles
• Layered Architecture: Emphasize the separation into different layers (Controllers, Services, Repositories, Data) to clearly illustrate the separation of concerns.
• Use of Middleware: Note that ASP.NET Core typically uses middleware for authentication/authorization and error handling.
• Dependency Injection: Although not explicitly shown in the file tree, point out that .NET Core projects typically rely on DI, which promotes loose coupling between Controllers, Services, and Repositories.
• Security: Showcase JWT-based authentication and role-based authorization as integral parts of the request handling process.
Relevant Technologies, Frameworks, and Libraries
• ASP.NET Core 8.0 for building the API.
• Entity Framework Core (EF Core) for ORM and in-memory database management.
• JWT Bearer Authentication for securing endpoints.
• Swagger/OpenAPI for API documentation.
• .NET 8.0 SDK and C# as the foundation language and runtime environment.
Instructing the Principal Software Engineer
• Incorporate elements that highlight the JWT authentication flow, including a token generation/validation component or note within the Authorization layer.
• Optionally, add environment-specific configurations (e.g., usage of in-memory database for development, environment variables for production-like configurations).