How cryselayala98/proyecto-api works
Main Components
• API Application: At the heart is the Spring Boot application (ApiApplication.java) that bootstraps the entire service.
• Controllers: Exposed endpoints are handled by controllers such as HistoryController and MathOperationsController.
• Services: Business logic is managed by service components (MathOperationsService, HistoryCallService, ResponseService) implemented in their respective impl classes.
• Repository Layer: Persistence logic for history calls, responses, and caching is handled by repository classes such as HistoryCallRepository and ResponseRepository.
• Caching Mechanism: There is a caching layer that uses dedicated classes (RedisEntity, PercentageCacheRepository, PercentageCacheService) with their implementations.
• External Services: Components under externalServices (PercentageService, ExternalCallsService) indicate integration with external systems.
• Configuration: Several configuration classes (CacheConfig, OpenApiConfig, WebClientConfig, PageableWebFluxConfiguration, WebConfig) set up the runtime environment and dependencies (e.g., for caching and reactive web features).
• Database & Redis: Although not directly in the code, the inclusion of script.sql and docker-compose.yml indicates a database container. Redis, used for caching, is also spun up via Docker.
• Presentation Layer: Controllers that receive HTTP requests.
• Business Logic Layer: Service classes that implement the core computation and delegation to cache/external service calls.
• Data Access Layer: Repositories that handle persistence for entities such as HistoryCall and Response.
• Caching Layer: Redis cache components showing the flow of data between the application and Redis.
• Integration with External Systems:
• Database: Represented by a separate database container (as indicated by script.sql and docker-compose) where the repositories operate.
• Infrastructure and Deployment:
• Docker: Include Docker containers for the entire API, Redis, and the database. Indicate that “docker-compose” sets up these containers.
• Configuration management: Note how configuration classes set up routing, caching, and API documentation (Swagger setup available via ApiHub and local URL).
Architectural Patterns and Design Principles
• MVC / Layered Architecture: Controllers, services, and repositories are clearly separated.
• Reactive Programming: Emphasize that the system is built using Spring WebFlux to support non-blocking operations which is a core design principle.
• Caching Strategy: Highlight the cache mechanism integration between controllers/services and Redis for performance improvements.
• Integration / External Service Calls: Indicate that some service logic is delegated to external APIs or services.