This project is a robust backend built with Spring Boot, leveraging Hibernate for ORM and Spring Security for authentication and authorization.
- Main Features
- Technologies Used
- Quick Start
- Project Configuration
- Database Schema
- Security and Authentication
- API Endpoints
- Exception Handling
- Contributing
- License
- 🔐 JWT-based authentication with access and refresh tokens
- 📊 RESTful API endpoints for concert ticket booking operations
- 🗃️ Database integration with Hibernate ORM and MySQL
- 📈 Efficient data querying with lazy loading
- 🔄 Asynchronous request processing
- 📝 Comprehensive API documentation with Swagger UI
- 🛡️ Robust exception handling and logging
| Category | Technologies |
|---|---|
| Core | |
| Security | |
| Database | |
| API Documentation | |
# Clone the repository git clone https://github.com/saraobialero/SpringBoot3.3.1-HibernateDB_Concerts-TicketStore-App.git cd SpringBoot3.3.1-HibernateDB_Concerts-TicketStore-App # Configure application properties (see Project Configuration section) # Build the project ./mvnw clean install # Run the application ./mvnw spring-boot:runThe application will start on http://localhost:8080.
Before running the application, ensure you have set up the following configuration files:
-
application-dev.properties,application-prod.properties,application-test.properties:- Configure database connection
- Set JWT secret and token expiration times
- Configure logging levels
-
logback-spring.xml:- Configure detailed logging behavior for different profiles
Example application-dev.properties:
spring.datasource.url=jdbc:mysql://localhost:3306/db?createDatabaseIfNotExist=true&useUnicode=yes&characterEncoding=UTF-8 spring.datasource.username=root spring.datasource.password=your_password spring.jpa.hibernate.ddl-auto=create-drop application.security.jwt-secret-key=your_secret_key application.security.jwt-expired-access-token=900000 application.security.jwt-expired-refresh-token=86400000The project uses the following main entities:
- User: OneToMany relationship with Order
- Reply: OneToOne relationship with Ticket
- Ticket:
- OneToOne with Reply
- ManyToOne with Seller
- OneToMany with Order
- Order:
- ManyToOne with User
- ManyToOne with Ticket
- Seller: OneToMany with Ticket
Notable changes from the original schema:
- Use of
BigDecimalfor prices LocalDatefor dates- Integer IDs with auto-increment
PaymentTypemoved to the Order entity
- JWT-based authentication with access and refresh tokens
- Tokens are automatically validated by a filter
- In Swagger UI, simply insert the token in the "Authorize" section to authenticate requests
To access protected endpoints for example in Postman, include the JWT token in the Authorization header:
Authorization: Bearer <your_token_here> Protected endpoints are defined in ApiUtils.java. Some key endpoints include:
/api/auth/login: User login/api/auth/signup: User registration/api/tickets/: View available tickets/api/orders/: Manage orders
For a complete list of endpoints, refer to the Swagger documentation at http://localhost:8080/swagger-ui.html when the application is running.
The project includes a comprehensive exception handling system:
- Custom exceptions for various scenarios (e.g.,
UserException,OrderException) - Global exception handler (
ExceptionHandlerConfig) to manage and return appropriate error responses - Detailed logging of exceptions for troubleshooting
Contributions are welcome! Please ensure that your contributions maintain the existing code structure and follow the established patterns for exception handling and API design.
This project is licensed under the MIT License.