Skip to content

neilchauhan2/microservice-app-server

Repository files navigation

Microservice Polling Application

A production-ready, cloud-native polling application demonstrating modern DevOps practices, microservices architecture, and full-stack development skills.

Frontend Repo Backend Repo


🎯 Project Overview

This project showcases a full-stack polling application built with a microservices architecture and deployed to Azure Kubernetes Service (AKS). It demonstrates proficiency in modern software development, containerization, orchestration, and CI/CD practices.

What makes this project special:

  • βœ… Production-grade microservices architecture
  • βœ… Automated CI/CD pipelines with GitHub Actions
  • βœ… Kubernetes orchestration on Azure AKS
  • βœ… GitOps workflow with ArgoCD
  • βœ… Container registry management with Docker Hub

πŸ—οΈ Architecture

System Architecture

The application follows a microservices pattern with clear separation of concerns:

frontend-ci-cd

Frontend CI/CD Flow

backend-ci-cd

Backend CI/CD Flow

Components

Frontend Service

  • React-based SPA
  • Deployed to Vercel for edge optimization
  • Communicates with backend via API gateway

Backend Services

  1. Polling Service (Port 8000)

    • Manages polls and nominations
    • Handles voting logic
    • Real-time vote counting
  2. User Service (Port 8001)

    • User authentication & authorization
    • JWT-based session management
    • Secure password hashing with bcrypt

Infrastructure Components

  • Nginx API Gateway: Routes requests to appropriate microservices
  • MongoDB: Persistent data storage with StatefulSet
  • Docker Hub: Container image registry
  • Azure AKS: Kubernetes cluster for orchestration
  • ArgoCD: GitOps continuous delivery tool

Network Architecture

                   Internet β†’ Nginx API Gateway (80)
                                    ↓
                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                    ↓                               ↓
            Polling Service (8000)          User Service (8001)
                    ↓                               ↓
                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    ↓
                              MongoDB (27017)

πŸ› οΈ Tech Stack

Frontend

  • React - UI library
  • React Router - Client-side routing
  • Axios - HTTP client
  • Bulma CSS - Responsive styling
  • Chart.js - Data visualization
  • Vite - Build tool and dev server
  • Vitest - Unit testing

Backend

  • Node.js - Runtime environment
  • Express.js - Web framework
  • MongoDB - NoSQL database
  • Mongoose - ODM for MongoDB
  • JWT - Authentication tokens
  • Bcrypt - Password hashing
  • Jest/Supertest - Testing framework

DevOps & Infrastructure

  • Docker - Containerization
  • Docker Compose - Local orchestration
  • Kubernetes - Production orchestration
  • Azure AKS - Managed Kubernetes service
  • ArgoCD - GitOps CD tool
  • GitHub Actions - CI/CD automation
  • Nginx - Reverse proxy & load balancer
  • Docker Hub - Container registry

✨ Key Features

User Features

  • βœ… User registration and authentication
  • βœ… Create custom polls
  • βœ… Add multiple nominations to polls
  • βœ… Real-time voting with instant updates
  • βœ… Visual vote results with charts
  • βœ… Responsive design for all devices

Technical Features

  • βœ… Stateless microservices for horizontal scaling
  • βœ… JWT-based authentication
  • βœ… RESTful API design
  • βœ… Database connection pooling
  • βœ… Health checks and readiness probes
  • βœ… Graceful shutdown handling
  • βœ… CORS-enabled API

πŸš€ DevOps Implementation

Containerization Strategy

Each microservice is containerized with optimized Docker images:

Multi-stage builds for reduced image size:

FROM node:22-slim
WORKDIR /src
COPY package*.json ./
RUN npm ci --only=production
COPY . .
EXPOSE 8000
CMD ["npm", "start"]

Image optimization results:

  • Production-only dependencies
  • Minimal base images (node:22-slim)
  • Layer caching for faster builds

Kubernetes Deployment

argo-cd-apps

ArgoCD Application Management Interface

argocd-deployment-flow

Detailed view of Kubernetes deployments, services, and pods with ArgoCD

Deployment Strategy:

  • Rolling updates with zero downtime
  • Resource limits and requests defined
  • Liveness and readiness probes configured
  • ConfigMaps for environment-specific config
  • Secrets for sensitive data
  • Persistent volumes for database

Sample Kubernetes Configuration:

resources:
  requests:
    cpu: "100m"
    memory: "128Mi"
  limits:
    cpu: "250m"
    memory: "256Mi"

readinessProbe:
  httpGet:
    path: /api/polling/hello
    port: 8000
  initialDelaySeconds: 15
  periodSeconds: 10

GitOps with ArgoCD

  • Declarative infrastructure management
  • Automatic sync from Git repository
  • Visual deployment tracking
  • Rollback capabilities
  • Health status monitoring
argocd-deployment-flow

Application showing "Healthy" and "Synced" status in production


πŸ’» Local Development

Prerequisites

  • Node.js 22+
  • Docker & Docker Compose
  • Git

Quick Start

  1. Clone the repositories:
# Backend
git clone https://github.com/yourusername/microservice-app-server.git
cd microservice-app-server

# Frontend (separate terminal)
git clone https://github.com/yourusername/microservice-app-client.git
cd microservice-app-client
  1. Set up environment variables:
# In backend directory
cp .env.example .env
# Edit .env with your configuration
  1. Start services with Docker Compose:
docker-compose up -d
  1. Access the application:

Development Commands

# View logs
docker-compose logs -f

# Restart a service
docker-compose restart polling-service

# Stop all services
docker-compose down

# Remove all data
docker-compose down -v

Testing

# Run backend tests
npm test

# Run frontend tests
cd microservice-app-client
npm test

# Run with coverage
npm test -- --coverage

🌐 Production Deployment

Azure AKS Setup

aks cluster

Azure Kubernetes Service cluster configuration details

Cluster Specifications:

  • Kubernetes Version: 1.32.7
  • Region: East Asia
  • Node Pool: 1 node (scalable)
  • Network: Azure CNI Overlay
  • Load Balancer: Standard SKU

Deployment Process

  1. Build Docker images (automated via GitHub Actions)
  2. Push to Docker Hub with version tags
  3. Update Kubernetes manifests with new image tags
  4. ArgoCD detects changes and syncs cluster state
  5. Rolling update deploys new version

Kubernetes Services

kubectl-get-svc

List of Kubernetes services

kubectl-get-pods

All pods in Running state with restart counts and ages*

Service Endpoints:

  • Nginx LoadBalancer: External access point
  • Polling Service: Internal ClusterIP
  • User Service: Internal ClusterIP
  • MongoDB: Internal ClusterIP with StatefulSet

Database Strategy

MongoDB StatefulSet:

  • Persistent Volume Claims for data retention
  • Automatic pod rescheduling on node failure
  • Init scripts for schema setup
  • Secrets management for credentials

πŸ”„ CI/CD Pipeline

GitHub Actions Workflows

1. Polling Service Pipeline

Screenshot 2025-10-27 at 1 48 09β€―PM
Trigger β†’ Test β†’ Build Docker Image β†’ Push to Registry β†’ Update K8s Manifests

2. User Service Pipeline

Screenshot 2025-10-27 at 1 48 43β€―PM
Trigger β†’ Test β†’ Build Docker Image β†’ Push to Registry β†’ Wait for Polling* β†’ Update K8s Manifests

*Implements concurrency control to prevent manifest conflicts

3. Frontend Pipeline

Screenshot 2025-10-27 at 2 30 14β€―PM
Trigger β†’ Test β†’ Build β†’ Deploy to Vercel

Key Pipeline Features

  • βœ… Automated Testing: All tests must pass before deployment
  • βœ… Docker Layer Caching: Faster builds with GitHub Actions cache
  • βœ… Semantic Versioning: Images tagged with build numbers
  • βœ… Concurrency Control: Prevents race conditions in manifest updates
  • βœ… Automatic Rollback: Failed deployments trigger alerts
  • βœ… Environment Separation: Different configs for dev/staging/prod

Workflow Synchronization

To handle concurrent updates, the User Service workflow includes:

  • Detection of running Polling Service CI
  • Wait mechanism (up to 10 minutes)
  • Sequential manifest updates
  • Conflict prevention

πŸ“š Lessons Learned

Technical Insights

  1. Microservices Complexity

    • Managing inter-service communication requires careful planning
    • Service discovery and health checks are critical
    • Distributed logging becomes essential at scale
  2. CI/CD Challenges

    • Concurrent pipeline runs need synchronization
    • Manifest updates require careful version control
    • Testing in production-like environments is crucial
  3. Kubernetes Operations

    • Proper resource limits prevent cluster instability
    • Readiness probes are different from liveness probes
    • StatefulSets are necessary for databases
  4. GitOps Benefits

    • Declarative infrastructure is easier to manage
    • Git history provides audit trail
    • Rollbacks are straightforward

Best Practices Adopted

  • βœ… Infrastructure as Code for reproducibility
  • βœ… Automated testing in CI pipeline
  • βœ… Container image versioning
  • βœ… Health checks for all services
  • βœ… Secrets management
  • βœ… Documentation as code

πŸ”— Related Repositories


⭐ Acknowledgments

Built with modern DevOps practices and cloud-native technologies to demonstrate real-world production deployment skills.

Technologies: React β€’ Node.js β€’ Express β€’ MongoDB β€’ Docker β€’ Kubernetes β€’ Azure AKS β€’ ArgoCD β€’ GitHub Actions β€’ Nginx


Last Updated: October 2025

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published