Skip to content

TreesSoftware/supap-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

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

Repository files navigation

Java Spring Boot REST API Boilerplate

A production-ready Java Spring Boot boilerplate for building scalable REST APIs with enterprise-grade patterns, comprehensive security, and AI-friendly architecture.

πŸš€ Quick Start

# Clone the repository
git clone [repository-url]
cd backend-java-spring-boot

# Build the project
mvn clean install

# Run the application
mvn spring-boot:run

# Access API documentation
open http://localhost:8080/swagger-ui.html

✨ Features

Core Features

  • βœ… Layered Architecture: Clean separation with Controller/Service/Repository/Model
  • βœ… RESTful API: Complete REST API with best practices
  • βœ… Spring Security: JWT authentication and role-based authorization
  • βœ… Data Persistence: Spring Data JPA with PostgreSQL
  • βœ… API Documentation: Interactive Swagger UI with Springdoc OpenAPI
  • βœ… Validation: Bean Validation with custom validators
  • βœ… Exception Handling: Global exception handling
  • βœ… Logging: Structured logging with SLF4J and Logback

Advanced Features

  • ⚑ Caching: Redis (distributed) and Caffeine (local)
  • πŸ”„ Async Processing: @Async support with custom thread pools
  • πŸ“¨ Message Queuing: Kafka and RabbitMQ integration
  • ⏰ Scheduled Tasks: @Scheduled tasks
  • πŸ“ File Handling: File upload/download with validation
  • βœ‰οΈ Email Service: Async email sending
  • πŸ”Œ WebSockets: Real-time communication patterns
  • πŸ“‘ Event-Driven: Spring Events for decoupled communication

Development Features

  • πŸ§ͺ Testing: Unit, integration, and e2e test patterns
  • πŸ“Š Monitoring: Spring Boot Actuator with custom metrics
  • 🐳 Docker: Docker and Docker Compose support
  • πŸ”„ Migrations: Flyway for version-controlled schema changes
  • 🌍 Profiles: Dev, staging, production configurations
  • βœ… Code Quality: Checkstyle, SpotBugs, PMD

πŸ› οΈ Tech Stack

Category Technology
Runtime Java 21 LTS
Framework Spring Boot 3.x
Build Tool Maven
Database PostgreSQL (default)
ORM Spring Data JPA + Hibernate
Authentication Spring Security + JWT
API Docs Springdoc OpenAPI
Testing JUnit 5, Mockito, Spring Boot Test
Caching Redis, Caffeine
Messaging Kafka, RabbitMQ
Deployment Docker, Kubernetes
Monitoring Actuator, Micrometer

πŸ“‹ Prerequisites

  • Java 21 or higher (Download)
  • Maven 3.8+ (Download)
  • PostgreSQL 14+ (Download) - Optional, H2 available for dev
  • Docker (Optional) - For containerized deployment

πŸ—οΈ Building from Source

You don't need to build from source to use this boilerplate, but if you want to customize or contribute:

Clone and Build

# Clone the repository
git clone [repository-url]
cd backend-java-spring-boot

# Build the project (skip tests for faster build)
mvn clean install -DskipTests

# Build with tests
mvn clean install

# Package as JAR
mvn clean package

Run Locally

# Using Maven
mvn spring-boot:run

# Using Java directly
java -jar target/spring-boot-api-0.0.1-SNAPSHOT.jar

# With specific profile
mvn spring-boot:run -Dspring-boot.run.profiles=dev

Verify Installation

# Check if application is running
curl http://localhost:8080/actuator/health

# Access Swagger UI
open http://localhost:8080/swagger-ui.html

πŸ†˜ Getting Help

Having trouble with the boilerplate? We're here to help!

Documentation

Community Support

Before Asking for Help

  1. Search existing issues - Your question might already be answered
  2. Check the documentation - Especially the Getting Started and Troubleshooting guides
  3. Provide details - Include Spring Boot version, Java version, and error messages
  4. Create a minimal reproducible example - Helps us help you faster

Reporting Issues

Found a bug? Please create an issue with:

  • Clear description of the problem
  • Steps to reproduce
  • Expected vs actual behavior
  • Environment details (Java version, OS, etc.)
  • Stack traces or error messages

See our Issue Template for more details.

πŸ“ Project Structure

backend-java-spring-boot/
β”œβ”€β”€ .ai/                    # AI-specific configuration
β”‚   β”œβ”€β”€ context.yaml       # Project metadata
β”‚   β”œβ”€β”€ mcp-config.json    # MCP server config
β”‚   └── agent-instructions.md
β”œβ”€β”€ .claude/                # Claude Code commands
β”‚   β”œβ”€β”€ commands/          # Custom commands
β”‚   └── output-style.md
β”œβ”€β”€ docs/                   # Project documentation
β”‚   β”œβ”€β”€ index.md           # Main documentation entry
β”‚   β”œβ”€β”€ architecture/      # Architecture docs
β”‚   β”œβ”€β”€ guides/            # Setup & deployment guides
β”‚   β”œβ”€β”€ status/            # Current status tracking
β”‚   β”œβ”€β”€ templates/         # Documentation templates
β”‚   β”œβ”€β”€ session-management/ # AI session tracking
β”‚   └── _working/          # Temporary work files
β”œβ”€β”€ standards/              # Development standards
β”‚   β”œβ”€β”€ coding.md          # Code conventions
β”‚   β”œβ”€β”€ patterns.md        # Architectural patterns
β”‚   β”œβ”€β”€ business-rules.md  # Domain logic
β”‚   └── documentation.md   # Documentation standards
β”œβ”€β”€ rules/                  # Spring Boot rules
β”‚   β”œβ”€β”€ java-spring-boot-rules.md
β”‚   └── questions.md
└── src/                    # Source code (to be created)
    β”œβ”€β”€ main/
    β”‚   β”œβ”€β”€ java/
    β”‚   └── resources/
    └── test/

πŸ—οΈ Architecture

This boilerplate follows a layered architecture pattern:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚      Controller Layer (REST)        β”‚  ← HTTP Requests/Responses
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚         Service Layer               β”‚  ← Business Logic
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚       Repository Layer              β”‚  ← Data Access
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚         Model Layer                 β”‚  ← Domain Entities
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Principles:

  • Single Source of Truth
  • SOLID Principles
  • High Cohesion, Low Coupling
  • AI-Friendly Documentation

Core Modules

Module Purpose Example
config/ Application configuration, security, caching SecurityConfig.java, CacheConfig.java
controller/ REST API endpoints UserController.java
service/ Business logic implementation UserService.java
repository/ Data access layer UserRepository.java
model/entity/ JPA domain entities User.java, Product.java
model/dto/ Data transfer objects UserDTO.java, CreateUserRequest.java
security/ Authentication & authorization JwtTokenProvider.java, SecurityFilter.java
exception/ Custom exceptions & handlers GlobalExceptionHandler.java, UserNotFoundException.java
util/ Utility classes DateUtil.java, ValidationUtil.java

πŸ“š Documentation

Document Description
Project Overview Complete project overview
Setup Guide Environment setup instructions
Architecture System architecture details
API Documentation API specifications
Coding Standards Code conventions
Patterns Architectural patterns
Business Rules Domain logic

πŸ§ͺ Testing

# Run all tests
mvn test

# Run with coverage
mvn verify

# Run specific test
mvn test -Dtest=UserServiceTest

# Run integration tests
mvn verify -P integration-tests

Coverage Target: 80%+

🚒 Deployment

Docker

# Build image
docker build -t spring-boot-api .

# Run container
docker run -p 8080:8080 spring-boot-api

# Using docker-compose
docker-compose up

Kubernetes

# Apply manifests
kubectl apply -f k8s/

# Check deployment
kubectl get pods

πŸ”§ Configuration

Configuration files are located in src/main/resources/:

  • application.yml - Main configuration
  • application-dev.yml - Development profile
  • application-prod.yml - Production profile

Environment Variables

Variable Description Default
DB_HOST Database host localhost
DB_PORT Database port 5432
DB_NAME Database name myapp
DB_USERNAME Database username postgres
DB_PASSWORD Database password -
JWT_SECRET JWT signing secret -
JWT_EXPIRATION Token expiration (ms) 86400000

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Follow coding standards in standards/coding.md
  4. Write tests for your changes
  5. Ensure tests pass (mvn test)
  6. Update documentation
  7. Commit changes (git commit -m 'feat: add amazing feature')
  8. Push to branch (git push origin feature/amazing-feature)
  9. Open a Pull Request

Commit Message Format

Follow conventional commits:

<type>(<scope>): <subject>

feat: new feature
fix: bug fix
docs: documentation
style: formatting
refactor: code restructure
test: tests
chore: maintenance

πŸ“Š Status

  • Phase: Documentation & Setup
  • Completion: 20%
  • Next: Core implementation

See progress.yaml for detailed status.

πŸ€– AI-Friendly

This boilerplate is designed for AI-assisted development:

  • MCP Integration: Model Context Protocol for AI agents
  • Structured Documentation: Machine-readable status tracking
  • Context Files: AI behavior guidelines and project metadata
  • Clear Patterns: Well-documented architectural patterns

πŸ“ License

MIT License

πŸ†˜ Support

πŸ™ Acknowledgments

Built with:


Made with ❀️ for the Java Spring Boot community

Last Updated: 2025-10-08

About

supap backend - java spring boot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages