How davidfparrab/reserva-tickets works
Main Components
• Service Layer (Business Logic)
– Controllers: e.g., ReservaController and ShowController which expose REST endpoints.
– Services: e.g., BookService, ShowService, and ValidationService that encapsulate business rules and transaction management (for updating seats and reservations in one atomic operation).
• Data Access Layer
– Repositories: Interfaces like BookRepository, LocationRepository, SeatRepository, and ShowRepository along with their implementations.
– Firestore: The NoSQL database (using the Firestore SDK) that holds collections for objects (books/reservations, locations, seats, shows).
• Security Layer
– Security Token Bearer: Two types of tokens for differentiation between app users and admin users.
• Data Transfer Objects and Models
– DTOs: Objects like Filter that are used to process requests (especially for the filtering endpoints).
– Domain Models: Classes like Book, Location, Seat, and Show represent the domain structure.
• External Integration
– The application interacts externally via HTTP REST API endpoints.
– It includes transactional behavior with Firestore to maintain database consistency.
Relationships and Interactions
• The Client (user app or admin user) sends an HTTP request (for reserving, querying availability, or filtering shows) with an Authorization header (Bearer tokens).
• The REST Controllers (ReservaController, ShowController) receive these requests.
• Controllers delegate processing to the Service layer, which applies business logic.
• Services interact with Repositories to perform CRUD operations on Firestore. The transaction modality ensures that, for instance, seat reservations are atomic.
• The security mechanism intercepts the requests early to validate the tokens before the request reaches the controller.
• Responses (JSON) are sent back through the REST controllers.
Architectural Patterns & Design Principles
• Layered Architecture: Clearly separating the controller (API), service (business logic), and repository (data access) layers.
• Dependency Inversion: The use of interfaces for service and repository implementations suggests that dependency injection is at work (a typical Spring Boot pattern).
• Transaction Management: The use of one transaction per reservation creation in Firestore ensures reliability during seat reservation.
• Security Model: Token-based authentication with clearly defined roles (APP user vs. ADMIN) delineates responsibilities.
Relevant Technologies, Frameworks & Libraries
• Java with Spring Boot (as seen in the structure with meli/reserva/tickets and the main application class).
• Firestore (NoSQL database SDK), chosen for its simplicity with collections and its transactional support.
• Maven (based on the pom.xml and mvnw scripts) for dependency and build management.
• Docker (Dockerfile present) possibly for deploying the application as a container.
• Testing: JUnit tests as indicated under the src/test directory.