|
| 1 | +# 🚀 Contact API — Production-Ready Spring Boot Backend |
| 2 | + |
| 3 | +A **production-grade backend system** built with Spring Boot, containerised using Docker, and deployed on a VPS with **zero-downtime blue-green deployment**, **NGINX reverse proxy**, and **full monitoring using Prometheus & Grafana**. |
| 4 | + |
| 5 | +--- |
| 6 | + |
1 | 7 | ## 🏗️ Architecture Overview |
2 | 8 |
|
3 | | - |
| 9 | +<p align="center"> |
| 10 | + <img src="assets/architecture-minimal.png" width="700"/> |
| 11 | +</p> |
| 12 | + |
| 13 | +--- |
| 14 | + |
| 15 | +## ⚙️ Detailed System Architecture |
| 16 | + |
| 17 | +<p align="center"> |
| 18 | + <img src="assets/architecture-detailed.png" width="900"/> |
| 19 | +</p> |
| 20 | + |
| 21 | +--- |
| 22 | + |
| 23 | +## 🚀 Key Features |
| 24 | + |
| 25 | +* 🔁 **Blue-Green Deployment** (Zero Downtime) |
| 26 | +* 🐳 **Dockerized Application** |
| 27 | +* 🌐 **NGINX Reverse Proxy Routing** |
| 28 | +* 📊 **Monitoring with Prometheus & Grafana** |
| 29 | +* 🛢️ **PostgreSQL Database Integration** |
| 30 | +* ⚙️ **CI/CD via GitHub + GHCR** |
| 31 | +* 🔐 **Environment-based Configuration (.env)** |
| 32 | +* 📈 **Production Observability Setup** |
| 33 | + |
| 34 | +--- |
| 35 | + |
| 36 | +## 🧱 Tech Stack |
| 37 | + |
| 38 | +| Layer | Technology | |
| 39 | +| ---------- | -------------------- | |
| 40 | +| Backend | Spring Boot | |
| 41 | +| Database | PostgreSQL | |
| 42 | +| Container | Docker | |
| 43 | +| Proxy | NGINX | |
| 44 | +| Monitoring | Prometheus, Grafana | |
| 45 | +| CI/CD | GitHub Actions, GHCR | |
| 46 | +| Deployment | VPS (Linux) | |
| 47 | + |
| 48 | +--- |
| 49 | + |
| 50 | +## 🔁 Deployment Strategy (Blue-Green) |
| 51 | + |
| 52 | +This project implements a **blue-green deployment strategy** to ensure zero downtime. |
| 53 | + |
| 54 | +### Flow: |
| 55 | + |
| 56 | +1. New version is deployed to **inactive environment** (Green) |
| 57 | +2. Health checks are verified |
| 58 | +3. NGINX switches traffic: |
| 59 | + |
| 60 | + ``` |
| 61 | + Blue → Green |
| 62 | + ``` |
| 63 | +4. Old version remains as a fallback |
| 64 | + |
| 65 | +### Result: |
| 66 | + |
| 67 | +* ✅ Zero downtime |
| 68 | +* ✅ Instant rollback capability |
| 69 | +* ✅ Safe production deployments |
| 70 | + |
| 71 | +--- |
| 72 | + |
| 73 | +## 📊 Monitoring & Observability |
| 74 | + |
| 75 | +* **Prometheus** scrapes metrics from: |
| 76 | + |
| 77 | + ``` |
| 78 | + /actuator/prometheus |
| 79 | + ``` |
| 80 | +* **Grafana** visualizes: |
| 81 | + |
| 82 | + * CPU usage |
| 83 | + * Memory usage |
| 84 | + * Request metrics |
| 85 | + * Container health |
| 86 | + |
| 87 | +--- |
| 88 | + |
| 89 | +## 🐳 Docker Setup |
| 90 | + |
| 91 | +### Run with Docker Compose |
| 92 | + |
| 93 | +```bash |
| 94 | +docker-compose up -d |
| 95 | +``` |
| 96 | + |
| 97 | +### Services: |
| 98 | + |
| 99 | +* contact-api (blue/green) |
| 100 | +* postgres |
| 101 | +* prometheus |
| 102 | +* grafana |
| 103 | +* nginx |
| 104 | + |
| 105 | +--- |
| 106 | + |
| 107 | +## 🌐 API Endpoints |
| 108 | + |
| 109 | +| Method | Endpoint | Description | |
| 110 | +| ------ | -------------- | ----------------- | |
| 111 | +| GET | /contacts | Get all contacts | |
| 112 | +| POST | /contacts | Create contact | |
| 113 | +| GET | /contacts/{id} | Get contact by ID | |
| 114 | +| PUT | /contacts/{id} | Update contact | |
| 115 | +| DELETE | /contacts/{id} | Delete contact | |
| 116 | + |
| 117 | +--- |
| 118 | + |
| 119 | +## 🧪 Run Locally |
| 120 | + |
| 121 | +```bash |
| 122 | +git clone https://github.com/vimal-java-dev/vimaltech-contact-api |
| 123 | +cd vimaltech-contact-api |
| 124 | + |
| 125 | +docker-compose up --build |
| 126 | +``` |
| 127 | + |
| 128 | +--- |
| 129 | + |
| 130 | +## ☁️ Production Deployment |
| 131 | + |
| 132 | +### Steps: |
| 133 | + |
| 134 | +1. Push Docker image to GHCR |
| 135 | +2. Pull the image on the VPS |
| 136 | +3. Run `deploy.sh` |
| 137 | +4. Switch NGINX between blue/green |
| 138 | + |
| 139 | +--- |
| 140 | + |
| 141 | +## 🔐 Security Considerations |
| 142 | + |
| 143 | +* Environment variables via `.env` |
| 144 | +* NGINX as reverse proxy (no direct exposure) |
| 145 | +* Container isolation |
| 146 | +* Controlled port exposure |
| 147 | + |
| 148 | +--- |
| 149 | + |
| 150 | +## 📸 Screenshots (Add Here) |
| 151 | + |
| 152 | +> Add: |
| 153 | +
|
| 154 | +* Grafana dashboard |
| 155 | +* Prometheus targets |
| 156 | +* Docker containers |
| 157 | +* Blue-Green switch logs |
| 158 | + |
| 159 | +--- |
| 160 | + |
| 161 | +## 🎯 What This Project Demonstrates |
| 162 | + |
| 163 | +* Real-world backend system design |
| 164 | +* DevOps integration with backend development |
| 165 | +* Zero-downtime deployment strategy |
| 166 | +* Monitoring & observability setup |
| 167 | +* Production-ready architecture thinking |
4 | 168 |
|
5 | 169 | --- |
6 | 170 |
|
7 | | -## ⚙️ Detailed Architecture |
| 171 | +## 🌍 Live Demo |
| 172 | + |
| 173 | +👉 https://vimaltech.dev/ |
| 174 | + |
| 175 | +--- |
8 | 176 |
|
9 | | - |
| 177 | +## 👨💻 Author |
| 178 | + |
| 179 | +**Vimal Patel** |
| 180 | + |
| 181 | +Backend Developer | Spring Boot | DevOps Enthusiast |
| 182 | + |
| 183 | +--- |
0 commit comments