Skip to content

Latest commit

 

History

28 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Java REST API with CI/CD & Traefik Deployment

Overview

This project demonstrates how to design, build, and deploy a production-ready Java REST API with a fully automated CI/CD pipeline and container-based infrastructure, where changes are built, tested, and deployed without manual intervention.

The focus is not only on API implementation, but on the end-to-end delivery lifecycle: clean backend architecture, automated testing, containerization, secure routing, and zero-touch deployment.


Status & CI/CD

Build Java Javalin Docker Traefik


What This Project Demonstrates

  • Clean, layered Java backend architecture (DAO → Service → Controller)
  • REST API design with validation and structured error handling
  • Automated CI/CD pipeline from Git push to production deployment
  • Containerized runtime using Docker and Docker Compose
  • Reverse proxy, HTTPS, and routing with Traefik
  • Environment-based configuration suitable for real deployments

Architecture Overview

Developer
   │
   ▼
GitHub Repository
   │
   ▼
GitHub Actions (CI/CD)
   │   - Build & Test
   │   - Build Docker Image
   │   - Push Image
   │   - Deploy via SSH
   ▼
Docker & Docker Compose
   │
   ▼
Traefik (HTTPS & Routing)
   │
   ▼
Java REST API  ──► PostgreSQL

Repository Structure

src/
├── main/java/
│   ├── controllers/      # HTTP endpoints
│   ├── daos/             # Persistence layer
│   ├── services/         # Business logic
│   ├── exceptions/       # Centralized error handling
│   ├── security/         # Authentication / access control
│   ├── util/             # Shared utilities
│   └── App.java          # Application entrypoint
│
└── test/
    ├── unit/             # Unit tests
    └── integration/      # Integration tests

CI/CD Pipeline

The pipeline is triggered automatically on pushes to the main branch and performs:

  1. Source checkout
  2. Build and test execution (mvn package)
  3. Docker image build
  4. Image push to registry
  5. Remote deployment via SSH
  6. Zero-downtime restart using Docker Compose

This ensures that every change is tested, packaged, and deployed automatically.


Deployment Stack

Backend

  • Java
  • Javalin
  • PostgreSQL
  • JUnit

DevOps & Infrastructure

  • Docker & Docker Compose
  • Traefik (reverse proxy & HTTPS)
  • GitHub Actions (CI/CD)
  • Linux server (cloud VM)

Local Development

Build and run locally:

mvn clean package
java -jar target/app.jar

Application runs at:

http://localhost:7000

API Example

GET /api/users

Returns a list of users.

POST /api/users

Creates a new user.

{
  "username": "john",
  "password": "secret"
}

Error Handling

The API returns structured error responses for predictable client behavior:

{
  "status": "error",
  "message": "User not found",
  "path": "/api/users/999",
  "timestamp": "2025-01-20T10:15:14Z"
}

Why This Matters

This project reflects how backend services are built and operated in real production environments:

  • Automated delivery instead of manual deployments
  • Infrastructure-aware backend design
  • Secure routing and HTTPS by default

It serves as a practical reference for building and shipping backend services reliably.


Disclaimer

This project is a demonstration and learning project designed to showcase backend and DevOps practices. While simplified, the patterns and workflows mirror those used in real-world production systems.

About

This is a simple Javalin REST API that allows you to create, read, update and delete.

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages