How altrof/selmefy_hotel_backend works
Main Components
• Application Entry & Bootstrapping:
• The HotelApplication.java class (located in tech.selmefy.hotel) serves as the Spring Boot entry point.
• Controllers (Presentation Layer):
• Organized into several domain-specific packages: auth, booking, hotelservice, hotelserviceorder, person, room, and user_account.
• That these controllers expose REST endpoints to the front end or external clients.
• Services (Business Logic Layer):
• Each major domain (auth, booking, room, etc.) has a corresponding service package.
• These components handle business logic and orchestrate data flows from controllers to repositories.
• Repositories & Data Access Layer:
• Each domain has its repository package (e.g., booking, person, room, etc.).
• These modules abstract the database communication and use ORM for persistence.
• Security Components:
• Spring Security configuration (WebSecurityConfig) and key classes like AuthTokenFilter, JwtTokenUtil, and AuthEntryPointJwt.
• How the AuthenticationProvider (using a UserDetailsService – implemented in UserAccountService or similar) handles credentials and token validation.
• Database:
• The PostgreSQL database is setup (as indicated by the docker-compose and sql_scripts files) and is managed with migration scripts using Liquibase (located under src/main/resources/db/changelog).
• Configurations & Utilities:
• Additional configurations are in dedicated packages (config for Swagger, TemplateConfig, security configuration, etc.) and fallback shared utilities (validators, email_sender, etc.).
Relationships and Interactions
• A client calls a REST endpoint on a Controller.
• The Controller interacts with the corresponding Service.
• The Service uses one or more Repositories to fetch or update data in the database.
• Security layers:
• Before a request reaches the Controller, it passes through a Security Filter (AuthTokenFilter) that uses JwtTokenUtil to verify the token. Any issues are handled by AuthEntryPointJwt.
• A DaoAuthenticationProvider in the security configuration integrates with the UserDetailsService to retrieve user-specific details.
Architectural Patterns and Design Principles
• Use a layered architecture (presentation, business, data) to separate concerns.
• Incorporate dependency injection and inversion of control as provided by Spring Boot.
• Stateless authentication with JWT, which influences the security design (no server sessions; instead, using tokens).
• How docker-compose and Dockerfile are used for deployment and local testing, representing infrastructure components that encapsulate the backend and the PostgreSQL database as separate services.
Relevant Technologies and Frameworks
• Java 17 with Spring Boot for the main application.
• Spring Security integrated with JWT (with references to spring-security-core, spring-security-web, and spring-security-config).
• Gradle for dependency management/build (build.gradle and settings.gradle).
• Liquibase for managing database migrations.
• Docker and docker-compose for containerized deployment.
• Swagger for API documentation and possibly Spring MVC configurations.