An open API service indexing awesome lists of open source software.

https://github.com/y1j2x34/springboot-ktorm-boilerplate


https://github.com/y1j2x34/springboot-ktorm-boilerplate

boilerplate captcha kotlin ktorm spring-boot spring-security spring-security-jwt

Last synced: 29 days ago
JSON representation

Awesome Lists containing this project

README

          

# Spring Boot Ktorm Boilerplate

Enterprise-ready Spring Boot application with Ktorm ORM, featuring complete Docker configurations for both development and production environments.

## πŸ“– Documentation

### Quick Links

| Language | Development | Production |
|----------|-------------|------------|
| **English** | [Quick Start](docs/en/DOCKER-QUICKSTART.md) | [Production Guide](docs/en/README.md) |
| **δΈ­ζ–‡** | [εΏ«ι€ŸεΌ€ε§‹](docs/zh-CN/DOCKER-QUICKSTART.md) | [η”ŸδΊ§ιƒ¨η½²](docs/zh-CN/README-PRODUCTION.md) |

### Complete Documentation

- **English**: [docs/en/](docs/en/)
- **δΈ­ζ–‡**: [docs/zh-CN/](docs/zh-CN/)

## πŸš€ Quick Start

### Development Environment

```bash
# Start all services
./start-all.sh

# Access:
# - API: http://localhost:8081/api
```

### Production Environment

```bash
# 1. Configure environment
cp env.prod.example .env.prod
vim .env.prod

# 2. Deploy
./deploy-prod.sh --with-monitoring
```

## πŸ“¦ Features

### Development
- βœ… One-command startup
- βœ… Hot reload support
- βœ… Easy debugging
- βœ… Docker-based development

### Production
- βœ… Security hardening (non-root user, network isolation)
- βœ… Resource management (CPU/memory limits)
- βœ… Complete monitoring (Prometheus + Grafana + Loki)
- βœ… Automated deployment scripts
- βœ… Health checks and auto-restart
- βœ… Log management and rotation

## πŸ—οΈ Project Structure

```
.
β”œβ”€β”€ docs/
β”‚ β”œβ”€β”€ en/ # English documentation
β”‚ └── zh-CN/ # Chinese documentation
β”œβ”€β”€ docker/
β”‚ └── configs/ # Database configurations
β”‚ β”œβ”€β”€ mariadb/
β”œβ”€β”€ app/ # Main application
β”œβ”€β”€ common/ # Common modules
β”œβ”€β”€ captcha/ # Captcha module
β”œβ”€β”€ jwt-auth/ # JWT authentication
β”œβ”€β”€ user/ # User module
β”œβ”€β”€ monitoring/ # Monitoring configurations
β”œβ”€β”€ docker-compose.yml # Development environment
β”œβ”€β”€ docker-compose.prod.yml # Production environment
β”œβ”€β”€ docker-compose.monitoring.yml # Monitoring stack
└── deploy-prod.sh # Deployment script
```

## πŸ› οΈ Tech Stack

- **Backend**: Spring Boot 2.7.1, Kotlin 1.8.20
- **ORM**: Ktorm 3.6.0
- **Database**: MariaDB 11.2
- **Auth**: JWT
- **Captcha**: Anji-Plus Captcha
- **Containerization**: Docker, Docker Compose
- **Monitoring**: Prometheus, Grafana, Loki

## πŸ“Š Services

### Development Environment

| Service | Port | Description |
|---------|------|-------------|
| Spring Boot | 8081 | Main API |
| MariaDB | 3306 | Database |

### Production Environment (Additional)

| Service | Port | Description |
|---------|------|-------------|
| Grafana | 3000 | Monitoring dashboards |
| Prometheus | 9090 | Metrics collection |
| Loki | 3100 | Log aggregation |

## πŸ”’ Security Features (Production)

- Non-root user execution
- Network isolation (internal/external networks)
- Environment variable management for secrets
- Security options (no-new-privileges)
- SSL/TLS support
- Regular security updates

## πŸ“ˆ Monitoring (Production)

- Real-time metrics (CPU, Memory, Requests)
- Application performance monitoring
- Log aggregation and search
- Pre-configured alerts (20+ rules)
- Grafana dashboards
- Health checks

## πŸ’Ύ Backup & Recovery (Production)

- Automated database backups
- Volume backup scripts
- Point-in-time recovery
- Backup retention policies
- Disaster recovery procedures

## 🎯 Use Cases

### Development
```bash
./start-all.sh # Start
./logs.sh all # View logs
./stop-all.sh # Stop
make help # View all commands
```

### Production
```bash
./deploy-prod.sh # Deploy
./deploy-prod.sh --with-monitoring # Deploy with monitoring
./stop-prod.sh # Stop
./stop-prod.sh --volumes # Stop and remove data
```

## πŸ“š Documentation Index

### Getting Started
- [Development Quick Start (EN)](docs/en/DOCKER-QUICKSTART.md) | [εΌ€ε‘εΏ«ι€ŸεΌ€ε§‹ (CN)](docs/zh-CN/DOCKER-QUICKSTART.md)
- [Production Quick Start (EN)](docs/en/README.md) | [η”ŸδΊ§εΏ«ι€ŸεΌ€ε§‹ (CN)](docs/zh-CN/README-PRODUCTION.md)

### Complete Guides
- [Production Deployment Guide (EN)](docs/en/PRODUCTION.md) | [η”ŸδΊ§ιƒ¨η½²ζŒ‡ε— (CN)](docs/zh-CN/PRODUCTION.md)
- [Production Checklist (EN)](docs/en/PRODUCTION-CHECKLIST.md) | [η”ŸδΊ§ζ£€ζŸ₯清单 (CN)](docs/zh-CN/PRODUCTION-CHECKLIST.md)

### Reference
- [Development vs Production (EN)](docs/en/DEV-VS-PROD.md) | [开发vsη”ŸδΊ§ (CN)](docs/zh-CN/DEV-VS-PROD.md)
- [Documentation Index (EN)](docs/en/INDEX.md) | [ζ–‡ζ‘£η΄’εΌ• (CN)](docs/zh-CN/INDEX.md)

## πŸ†˜ Troubleshooting

### Service won't start
```bash
# Development
./logs.sh all

# Production
docker compose -f docker-compose.prod.yml logs
```

### Port conflicts
Edit port mappings in `docker-compose.yml` or `docker-compose.prod.yml`

### Database connection issues
```bash
# Check database status
docker compose ps
docker exec mariadb-db mysql -uroot -p -e "SELECT 1"
```

## 🀝 Contributing

Contributions are welcome! Please read our contributing guidelines before submitting pull requests.

## πŸ“ License

[Your License]

## πŸ“ž Support

- Documentation: [docs/](docs/)
- Issues: [GitHub Issues](your-repo-issues)
- Email: your-email@example.com

---

**⚠️ Important Notes:**
- For production deployment, read the complete [Production Guide](docs/en/PRODUCTION.md)
- Always use strong passwords in production
- Enable monitoring for production environments
- Backup data regularly
- Test thoroughly before production deployment