How 412139-chachagua/teg_mydiagrams_public works
Project type and purpose
• This is the backend of a full-stack digital version of the TEG board game. It exposes a REST API (Spring Boot) implementing game mechanics, user management, chat, and state persistence. Although there is no frontend code here, the system is intended to serve a separate client application (web or mobile).
File structure and README
• Top-level artifacts:
• pom.xml, mvnw → Java/Spring Boot build
• src/main/java → layered API (controllers, services, repositories, entities, DTOs)
• src/main/resources/application.properties → runtime configuration (DB connection, ports, etc.)
• scripts/BD_TEG.sql → initial database schema
• Layers follow a classic MVC/service/repository pattern with MapStruct mappers and SpringDoc (Swagger) for API docs.
Core architectural components
a. Client (web/mobile) – consumes REST endpoints and pushes/polls chat messages
b. API Layer (Controllers) – Spring MVC REST controllers (Ping, Usuario, Partida, Chat, etc.)
c. Business Layer (Services) – interfaces + impl packages encapsulate game logic, security, chat, DTO mapping
d. Data Layer (Repositories) – Spring Data JPA repositories for entities (Usuario, Partida, Mensaje, Pais, Turno, etc.)
e. Persistence Store – relational database (PostgreSQL or H2) defined via application.properties and initialized by BD_TEG.sql
f. Cross-cutting / Infra
• MapStruct (MappersConfig)
• Swagger/OpenAPI (SpringDocConfig)
• Authentication module (AutenticacionService)
• Logging, error handling (ErrorApi DTO)
Relationships and interactions
• Client → HTTP(S) → Controllers
• Controller methods delegate to Service interfaces
• Services orchestrate business rules, call Repositories, use Mappers to convert Entities ↔ DTOs
• Repositories ↔ Database
• ChatController ↔ ChatService may poll or publish messages (consider WebSocket or long-polling extension in future)
Architectural patterns / design principles
• Layered (Controller → Service → Repository)
• Dependency injection (Spring @Component, @Service, @Repository)
• Separation of concerns (DTO vs. Entity)
• Configuration externalized (application.properties)
• API documentation via OpenAPI / Swagger
• Use of MapStruct for mapping to reduce boilerplate