How sebastian-0912/ticket_backend works
Project Type & Purpose
• This is a distributed, containerized full-stack back-end system built with Flask and CockroachDB.
• It demonstrates a 3-node CockroachDB cluster, two Flask app instances behind Nginx, plus monitoring and an autoscaler.
Main Components
• Clients (API consumers, curl, browser)
• Nginx reverse proxy / load balancer
• Flask application (2 instances: flask_app1, flask_app2)
• CockroachDB cluster (3 nodes: crdb1, crdb2, crdb3)
• Monitoring stack: Prometheus + Grafana
• Autoscaler service
Relationships & Data Flows
• Clients → Nginx → Flask instances → CockroachDB cluster
• Prometheus scrapes metrics from Nginx, Flask apps, CockroachDB
• Grafana reads from Prometheus
• Autoscaler polls metrics & adjusts number of Flask containers
Architectural Patterns
• Load‐balanced stateless API layer (Flask behind Nginx)
• Distributed SQL data storage (CockroachDB replication)
• Infrastructure as code via Docker Compose
• Observability via Prometheus + Grafana
• Automatic scaling based on metrics
Simple ASCII Chart
[Clients]
|
v
+----------------+
| NGINX LB |
+----------------+
|
+-----+-----+
| |
v v
+-------+ +-------+
|Flask 1| |Flask 2|
+-------+ +-------+
| |
+-----+-----+
|
v
+---------------------+
| CockroachDB Cluster |
| +---+ +---+ +---+ |
| |N1 | |N2 | |N3 | |
| +---+ +---+ +---+ |
+---------------------+
|
v
+------------------+
| Docker Compose |
+------------------+
Side services:
• Prometheus ──scrapes──> NGINX, Flask 1/2, CRDB 1/2/3
• Grafana ──reads──────> Prometheus
• Autoscaler ──polls────> Prometheus & adjusts Flask replicas