Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

103 Commits

Folders and files

Repository files navigation

πŸ”§ CodeForge β€” Multi-Tier Coding Platform

A production-ready, DevSecOps-hardened coding platform built with React, Node.js/Express, PostgreSQL, and Redis β€” containerised with Docker, deployable on Kubernetes via Helm, and secured through a fully automated CI/CD pipeline.

Architecture Diagram


πŸ“‘ Table of Contents


🧭 Overview

CodeForge is a full-stack competitive coding platform where users can:

  • Browse and solve coding challenges through an in-browser Monaco editor
  • Submit code that is evaluated asynchronously via a Redis job queue
  • View real-time submission status through result polling
  • Track their scores and ranking on a live leaderboard

The project is designed as a DevSecOps reference implementation, demonstrating a complete journey from local Docker Compose to a production-grade Kubernetes cluster on Azure AKS, with security baked into every stage of the pipeline.


πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        CODEFORGE PLATFORM                        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚   TIER 1     β”‚    TIER 2     β”‚   TIER 3     β”‚      TIER 4        β”‚
β”‚  Frontend    β”‚  Backend API  β”‚  PostgreSQL  β”‚      Redis         β”‚
β”‚  React +     β”‚  Node.js +    β”‚  Database    β”‚  Cache + Job Queue β”‚
β”‚  Monaco +    β”‚  Express      β”‚              β”‚                    β”‚
β”‚  Nginx       β”‚               β”‚              β”‚                    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                       Code Execution Worker                      β”‚
β”‚                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Services

Service Technology Port Role
frontend React + Nginx 3000 Monaco editor UI, routing, JWT auth
backend Node.js + Express 5000 REST API, authentication, business logic
postgres PostgreSQL 15 5432 Users, challenges, submissions persistence
redis Redis 7 6379 Session cache, JWT blacklist, job queue
worker Node.js β€” Async code evaluation via Redis queue

πŸ› οΈ Tech Stack

Layer Technology
Frontend React, Monaco Editor, Axios, Nginx
Backend Node.js, Express, JWT, Winston
Database PostgreSQL 15
Cache / Queue Redis 7
Containerisation Docker, Docker Compose
Orchestration Kubernetes, Helm
Cloud Azure AKS (via Terraform)
CI/CD GitHub Actions
Security GitLeaks, Semgrep (SAST), Trivy, npm Dependency-audit
Observability Prometheus, Grafana, Alertmanager (kube-prometheus-stack)
GitOps Argo CD
Ingress NGINX Ingress
Gateway Api NGINX Gateway Fabric

πŸ“ Project Structure

codeforge/
β”œβ”€β”€ docker-compose.yml              # Local orchestration of all 5 services
β”‚
β”œβ”€β”€ frontend/                       # TIER 1 β€” React Application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ App.js                  # Router + auth wrapper
β”‚   β”‚   β”œβ”€β”€ api.js                  # Axios client with JWT interceptors
β”‚   β”‚   β”œβ”€β”€ context/
β”‚   β”‚   β”‚   └── AuthContext.js      # Global authentication state
β”‚   β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”‚   └── Navbar.js
β”‚   β”‚   └── pages/
β”‚   β”‚       β”œβ”€β”€ Home.js
β”‚   β”‚       β”œβ”€β”€ Challenges.js
β”‚   β”‚       β”œβ”€β”€ Editor.js           # Monaco editor + submission polling
β”‚   β”‚       β”œβ”€β”€ Login.js
β”‚   β”‚       β”œβ”€β”€ Register.js
β”‚   β”‚       └── Leaderboard.js
β”‚   β”œβ”€β”€ Dockerfile                  # Multi-stage: build β†’ Nginx serve
β”‚   β”œβ”€β”€ .env.example
β”‚   └── nginx.conf                  # Reverse proxy + security headers
β”‚
β”œβ”€β”€ backend/                        # TIER 2 β€” Express REST API
β”‚   β”œβ”€β”€ server.js                   # App bootstrap, middleware, routes
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ auth.js                 # Register, login, logout, /me
β”‚   β”‚   β”œβ”€β”€ challenges.js           # Challenge list + detail (Redis-cached)
β”‚   β”‚   β”œβ”€β”€ submissions.js          # Submit code, poll results
β”‚   β”‚   β”œβ”€β”€ users.js                # Leaderboard + profiles
β”‚   β”‚   └── health.js               # Health check endpoint
β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   └── auth.js                 # JWT verification + Redis blacklist
β”‚   β”œβ”€β”€ config/
β”‚   β”‚   β”œβ”€β”€ db.js                   # PostgreSQL connection pool
β”‚   β”‚   β”œβ”€β”€ redis.js                # Redis client + cache helpers
β”‚   β”‚   β”œβ”€β”€ logger.js               # Winston structured logging
β”‚   β”‚   └── init.sql                # DB schema + seed data
β”‚   β”œβ”€β”€ package.json
β”‚   └── Dockerfile                  # Multi-stage Node.js build
β”‚
β”œβ”€β”€ worker/                         # Code Execution Worker
β”‚   β”œβ”€β”€ worker.js                   # Redis BRPOP queue consumer
β”‚   β”œβ”€β”€ package.json
β”‚   └── Dockerfile
β”‚
β”œβ”€β”€ k8s/                            # Raw Kubernetes manifests
β”‚   β”œβ”€β”€ namespace.yaml
β”‚   β”œβ”€β”€ configmap.yaml
β”‚   β”œβ”€β”€ secrets.yaml
β”‚   β”œβ”€β”€ network-policies.yaml       # Default-deny + explicit allow rules
β”‚   β”œβ”€β”€ frontend.yaml
β”‚   β”œβ”€β”€ backend.yaml
β”‚   β”œβ”€β”€ worker.yaml
β”‚   β”œβ”€β”€ postgres.yaml
β”‚   β”œβ”€β”€ redis.yaml
β”‚   └── ingress.yaml
β”‚
β”œβ”€β”€ helm/                           # Helm chart for parameterised deployment
β”‚   └── codeforge/
β”‚       β”œβ”€β”€ Chart.yaml
β”‚       β”œβ”€β”€ values-dev.yaml         # Dev environment overrides
β”‚       β”œβ”€β”€ values-prod.yaml        # Production environment overrides
β”‚       └── templates/
β”‚           β”œβ”€β”€ frontend.yaml
β”‚           β”œβ”€β”€ backend.yaml
β”‚           β”œβ”€β”€ worker.yaml
β”‚           β”œβ”€β”€ postgres.yaml
β”‚           β”œβ”€β”€ redis.yaml
β”‚           β”œβ”€β”€ configmap.yaml
β”‚           β”œβ”€β”€ secrets.yaml
β”‚           β”œβ”€β”€ ingress.yaml
β”‚           └── network-policies.yaml
β”‚
β”œβ”€β”€ terraform/                      # Azure AKS cluster provisioning
β”‚   └── main.tf
β”‚
β”œβ”€β”€ automation/                     # Bootstrap & observability scripts
β”‚   β”œβ”€β”€ dev_automation.sh           # Installs Docker, kubectl, Minikube, Helm
β”‚   β”œβ”€β”€ obervability.sh             # Deploys Prometheus, Grafana, Argo CD
β”‚   β”œβ”€β”€ gateway.yaml                # NGINX Gateway Fabric HTTPRoute
β”‚   β”œβ”€β”€ ingress.yaml                # Ingress resource
β”‚   β”œβ”€β”€ obs_route.yaml              # Observability service routes
β”‚   └── values.yaml                 # Shared Helm values
β”‚
└── .github/
    └── workflows/
        └── ci_security.yaml        # Full CI/CD + security scanning pipeline

πŸš€ Quick Start

Prerequisites

  • Docker & Docker Compose
  • Node.js 20+ (local dev only)

Run with Docker (Recommended)

# 1. Clone the repository
git clone https://github.com/Yadav-SubratKumar/codeforge_devopsified.git
cd codeforge_devopsified

# 2. Copy environment variables
cp .env.example .env

# 3. Build and start all services
docker compose up --build

# 4. Open in browser
open http://localhost:3000

All five services (frontend, backend, postgres, redis, worker) will start with health checks and restart policies.


☸️ Kubernetes Deployment

Prerequisite: Dev Environment Setup

If you're running locally with Minikube, the automation script handles all tool installation:

chmod +x automation/dev_automation.sh
./automation/dev_automation.sh

# Apply docker group changes without logging out
newgrp docker

# Start Minikube
minikube start

This installs Docker, kubectl, Minikube, and Helm.


Option 1: Raw Kubernetes Manifests

# Create the namespace
kubectl apply -f k8s/namespace.yaml

# Apply all resources
kubectl apply -f k8s/

# Verify pods are running
kubectl get pods -n codeforge

Option 2: Helm Chart (Recommended)

The Helm chart supports parameterised deployments across environments.

# Deploy to dev
helm upgrade --install codeforge ./helm/codeforge \
  --namespace codeforge \
  --create-namespace \
  -f helm/codeforge/values-dev.yaml

# Deploy to production
helm upgrade --install codeforge ./helm/codeforge \
  --namespace codeforge \
  --create-namespace \
  -f helm/codeforge/values-prod.yaml

πŸ“Š Observability Stack

The observability script sets up a full monitoring and GitOps stack:

chmod +x automation/obervability.sh
./automation/obervability.sh

This deploys:

Tool Purpose Access
Prometheus Metrics collection NodePort (patched)
Grafana Dashboards & visualisation NodePort (patched)
Alertmanager Alerting NodePort (patched)
Argo CD GitOps continuous delivery NodePort
NGINX Gateway Kubernetes Gateway API ingress β€”

Retrieve credentials after deployment:

# Grafana admin password
kubectl get secret --namespace monitoring \
  -l app.kubernetes.io/component=admin-secret \
  -o jsonpath="{.items[0].data.admin-password}" | base64 --decode && echo

# Argo CD admin password
kubectl -n argocd get secret argocd-initial-admin-secret \
  -o jsonpath="{.data.password}" | base64 -d && echo

☁️ Infrastructure (Terraform β€” Azure AKS)

Provision an AKS cluster on Azure using the provided Terraform config:

cd terraform

# Authenticate with Azure
az login

# Initialise and apply
terraform init
terraform plan
terraform apply

What it provisions:

  • Resource group in East US
  • Virtual network (10.0.0.0/20) with a dedicated AKS subnet
  • AKS cluster with a single Standard_B2ms node (system-assigned identity)
  • Azure CNI networking

After provisioning, configure kubectl:

az aks get-credentials --resource-group james --name my-aks-cluster
kubectl get nodes

πŸ” CI/CD Pipeline

The GitHub Actions pipeline (.github/workflows/ci_security.yaml) triggers on every push and pull request to main / develop (excluding changes to infra-only paths like k8s/, helm/, terraform/).

Pipeline Stages

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Secret Scan   β”‚    β”‚  Backend Tests  β”‚    β”‚ Frontend Tests & β”‚
β”‚  (GitLeaks)    β”‚    β”‚  (Jest + pg +   β”‚    β”‚    Build         β”‚
β”‚                β”‚    β”‚   redis svc)    β”‚    β”‚                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                    β”‚                       β”‚
         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚  Dependency Audit (npm audit) β”‚
              β”‚  SAST (Semgrep β€” OWASP Top 10,β”‚
              β”‚  Node.js, JWT, Express rules) β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                              β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚  Build & Push Docker Images   β”‚
              β”‚  to Docker Hub                β”‚
              β”‚  (backend, frontend, worker)  β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                              β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚  Container Scan (Trivy)       β”‚
              β”‚  CRITICAL/HIGH CVEs β†’ fail    β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚
                              β–Ό
              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
              β”‚  Update Image Tags in         β”‚
              β”‚  k8s/ manifests & Helm values β”‚
              β”‚  β†’ Commit & Push (GitOps)     β”‚
              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Required GitHub Secrets & Variables

Key Type Description
DOCKERHUB_TOKEN Secret Docker Hub access token
DOCKERHUB_USERNAME Variable Docker Hub username

Security Tools Summary

Tool What it checks
GitLeaks Secrets and credentials accidentally committed to git
Semgrep SAST β€” OWASP Top 10, JWT misuse, Express vulnerabilities
npm audit Known CVEs in backend, frontend, and worker dependencies
Trivy Container image vulnerabilities (CRITICAL & HIGH severity)

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/your-feature
  3. Make your changes and commit: git commit -m "feat: describe your change"
  4. Push to your fork: git push origin feature/your-feature
  5. Open a Pull Request against main

The CI pipeline will automatically run all security scans and tests on your PR.


πŸ“„ License

This project is open source. See LICENSE for details.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages