How witordias/animelistor works
Main Components
• API / Presentation Layer: Represented by the controllers (e.g., AnimeController). This layer receives HTTP requests and routes them to appropriate services.
• Business Logic / Service Layer: The AnimeService encapsulates the business logic. It acts as the intermediary between controllers and repositories.
• Data Access Layer: The repository (AnimeRepository) handles interactions with the MySQL database.
• Domain Model: The Anime class defines the core entity; DTOs (like AnimeDto) are used for data transfer.
• Exception Handling: Custom exceptions (BadRequestException, ValidationExceptionCustomFields etc.) along with the RestExceptionHandler provide robust error management.
• Security: The SecurityConfig configures in-memory authentication with different roles (admin and user) to secure API endpoints.
• Configuration/Extension: Files such as AnimeListorWebMvcConfigurer indicate customized configurations for the web layer.
• External and Supporting Services:
• Database: MySQL managed via Docker-compose.
• Monitoring: Prometheus (with its configuration in prometheus.yml) and Grafana for dashboard visualization.
• API Documentation: Swagger generated automatically via SpringDoc OpenAPI 3.
• Testing: The inclusion of both unit and integration tests (in the src/test tree) indicates a comprehensive test layer.
Relationships and Interactions
• Clients (e.g., Postman, Swagger UI, web browsers) send HTTP requests which are processed by the Controller layer.
• Requests flow through Spring Security to ensure proper authentication (using basic in-memory credentials).
• Controllers invoke methods in the Service layer, which in turn call the Repository layer for database operations.
• Exceptions raised in any layer are centrally handled by the RestExceptionHandler to inform users of errors.
• Docker Compose coordinates external dependencies (MySQL, Prometheus, Grafana) which interact with the API container.
• Monitoring data flows from the application (via Prometheus metrics) into Grafana dashboards.