Infrastructure reliability demo · NestJS · PostgreSQL · Docker
Built by Altura Codeworks as a backend showcase.
A minimal backend service that simulates API uptime monitoring — the kind of tool you’d run beside gateways and microservices in production.
It registers APIs, performs scheduled health checks, logs their response times, and produces an uptime summary report — all documented via Swagger UI.
Designed as a backend / DevOps engineering demo, it focuses on system reliability patterns rather than UI features.
| Layer | Technology | Purpose |
|---|---|---|
| Framework | NestJS 10+ | Structured, modular Node.js backend |
| Database | PostgreSQL 16 + TypeORM | Entities, repositories, logging |
| Scheduling | @nestjs/schedule (cron) | Background health checks |
| HTTP client | Axios via @nestjs/axios | Fast HEAD probes |
| Documentation | Swagger / OpenAPI | REST interface with linked hints |
| Containerization | Docker + docker-compose | Single-command spin-up |
src/
├─ config/ → env + TypeORM config
├─ services/ → service registry (CRUD)
│ ├─ service.entity.ts
│ ├─ services.service.ts
│ └─ services.controller.ts
├─ monitoring/ → health checks, logs, uptime summary
│ ├─ log.entity.ts
│ ├─ monitoring.service.ts
│ └─ monitoring.controller.ts
└─ app.module.ts
**Core entities**
| Table | Fields (main) |
|-------|----------------|
| `services` | id · name · baseUrl · isActive · lastCheckedAt · lastStatus |
| `check_logs` | id · serviceId · checkedAt · responseTimeMs · status · errorMessage |
✅ Register APIs to monitor
✅ Manual and automated pings (@Cron(EVERY_MINUTE))
✅ Store historical response logs
✅ Aggregate uptime % for last 24h
✅ Configurable per-service check interval
✅ Dockerized Postgres environment + seed data
✅ Swagger UI with discoverable documentation
PORT=3000
DB_HOST=db
DB_PORT=5432
DB_USER=postgres
DB_PASS=postgres
DB_NAME=api_monitor2️⃣ Launch docker compose up --build
API → http://localhost:3000
Swagger UI → http://localhost:3000/docs
3️⃣ Seed demo data psql -h localhost -U postgres -d api_monitor -f seed.sql
You’ll immediately see populated uptime stats under /monitoring/summary.
The /monitoring/summary endpoint lists uptime, latency, and health status for each monitored API.
| Method | Path | Description |
|---|---|---|
GET |
/services |
List registered APIs 🛈 See /monitoring/summary for uptime overview |
POST |
/services |
Register a new service |
POST |
/monitoring/ping/:id |
Manually trigger a health check |
GET |
/monitoring/summary |
Aggregated uptime & latency stats (last 24 h) |
[
{
"serviceId": 1,
"name": "Billing API",
"baseUrl": "https://api.stripe.com/v1/charges",
"lastStatus": "OK",
"lastResponseTimeMs": 152,
"lastCheckedAt": "2025-11-10T10:30:00Z",
"checksLast24h": 3,
"uptimePercentLast24h": 100.0
},
{
"serviceId": 2,
"name": "CRM Backend",
"baseUrl": "https://crm.alturacodeworks.com/api/health",
"lastStatus": "DOWN",
"lastResponseTimeMs": 982,
"lastCheckedAt": "2025-11-10T10:27:00Z",
"checksLast24h": 3,
"uptimePercentLast24h": 33.3
}
]🧠 Implementation Highlights
Ping logic — performs HEAD requests with 5-second timeout
Health heuristic — treats status < 500 (except 404) as reachable
Interval logic — honors each service’s checkIntervalMinutes
Fault tolerance — per-service try/catch to avoid cron cascade failures
Aggregation — simple in-memory uptime calculation for demo clarity
🧭 Future Ideas
JWT authentication for restricted endpoints
Configurable schedulers (RabbitMQ / BullMQ)
WebSocket push of latest health status
Lightweight Angular/React dashboard consuming /monitoring/summary
Export to Prometheus / Grafana integration
🪶 Credits
Built by Yuriy Mykhalchuk · Founder of Altura Codeworks
A demonstration of calm architecture, reliable systems, and measurable uptime.
© 2025 Altura Codeworks · github.com/ymykhal · Upwork Agency


