A lightweight REST API built with Javalin and a full production-ready DevOps pipeline using Docker, Traefik, and GitHub Actions.
Includes routing, controllers, exception handling, middleware-style security, PostgreSQL integration, and automated CI/CD deployment.
This repository contains:
- Javalin routing
- DAO β Service β Controller
- Exception & validation handling
- JWT or custom authentication (depending on your config)
- Unit + integration tests
- PostgreSQL integration
- Dockerfile + docker-compose
- Traefik reverse proxy & TLS certificates
- GitHub Actions CI/CD
- DigitalOcean deployment (SSH + Docker Compose)
- Environment-based configuration
Branch link:
π https://github.com/tysker/javalin_rest_api_pipeline/tree/traefik-pipeline
- Java + Javalin
- PostgreSQL
- JUnit testing
- Docker & Docker Compose
- Traefik v3 reverse proxy
- GitHub Actions CI/CD
- DigitalOcean droplet (Ubuntu)
src/
βββ main/java/
β βββ controllers/ # HTTP endpoints
β βββ daos/ # Database layer
β βββ services/ # Business logic
β βββ exceptions/ # Custom exceptions
β βββ security/ # Access manager / filters
β βββ util/ # Helpers
β βββ App.java # Application entrypoint
β
βββ test/
βββ unit/ # Unit tests
βββ integration/ # Integration tests
deployment/
βββ docker/
β βββ Dockerfile
β βββ docker-compose.yml
β βββ docker-compose.prod.yml
β βββ .env
β
βββ traefik/
β βββ traefik.yml # Static config
β βββ traefik_dynamic.yml # Routers / TLS
β βββ acme.json # Certificate storage
β
βββ github/workflows/
βββ deploy.yml # CI/CD pipeline
Run tests:
mvn testmvn clean package
java -jar target/app.jarRuns at:
http://localhost:7000
flowchart TD
A[Push to GitHub] --> B[GitHub Actions]
B --> C[Run Tests / Build JAR]
C --> D[Build Docker Image]
D --> E[Push Image to Docker Hub]
E --> F[SSH into DigitalOcean Server]
F --> G[docker compose pull]
G --> H[docker compose up -d]
H --> I[Traefik Routes Traffic + HTTPS]
ββββββββββββββββββββββββββββ
β Traefik v3 β
β Automatic HTTPS / Routing β
ββββββββββββββββ¬βββββββββββββ
β
ββββββββββββββββββ΄βββββββββββββββββ
β β
βββββββββββΌβββββββββββ ββββββββββββΌββββββββββ
β Javalin API β β Admin Dashboard β
β (Docker Container)β β (Optional) β
βββββββββββ¬βββββββββββ ββββββββββββ¬βββββββββββ
β β
ββββββββββββββββββ¬βββββββββββββββββ
β
ββββββββββββΌββββββββββ
β PostgreSQL β
β (Docker Container) β
βββββββββββββββββββββββ- All routes
- Example requests
- Example JSON responses
- Error model
Base URL:
`/api/*`
Returns list of users.
Returns a user by ID.
Creates a new user.
Body:
{
"username": "john",
"password": "secret"
}Updates a user.
Deletes a user.
{
"status": "error",
"message": "User not found",
"path": "/api/users/999",
"timestamp": "2025-01-20T10:15:14Z"
}- Docker architecture
- Traefik configuration
- GitHub Actions workflow explanation
- Deployment steps
- Environment variables
This project includes a complete CI/CD pipeline with:
- Docker
- Docker Compose
- Traefik v3
- GitHub Actions
- DigitalOcean (remote server)
GitHub Actions performs:
- Checkout
- Java build (
mvn -B package) - Run tests
- Build Docker image
- Push to Docker Hub
- GitHub connects to the remote server via SSH
- Server pulls the latest Docker image
- Traefik reloads routes automatically
- New version goes live instantly
Traefik handles:
- HTTPS certificates via Letβs Encrypt
- Routing to API container
- Middleware
- Logging
- Security headers
.env contains:
DOMAIN=mydomain.com
EMAIL=[admin@mydomain.com](mailto:admin@mydomain.com)
POSTGRES_URL=jdbc:postgresql://db:5432/app
POSTGRES_USER=user
POSTGRES_PASSWORD=password
APP_PORT=7000
Push to main automatically triggers deployment.