Skip to content

2RK-dev/disc-hard

Repository files navigation

Spring Boot Layered Application

A well-structured Spring Boot application following layered architecture best practices.

Features

  • Layered architecture (Controller, Service, Repository, etc.)
  • Global exception handling
  • Docker Compose for PostgreSQL database
  • Environment configuration with .env files
  • Security configuration
  • Unit and integration tests with Testcontainers

Prerequisites

  • Java 21
  • Gradle
  • Docker and Docker Compose

Project Structure

src/
├── main/
│   ├── java/
│   │   └── com/
│   │       └── _2rkdev/
│   │           └── dischard/
│   │               ├── config/       # Configuration classes
│   │               ├── controller/   # REST controllers
│   │               ├── dto/          # Data Transfer Objects
│   │               ├── entity/       # JPA entities
│   │               ├── exception/    # Custom exceptions and handlers
│   │               ├── mapper/       # Object mappers
│   │               ├── repository/   # Data repositories
│   │               ├── service/      # Business logic
│   │               └── utils/         # Utility classes
│   └── resources/
│       ├── application.yml   # Application configuration
│       └── .env              # Environment variables
└── test/                     # Test classes

Getting Started

Setting Up the Environment

  1. Clone the repository:
   git clone https://github.com/2RK-dev/disc-hard.git

or :

    git clone git@github.com:2RK-dev/disc-hard.git

and :

   cd layered-app
  1. Configure your environment variables in the .env file located in the src/main/resources/ directory.

  2. Start the database using Docker Compose:

   docker-compose up -d
  1. Create/update the .env file in src/main/resources/ with appropriate values:
DB_URL=jdbc:postgresql://localhost:5432/discharddb
DB_USERNAME=admin #change me
DB_PASSWORD=admin #change me
APP_SECRET_KEY=your_secret_key_for_jwt
  1. Run the application:
    ./gradlew bootRun

or just click play button in your IDE

  1. Access the API documentation:
http://localhost:8080/api/v1/swagger-ui.html
  1. API Documentation The application uses OpenAPI/Swagger for API documentation which provides:
  • Interactive API documentation
  • Request/response models
  • Testing capabilities
  • OpenAPI specification is available at /api/v1/api-docs Swagger UI is available at /api/v1/swagger-ui.html
  1. Database Migrations The application uses Flyway for database migrations. Migration scripts are located in src/main/resources/db/migration.

API Endpoints

  • GET /api/v1/{controllerName}

Reference Documentation

For further reference, please consider the following sections:

About

A chat application.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages