A well-structured Spring Boot application following layered architecture best practices.
- 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
- Java 21
- Gradle
- Docker and Docker Compose
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
- Clone the repository:
git clone https://github.com/2RK-dev/disc-hard.gitor :
git clone git@github.com:2RK-dev/disc-hard.gitand :
cd layered-app-
Configure your environment variables in the
.envfile located in thesrc/main/resources/directory. -
Start the database using Docker Compose:
docker-compose up -d- 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- Run the application:
./gradlew bootRunor just click play button in your IDE
- Access the API documentation:
http://localhost:8080/api/v1/swagger-ui.html
- 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
SwaggerUI is available at/api/v1/swagger-ui.html
- Database Migrations
The application uses
Flywayfor database migrations. Migration scripts are located insrc/main/resources/db/migration.
GET /api/v1/{controllerName}
For further reference, please consider the following sections: