Skip to content

zainasr/platform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Platform Services - Application Repository

CI Status Container Registry GitOps

Production-grade microservices platform implementing cloud-native best practices with GitOps-driven deployments

This repository contains the application source code and container build pipelines for a distributed microservices platform designed for Kubernetes. It follows the GitOps paradigm by separating application code (this repo) from infrastructure configuration (platform-ops).


πŸ“‹ Table of Contents


πŸ—οΈ Architecture Overview

This platform implements a polyglot microservices architecture with the following characteristics:

  • Multi-language services: Go, Node.js, and Python
  • Cloud-native design: 12-factor app principles
  • GitOps-driven deployments: Declarative infrastructure with Argo CD
  • Immutable infrastructure: Container images tagged with Git SHA
  • Observability-first: Prometheus metrics and Grafana dashboards
  • Security hardened: Non-root containers, read-only filesystems, minimal attack surface

Service Communication

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Ingress   β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
       β”‚
   β”Œβ”€β”€β”€β–Όβ”€β”€β”€β”€β”
   β”‚api-nodeβ”‚ (Node.js - API Gateway)
   β””β”€β”€β”€β”¬β”€β”€β”€β”€β”˜
       β”‚
   β”Œβ”€β”€β”€β–Όβ”€β”€β”€β”€β”
   β”‚core-go β”‚ (Go - Core Business Logic)
   β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚worker-python β”‚ (Python - Background Jobs)
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🧱 Microservices

1. api-node - API Gateway & Orchestration Layer

Language: Node.js (Express.js)
Port: 3000
Responsibility:

  • REST API gateway
  • Request routing and orchestration
  • Authentication/Authorization middleware
  • Rate limiting and request validation

Health Endpoints:

  • GET /health - Liveness probe
  • GET /ready - Readiness probe
  • GET /metrics - Prometheus metrics

Technology Stack:

  • Express.js
  • Prometheus client
  • Winston logger

2. core-go - Core Backend Service

Language: Go
Port: 8080
Responsibility:

  • Core business logic
  • Data processing and validation
  • Domain service layer
  • Database operations

Health Endpoints:

  • GET /health - Health check
  • GET /metrics - Prometheus metrics (promhttp)

Technology Stack:

  • Go 1.21+
  • Gorilla Mux / Chi router
  • Prometheus Go client
  • GORM (if using database)

3. worker-python - Background Worker

Language: Python
Port: 8000
Responsibility:

  • Scheduled background jobs (cron-like)
  • Asynchronous task processing
  • Data aggregation and reporting
  • Batch operations

Health Endpoints:

  • GET /health - Worker health status
  • GET /metrics - Prometheus metrics

Technology Stack:

  • Python 3.11+
  • FastAPI / Flask
  • APScheduler or Celery
  • Prometheus Python client

πŸ”’ Container Security

All services implement defense-in-depth security with the following best practices:

Multi-Stage Docker Builds

Each Dockerfile uses multi-stage builds to:

  • Separate build dependencies from runtime
  • Minimize final image size
  • Reduce attack surface

Security Hardening

Security Controls:
  βœ“ Non-root user (UID: 65532)
  βœ“ Read-only root filesystem
  βœ“ No shell in production images
  βœ“ Distroless/minimal base images
  βœ“ Capability dropping
  βœ“ securityContext enforcement

Base Images

Service Base Image Final Size
api-node node:21-alpine ~150MB
core-go gcr.io/distroless/static ~15MB
worker-python python:3.11-slim ~120MB

Vulnerability Scanning

  • Trivy: Integrated in CI pipeline
  • Snyk: Optional third-party scanning
  • GHCR: Native vulnerability scanning

πŸ”„ CI/CD Pipeline

CI Responsibilities (This Repository)

This repository implements Continuous Integration using GitHub Actions:

Build Pipeline (.github/workflows/build.yml)

Triggers:
  - Push to main branch
  - Pull request to main
  - Manual workflow dispatch

Steps:
  1. Checkout code
  2. Run tests and linters
  3. Build Docker images (multi-arch)
  4. Tag with Git SHA
  5. Push to GHCR
  6. Update image tag in platform-ops
  7. Create Git commit
  8. Push to platform-ops repository

Image Tagging Strategy

# Format: service-name:git-sha
ghcr.io/<org>/api-node:a1b2c3d
ghcr.io/<org>/core-go:a1b2c3d
ghcr.io/<org>/worker-python:a1b2c3d

# Additional tags
ghcr.io/<org>/api-node:latest
ghcr.io/<org>/api-node:v1.2.3  # Semantic versioning

CD Responsibilities (platform-ops Repository)

Continuous Deployment is handled by Argo CD in the platform-ops repository.

⚠️ Important: This repository does not deploy to Kubernetes. All deployments are GitOps-driven.


πŸš€ Deployment Flow

GitOps Workflow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Developer   β”‚
β”‚ commits code β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  GitHub Actions  β”‚
β”‚  (CI Pipeline)   β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β”œβ”€β–Ί Build Docker images
       β”œβ”€β–Ί Tag with Git SHA
       β”œβ”€β–Ί Push to GHCR
       β”‚
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Update Tag in   β”‚
β”‚  platform-ops    β”‚
β”‚  values.yaml     β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚    Argo CD       β”‚
β”‚  Auto-Sync       β”‚
β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
       β”‚
       β”œβ”€β–Ί Render Helm charts
       β”œβ”€β–Ί Apply manifests
       β”œβ”€β–Ί Deploy to K8s
       β”‚
       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Kubernetes      β”‚
β”‚  Cluster         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Rollback Strategy

# Rollback is just a Git revert
cd platform-ops
git revert HEAD
git push origin main

# Argo CD automatically deploys previous version

πŸ’» Local Development

Prerequisites

  • Docker (v24+)
  • Docker Compose (v2+)
  • Go (v1.21+)
  • Node.js (v20+)
  • Python (v3.11+)

Running Services Locally

Using Docker Compose

# Start all services
docker-compose up --build

# Start specific service
docker-compose up api-node

# View logs
docker-compose logs -f core-go

# Stop all services
docker-compose down

Native Development

# API Node
cd api-node
npm install
npm run dev

# Core Go
cd core-go
go mod download
go run main.go

# Worker Python
cd worker-python
python -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python main.py

Running Tests

# API Node
cd api-node
npm test
npm run test:coverage

# Core Go
cd core-go
go test ./... -v
go test -cover ./...

# Worker Python
cd worker-python
pytest
pytest --cov

βœ… Best Practices

Code Quality

  • Linting: ESLint (Node.js), golangci-lint (Go), Ruff (Python)
  • Formatting: Prettier, gofmt, Black
  • Testing: Jest, Go testing, pytest
  • Coverage: Minimum 80% code coverage

Container Best Practices

  1. Use specific base image tags (not latest)
  2. Implement health checks in all services
  3. Use multi-stage builds to minimize image size
  4. Run as non-root user (security)
  5. Set resource limits in Kubernetes
  6. Implement graceful shutdown for SIGTERM
  7. Use .dockerignore to exclude unnecessary files

Kubernetes Best Practices

  1. Resource requests and limits
  2. Liveness and readiness probes
  3. Pod disruption budgets
  4. Horizontal Pod Autoscaling (HPA)
  5. Network policies
  6. Service mesh (optional: Istio/Linkerd)

Monitoring & Observability

  • Metrics: Prometheus format (/metrics endpoint)
  • Logging: Structured JSON logs
  • Tracing: OpenTelemetry (optional)
  • Dashboards: Grafana

πŸ”— Related Resources


πŸ“š Additional Documentation


πŸ“„ License

MIT License - See LICENSE file for details


Built with ❀️ using cloud-native best practices

About

Production-grade polyglot microservices platform (Go, Node.js, Python) with GitOps CI/CD, containerized workloads, and Kubernetes-native architecture.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors