Skip to content

AhmetSah13/Gallery-Management-System

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

3 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš— Gallery Management System

A comprehensive car gallery management system built with Spring Boot 3.5.6 and Java 21, featuring authentication, sales tracking, and customer management.

πŸ—οΈ Technology Stack

  • 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

πŸš€ Features

Core Functionality

  • βœ… 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

Technical Features

  • βœ… 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

πŸ“‹ Prerequisites

  • Java 21+
  • Maven 3.6+
  • PostgreSQL 12+
  • Redis 6+ (optional, for caching)

πŸ› οΈ Installation & Setup

1. Clone the Repository

git clone <repository-url>
cd gallery

2. Database Setup

-- Create database
CREATE DATABASE postgres;

-- Create schema
CREATE SCHEMA gallery;

3. Configuration

Update application.yml with your database credentials:

spring:
  datasource:
    url: jdbc:postgresql://localhost:5432/postgres
    username: your_username
    password: your_password

4. Run the Application

mvn spring-boot:run

πŸ“š API Documentation

Swagger UI

Once the application is running, access the interactive API documentation at:

Authentication Flow

1. Register a User

POST /register
Content-Type: application/json

{
  "username": "testuser",
  "password": "password123"
}

2. Authenticate

POST /authenticate
Content-Type: application/json

{
  "username": "testuser",
  "password": "password123"
}

Response:

{
  "success": true,
  "data": {
    "accessToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "refreshToken": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9..."
  }
}

3. Use Token in Requests

GET /rest/api/car
Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...

πŸ” Security

JWT Configuration

  • Access Token: 2 hours expiration
  • Refresh Token: 4 hours expiration
  • Algorithm: HS256
  • Secret: Configurable via application.yml

CORS Configuration

  • Allowed Origins: * (configurable)
  • Allowed Methods: GET, POST, PUT, DELETE, OPTIONS
  • Allowed Headers: *
  • Credentials: Enabled

πŸ§ͺ Testing

Run Tests

# Run all tests
mvn test

# Run specific test class
mvn test -Dtest=CarServiceTest

# Run with coverage
mvn test jacoco:report

Test Coverage

  • Unit Tests: Service layer, Repository layer
  • Integration Tests: Controller layer with MockMvc
  • Test Coverage: >80% target

πŸ“Š Monitoring & Health Checks

Actuator Endpoints

Logging

  • Application Logs: logs/gallery.log
  • Log Level: DEBUG (configurable)
  • Request/Response Logging: Enabled

πŸ—οΈ Architecture

Project Structure

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

Key Design Patterns

  • Repository Pattern - Data access abstraction
  • Service Layer - Business logic encapsulation
  • DTO Pattern - Data transfer optimization
  • Event-Driven - Asynchronous processing
  • Audit Pattern - Change tracking

πŸ”§ Configuration

Environment Variables

# 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=6379

πŸš€ Deployment

Docker Deployment

FROM openjdk:21-jdk-slim
COPY target/gallery-0.0.1-SNAPSHOT.jar app.jar
EXPOSE 8080
ENTRYPOINT ["java", "-jar", "/app.jar"]

Production Considerations

  • Configure proper JWT secrets
  • Set up Redis for caching
  • Configure database connection pooling
  • Set up monitoring and alerting
  • Configure log aggregation

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Submit a pull request

πŸ“„ License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

πŸ‘¨β€πŸ’» Author

Ahmet Şahin

πŸ†˜ Support

For support and questions:


Happy Coding! πŸš€

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages