How muthukamalan/voting_app works
Purpose and deployment entry points
This is a distributed voting application demonstrating asynchronous vote processing, persistent aggregation, and production-style observability. Run locally through compose.yaml or deploy the complete service set recursively from k8s/manifests/. Application containers are built from vote/Dockerfile, worker/Dockerfile, and result/Dockerfile.
Vote submission service
The Python/Flask voting UI accepts a browser’s choice between two options and enforces one effective vote per client browser. Its primary application entry point is vote/app.py, with the rendered page in vote/templates/index.html. The service deployment boundary is defined by k8s/manifests/vote/vote.deploy.yml and its service/secret manifests.
Asynchronous processing boundary
Votes cross from the synchronous Flask request path into RabbitMQ, decoupling user-facing submission from database persistence. The Celery worker consumes queued messages, uses Redis as its task result/state backend, and writes vote records to PostgreSQL. Core worker implementation and deployment are worker/worker.py, worker/requirements.txt, and k8s/manifests/worker/worker.deploy.yml; broker infrastructure is under k8s/manifests/amqp/.
Persistent results and read model
PostgreSQL is the durable source of vote data. Initialization is supplied by postgres/init.sql; Kubernetes provisions configuration, credentials, a persistent volume claim, and service through k8s/manifests/postgres/postgres.deploy.yml, k8s/manifests/postgres/postgres.pvc.yml, and k8s/manifests/postgres/postgres.config.init.yml. The Node.js results service reads this database and presents live totals, polling every two seconds; its runtime entry points are result/server.js and result/tracing.js, deployed via k8s/manifests/result/result.deploy.yml.
Runtime topology
The system spans Python for vote intake and background processing, Node.js for results delivery, RabbitMQ for transport, Redis for Celery state, and PostgreSQL for durable data. Service discovery and exposure are represented by paired deployment/service manifests, especially k8s/manifests/redis/redis.deploy.yml, k8s/manifests/amqp/amqp.deploy.yml, and k8s/manifests/result/result.service.yml. Docker Compose is the local multi-container topology; Kubernetes manifests are the cluster topology.
Metrics and operational inspection
Prometheus collects metrics from Redis and PostgreSQL exporters and feeds Grafana dashboards. The architecture-defining manifests are k8s/manifests/prometheus/prometheus.config.yml, prometheus/prometheus.yml, k8s/manifests/grafana/grafana.deploy.yml, k8s/manifests/redis.exporter/redis.exporter.deploy.yml, and k8s/manifests/postgres.exporter/postgres.export.deploy.yml. Flower provides Celery task/worker monitoring, while RedisInsight exposes Redis inspection: k8s/manifests/flower/flower.deploy.yml and k8s/manifests/redisinsights/redisinsights.deploy.yml.
Distributed tracing
Application traces are collected by OpenTelemetry and visualized in Jaeger. The collector’s concrete configuration is otel/otel-collector-config.yaml, while cluster deployment/configuration lives at k8s/manifests/otel/otel.deploy.yml, k8s/manifests/otel/otel.config.yml, and k8s/manifests/jager/jager.deploy.yml. result/tracing.js indicates explicit tracing integration in the results service.
Main entry points: vote.deploy.yml Cluster topology · worker.py Celery worker · app.py Vote Flask service · postgres.deploy.yml PostgreSQL
Components 21
Application services
- Voter browser
- Vote Flask service · Accepts choices and enforces one effective browser vote.
vote/app.py - Voting page
vote/templates/index.html - Celery worker · Consumes votes and persists vote records.
worker/worker.py - Results service · Polls vote totals every two seconds.
result/server.js - Results tracing
result/tracing.js
Messaging and data
- RabbitMQ · Decouples vote submission from persistence.
k8s/manifests/amqp/amqp.deploy.yml - Redis
k8s/manifests/redis/redis.deploy.yml - PostgreSQL · Durable source of vote data.
k8s/manifests/postgres/postgres.deploy.yml - Database initialization
postgres/init.sql
Observability
- Prometheus
k8s/manifests/prometheus/prometheus.config.yml - Redis exporter
k8s/manifests/redis.exporter/redis.exporter.deploy.yml - PostgreSQL exporter
k8s/manifests/postgres.exporter/postgres.export.deploy.yml - Grafana
k8s/manifests/grafana/grafana.deploy.yml - Flower
k8s/manifests/flower/flower.deploy.yml - RedisInsight
k8s/manifests/redisinsights/redisinsights.deploy.yml - OpenTelemetry Collector
otel/otel-collector-config.yaml - Jaeger
k8s/manifests/jager/jager.deploy.yml
Deployment topology
- Results exposure
k8s/manifests/result/result.service.yml - Local topology · Runs the local multi-container stack.
compose.yaml - Cluster topology · Deployment manifests define the cluster service set.
k8s/manifests/vote/vote.deploy.yml
Connections 28
- Voter browser → Vote Flask service: submits vote
- Vote Flask service → Voting page: renders
- Vote Flask service → RabbitMQ: queues vote
- RabbitMQ → Celery worker: delivers task
- Celery worker → Redis: stores task state
- Celery worker → PostgreSQL: writes vote
- Database initialization → PostgreSQL: initializes schema
- Results service → PostgreSQL: polls totals
- Voter browser → Results exposure: views results
- Results exposure → Results service: routes traffic
- Results tracing → OpenTelemetry Collector: emits traces
- OpenTelemetry Collector → Jaeger: exports traces
- Redis → Redis exporter: metrics
- PostgreSQL → PostgreSQL exporter: metrics
- Redis exporter → Prometheus: scraped by
- PostgreSQL exporter → Prometheus: scraped by
- Prometheus → Grafana: dashboard data
- Flower → Celery worker: monitors tasks
- RedisInsight → Redis: inspects
- Local topology → Vote Flask service: runs locally
- Local topology → Celery worker: runs locally
- Local topology → Results service: runs locally
- Cluster topology → Vote Flask service: deploys
- Cluster topology → Celery worker: deploys
- Cluster topology → Results service: deploys
- Cluster topology → RabbitMQ: deploys
- Cluster topology → Redis: deploys
- Cluster topology → PostgreSQL: deploys