A comprehensive car gallery management system built with Spring Boot 3.5.6 and Java 21, featuring authentication, sales tracking, and customer management.
- Backend: Spring Boot 3.5.6, Java 21
- Database: PostgreSQL
- Security: Spring Security + JWT
- ORM: Spring Data JPA + Hibernate
- Documentation: Swagger/OpenAPI 3
- Mapping: MapStruct
- Caching: Redis
- Monitoring: Spring Boot Actuator
- Testing: JUnit 5, Mockito, MockMvc
- β User Authentication - JWT-based secure authentication
- β Car Management - Add, update, and track cars
- β Customer Management - Customer profiles and accounts
- β Sales Tracking - Complete sales workflow
- β Currency Support - Multi-currency transactions (TL/USD)
- β Audit Trail - Complete audit logging
- β RESTful API - Clean REST endpoints
- β Request/Response Logging - Comprehensive logging
- β Event-Driven Architecture - Asynchronous event processing
- β Caching - Redis-based caching
- β API Documentation - Swagger UI integration
- β Health Monitoring - Actuator endpoints
- Java 21+
- Maven 3.6+
- PostgreSQL 12+
- Redis 6+ (optional, for caching)
git clone <repository-url>
cd gallery-- Create database
CREATE DATABASE postgres;
-- Create schema
CREATE SCHEMA gallery;Update application.yml with your database credentials:
spring:
datasource:
url: jdbc:postgresql://localhost:5432/postgres
username: your_username
password: your_passwordmvn spring-boot:runOnce the application is running, access the interactive API documentation at:
- Swagger UI: http://localhost:8080/swagger-ui.html
- API Docs: http://localhost:8080/v3/api-docs
POST /register
Content-Type: application/json
{
"username": "testuser",
"password": "password123"
}POST /authenticate
Content-Type: application/json
{
"username": "testuser",
"password": "password123"
}Response:
{
"success": true,
"data": {
"accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
}
}GET /rest/api/car
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...- Access Token: 2 hours expiration
- Refresh Token: 4 hours expiration
- Algorithm: HS256
- Secret: Configurable via
application.yml
- Allowed Origins:
*(configurable) - Allowed Methods: GET, POST, PUT, DELETE, OPTIONS
- Allowed Headers:
* - Credentials: Enabled
# Run all tests
mvn test
# Run specific test class
mvn test -Dtest=CarServiceTest
# Run with coverage
mvn test jacoco:report- Unit Tests: Service layer, Repository layer
- Integration Tests: Controller layer with MockMvc
- Test Coverage: >80% target
- Health: http://localhost:8080/actuator/health
- Metrics: http://localhost:8080/actuator/metrics
- Info: http://localhost:8080/actuator/info
- Application Logs:
logs/gallery.log - Log Level: DEBUG (configurable)
- Request/Response Logging: Enabled
src/
βββ main/java/com/ahmetsahin/gallery/
β βββ config/ # Configuration classes
β βββ controller/ # REST controllers
β βββ dto/ # Data Transfer Objects
β βββ event/ # Event handling
β βββ exception/ # Exception handling
β βββ filter/ # Request filters
β βββ handler/ # Exception handlers
β βββ jwt/ # JWT utilities
β βββ mapper/ # MapStruct mappers
β βββ model/ # JPA entities
β βββ repository/ # Data repositories
β βββ service/ # Business logic
βββ test/ # Test classes
- Repository Pattern - Data access abstraction
- Service Layer - Business logic encapsulation
- DTO Pattern - Data transfer optimization
- Event-Driven - Asynchronous processing
- Audit Pattern - Change tracking
# Database
SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/postgres
SPRING_DATASOURCE_USERNAME=postgres
SPRING_DATASOURCE_PASSWORD=your_password
# JWT
JWT_SECRET=your_secret_key
JWT_ACCESS_TOKEN_EXPIRATION=7200000
JWT_REFRESH_TOKEN_EXPIRATION=14400000
# Redis (optional)
SPRING_REDIS_HOST=localhost
SPRING_REDIS_PORT=6379FROM openjdk:21-jdk-slim
COPY target/gallery-0.0.1-SNAPSHOT.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "/app.jar"]- Configure proper JWT secrets
- Set up Redis for caching
- Configure database connection pooling
- Set up monitoring and alerting
- Configure log aggregation
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.
Ahmet Εahin
- Email: ahmet@example.com
- GitHub: @sahinahmet
For support and questions:
- Create an issue in the repository
- Contact: ahmet@example.com
Happy Coding! π