How jeansupre/stardewvalleyprojectback works
Main Components
a. API Controllers: Located in the “controller” package, with subcategories such as AdminController and AuthController (in the “publics” folder). These components handle inbound HTTP requests.
b. Service Layer: Splitting into interfaces (in service/interfaces) and implementations (in service/impl), these encapsulate business logic (e.g., AuthServiceImpl, AdminServiceImpl, JwtService).
c. Data Access Layer: Represented by repositories (in the “repository” package) interfacing with data persistence, handling entities such as Aldeano, Cultivo, Item, etc.
d. Data Transfer Objects (DTOs): In the “dto” package (e.g., for creating users, items, etc.) supporting data interchange between client and server.
e. Domain Models: In the “model” package, these are the application’s core entities (Aldeano, Categoria, Cultivo, etc.).
f. Security Module: The “security” package includes annotations and interceptors (e.g., JwtInterceptor) and related configurations ensuring JWT authentication.
g. Configuration: The “config” package and resources (application.properties, messages files) hold the environment setup, locale resolving, Swagger documentation, and web configurations.
h. Utility Components: In the “util” package (e.g., Constantes, ITools, Mensajes).
Relationships and Data Flow
• Clients call the API endpoints through the controllers.
• Controllers delegate requests to the service layer, which orchestrates business logic.
• The service layer interacts with the repository layer to perform CRUD operations on the domain models.
• Security interceptors (like JwtInterceptor) work on the request flow to enforce authentication/authorization before controllers get involved.
• Configuration components (e.g., Swagger, locale, web settings) ensure that the API is both well documented and tailored for internationalization.
• DTOs translate data between front-end requests and backend domain models, while Mapper interfaces ensure correct conversions.
Architectural Patterns and Design Principles
• Layered (n-tier) Architecture: Clearly separating controllers, services, and repositories.
• MVC (Model-View-Controller) principles: While this is primarily an API backend (without a traditional “view”), the controller-model separation follows MVC ideas.
• Security is implemented using interceptors and annotations, ensuring concerns of authentication are modular and cross-cutting.
• Integration with external tools/libraries is managed via Maven, which handles dependency management.
Relevant Technologies
• Java and Spring Boot framework patterns (configurations, MVC architecture)
• Maven for build and dependency management (pom.xml, mvnw scripts)
• Swagger for API documentation (SwaggerConfig)
• Internationalization (i18n) via locale resolvers and message properties files
• JWT based authentication via security interceptors.
Detail
• Avoid oversimplification – clearly denote sub-packages like “publics” under controllers and the separation of DTO and mappers.