How adeelarshad414/devops-interns-proj works
Purpose and Entry Points
Daig is a deliberately breakable food-delivery platform used to teach Cloud, DevOps, SRE, DevSecOps, and platform engineering through real failures. Local operation begins through Makefile, principally Compose-based stack startup, seeding, smoke checks, observability overlays, load, and chaos exercises. The application entry tier is the static nginx SPA in services/web/nginx.conf; service bootstraps are services/orders/src/index.js, services/kitchen/src/index.js, and services/dispatch/src/index.js.
Three-Tier Request Path
The browser calls web, which proxies order API traffic to orders; orders persists the initial order before invoking kitchen; kitchen accepts/rejects and invokes dispatch for rider assignment. All application services are Node.js services, while the frontend has no build stage.
• Presentation: services/web/nginx.conf, services/web/public/app.js
• Application: services/orders/src/server.js, services/kitchen/src/server.js, services/dispatch/src/server.js
• Local topology: docker-compose.yml
The committed-before-downstream boundary means an order remains durable if kitchen or dispatch fails.
Data and State Boundary
PostgreSQL is the system of record for orders, events, menu/reference data, riders, and assignments; Redis is used by orders as a cache. Schema design enforces order lifecycle constraints and append-only event history, with additive migrations.
• Schema and seed data: db/init/001_schema.sql, db/init/002_seed_reference.sql
• Shared database access/timing: services/_shared/db.js
• Cache consumer: services/orders/src/server.js
State progresses from placement through acceptance/rejection, kitchen stages, assignment, and delivery/cancellation. Intentional missing indexes and dispatch N+1 behavior create diagnosable latency exercises.
Cross-Cutting Runtime Contracts
Shared modules establish common service behavior: telemetry initializes before server startup, JSON logs carry trace context, metrics are exposed for Prometheus, database access is timed, and shutdown/config guards standardize failure behavior.
• Core contracts: services/_shared/telemetry.js, services/_shared/logger.js, services/_shared/metrics.js
• Credential fail-closed logic: services/_shared/secrets.js, services/_shared/guard.js
• Deliberately insecure teaching surface: services/orders/src/insecure.js
Production-oriented secret resolution uses OpenBao AppRole and optionally dynamic database credentials. If required vault access fails in production, services exit rather than silently use environment secrets.
Observability and Incident Analysis
Services emit OTLP traces, Prometheus metrics, structured stdout logs, and profiles. The OpenTelemetry Collector is the vendor boundary; Grafana correlates metrics, traces, logs, and profiles to support incident diagnosis.
• Telemetry routing: observability/otel-collector.yaml
• Metrics/SLO alerts: observability/prometheus.yml, observability/rules/slo.yml
• Grafana correlations: observability/grafana/provisioning/datasources/datasources.yaml
The Python incident copilot consumes collected signals to rank root-cause hypotheses, with fixture-driven evaluation. ai/incident-copilot/copilot.py, ai/incident-copilot/collectors.py, and ai/incident-copilot/evals/run_evals.py form that optional AIOps subsystem.
Deployment, Infrastructure, and Policy Boundaries
Compose is the primary local runtime, augmented by isolated observability, vault, security, and egress overlays. The same application has Swarm and Kubernetes deployment paths; Kubernetes adds HPA, ingress, NetworkPolicy, secrets, scheduled scaling, and chaos manifests.
• Container/orchestration definitions: docker-compose.yml, k8s/base/kustomization.yaml, swarm/daig-stack.yml
• Kubernetes isolation/scaling: k8s/base/networkpolicy.yaml, k8s/base/hpa.yaml
• Secrets platform: vault/bootstrap.sh, vault/config/config.hcl
Terraform provides parallel cloud targets: AWS ECS/Fargate, RDS, ALB, ECR; GCP Cloud Run/Cloud SQL; and Azure Container Apps/Flexible Server. Ansible is an alternate host-configuration path.
Teaching, Failure Injection, and Delivery Gates
Chaos scripts inject controlled faults; challenge definitions pair failures with a live-system grader supporting file, shell, HTTP, and Prometheus checks. Deliberate defects are retained as curriculum, not bugs to casually remediate.
• Exercises and scoring: chaos/day4-latency.sh, challenges/fix-dispatch-latency.yml, grader/grader.py
• Security/policy gates: security/policy/kubernetes.rego, security/kyverno/policies.yaml
• CI/CD orchestration: .github/workflows/ci.yml, .github/workflows/cd.yml, .github/workflows/devsecops.yml
GitHub Actions builds and integration-tests the full stack, then layers secret scanning, SAST/SCA, IaC policy, image/SBOM/signing, and DAST. Some security findings are intentional and represent successful detector operation.
Main entry points: docker-compose.yml Compose topology · src/server.js Orders service · src/server.js Kitchen service · otel-collector.yaml OTel Collector
Components 21
Application Runtime
- Local workflow · Starts stacks and runs smoke, load, and chaos exercises.
Makefile - Compose topology
docker-compose.yml - Web SPA + proxy · Serves the unbuilt SPA and proxies order API traffic.
services/web/nginx.conf - Orders service · Commits orders before calling downstream services.
services/orders/src/server.js - Kitchen service
services/kitchen/src/server.js - Dispatch service · Assigns riders; intentionally contains an N+1 exercise.
services/dispatch/src/server.js
State & Secrets
- PostgreSQL · Stores orders, events, reference data, riders, and assignments.
db/init/001_schema.sql - Redis cache
services/orders/src/server.js - Shared runtime contracts · Standardizes telemetry, logs, metrics, timed DB access, shutdown, and guards.
services/_shared/telemetry.js - OpenBao secrets · Production services fail closed when required vault access fails.
vault/config/config.hcl
Observability
- OTel Collector
observability/otel-collector.yaml - Prometheus + SLOs
observability/prometheus.yml - Grafana · Correlates metrics, traces, logs, and profiles for incidents.
observability/grafana/provisioning/datasources/datasources.yaml - Incident copilot · Ranks root-cause hypotheses from collected signals.
ai/incident-copilot/copilot.py
Deployment Targets
- Kubernetes path · Adds ingress, HPA, NetworkPolicy, secrets, scaling, and chaos manifests.
k8s/base/kustomization.yaml - Swarm path
swarm/daig-stack.yml - Cloud infrastructure · Provisions parallel AWS, GCP, and Azure application platforms.
Teaching & Delivery
- Chaos exercises · Injects controlled failures into the live stack.
chaos/day4-latency.sh - Challenges + grader · Pairs failures with file, shell, HTTP, and Prometheus checks.
grader/grader.py - CI/CD and DevSecOps · Builds, tests, scans, signs, and deploys the stack.
.github/workflows/ci.yml - Policy gates · Applies Kubernetes admission and IaC policy checks.
security/policy/kubernetes.rego
Connections 29
- Local workflow → Compose topology: starts
- Compose topology → Web SPA + proxy: runs
- Compose topology → Orders service: runs
- Compose topology → Kitchen service: runs
- Compose topology → Dispatch service: runs
- Web SPA + proxy → Orders service: proxies order API
- Orders service → PostgreSQL: commits order
- Orders service → Redis cache: reads/writes cache
- Orders service → Kitchen service: submits after commit
- Kitchen service → Dispatch service: requests rider assignment
- Kitchen service → PostgreSQL: updates lifecycle
- Dispatch service → PostgreSQL: stores assignment
- Shared runtime contracts → PostgreSQL: timed database access
- OpenBao secrets → Shared runtime contracts: AppRole and dynamic credentials
- Orders service → OTel Collector: OTLP traces
- Kitchen service → OTel Collector: OTLP traces
- Dispatch service → OTel Collector: OTLP traces
- OTel Collector → Prometheus + SLOs: routes metrics
- Prometheus + SLOs → Grafana: metrics and alerts
- OTel Collector → Grafana: traces, logs, profiles
- Grafana → Incident copilot: incident signals
- Kubernetes path → Compose topology: alternative deployment topology
- Swarm path → Compose topology: alternative deployment topology
- Cloud infrastructure → Kubernetes path: provisions cloud platforms
- Chaos exercises → Compose topology: injects faults
- Challenges + grader → Chaos exercises: grades exercises
- CI/CD and DevSecOps → Compose topology: integration tests
- CI/CD and DevSecOps → Policy gates: enforces
- CI/CD and DevSecOps → Kubernetes path: deploys