Skip to content

Employee Management System built on FastAPI, Next.js, integrating Model Context Protocol (MCP) with a dual-LLM architecture for AI-driven, natural-language database interaction..

Notifications You must be signed in to change notification settings

shiranthaDS/Work-Zen

Repository files navigation

πŸš€ Work-Zen: Cloud-Native Employee Management System

Next.js Python FastAPI Docker AWS Terraform Ansible Jenkins Grafana HuggingFace MCP

A production-grade, cloud-native Employee Management System with an AI-powered chat interface that integrates the Model Context Protocol (MCP) with a dual-LLM architecture, demonstrating enterprise DevOps practices through Jenkins-based CI/CD automation, Infrastructure as Code (IaC), Dockerized services deployed on AWS EC2, and end-to-end monitoring.


🎯 Project Overview

  • πŸ‘₯ Employee Management: Complete CRUD operations for employee data
  • πŸ’¬ Chat interface: Natural language queries to database
  • 🧠 Dual LLM System: OpenRouter (Primary) & HuggingFace (Backup) for Intent Detection + Response Generation
  • πŸ”„ MCP Server:Real-time data retrieval via MCP
  • πŸ”„ CI/CD Automation (Jenkins)
  • 🐳 Containerization (Docker + Docker Compose)
  • ☁️ Cloud Deployment (AWS EC2)
  • πŸ—οΈ Infrastructure as Code (Terraform)
  • πŸ€– Configuration Management (Ansible)
  • πŸ“Š Monitoring & Observability (Prometheus + Grafana)

πŸ”„ Application Architecture Flow

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   User   │────────►│ Next.js  │────────►│ FastAPI  │────────►│   MCP    │────────►│ MongoDB  β”‚
β”‚ Browser  │◄────────│ Frontend │◄────────│ Backend  │◄────────│  Server  │◄────────│  Atlas   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          β”‚                     β”‚                     β”‚
                          β”‚                     β”‚                     β”‚
                          β–Ό                     β–Ό                     β–Ό
                      React UI             LLM Intent Detection       MCP Tools
                   chat interface         (OpenRouter/HF)        (16 operations)
                                         Response Generation        JSON-RPC stdio

πŸ—οΈ DevOps Architecture

DevOps Pipeline

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                          DEVELOPER WORKFLOW                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                          Git Push to GitHub
                                    β”‚
                                    β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                           CI/CD PIPELINE (Jenkins)                           β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  1. Source Code Checkout (GitHub Webhook)                                    β”‚
β”‚  2. Unit & Integration Tests (Backend / Frontend)                            β”‚
β”‚  3. Docker Image Build (Multi-stage builds)                                  β”‚
β”‚  4. Image Scan / Best Practices                                              β”‚
β”‚  5. Push Images to Docker Hub                                                β”‚
β”‚  6. Deploy to EXISTING EC2                                                   β”‚
β”‚  7. Health Checks & Smoke Tests                                              β”‚
β”‚  8. Notifications (Success / Failure)                                        β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     RUNNING APPLICATION (PRODUCTION) On EC2                 β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                              β”‚
β”‚                        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                             β”‚
β”‚     Internet (HTTPS)──►│  NGINX Reverse Proxy β”‚                             β”‚
β”‚     Port 443/80        β”‚  Let's Encrypt SSL   β”‚                             β”‚
β”‚                        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                             β”‚
β”‚                                 β”‚                                            β”‚
β”‚                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                             β”‚
β”‚                    β”‚                          β”‚                             β”‚
β”‚                    β–Ό                          β–Ό                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”‚
β”‚  β”‚   Frontend       β”‚    β”‚    Backend       β”‚    β”‚   MCP Server     β”‚     β”‚
β”‚  β”‚   (Next.js)      │◄──►│   (FastAPI)      │◄──►│   (Node.js)      β”‚     β”‚
β”‚  β”‚   Port: 3000     β”‚    β”‚   Port: 8000     β”‚    β”‚   stdio          β”‚     β”‚
β”‚  β”‚   Docker Image   β”‚    β”‚   Docker Image   β”‚    β”‚   Subprocess     β”‚     β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β”‚
β”‚                                   β”‚                                         β”‚
β”‚                         work-zen-docker-network                              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                β”‚                                        β”‚
                β–Ό                                        β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚     DATABASE (MongoDB Atlas)     β”‚   β”‚        MONITORING STACK              β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€   β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Cloud-hosted NoSQL Database     β”‚   β”‚  Prometheus (9090)                   β”‚
β”‚  - employees                     β”‚   β”‚  Grafana (3001)                     β”‚
β”‚  - attendance                    β”‚   β”‚  Node Exporter (9100)               β”‚
β”‚  - payroll                       β”‚   β”‚  cAdvisor (8081)                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

🎯 Key DevOps Features

Feature Technology Purpose
πŸ—οΈ IaC Terraform Provision AWS infrastructure (VPC, EC2, Security Groups)
πŸ€– Config Mgmt Ansible Server setup, app deployment, monitoring stack
πŸ”„ CI/CD Jenkins Automated build, test, deploy pipeline with webhooks
πŸ“Š Monitoring Prometheus + Grafana System & container metrics, custom dashboards
🐳 Containers Docker + Compose Multi-stage builds, optimized images, orchestration
☁️ Cloud AWS EC2 Production deployment with t3.micro optimization
πŸ”’ Security UFW + Security Groups Firewall rules, minimal port exposure
🌐 Reverse Proxy NGINX + Let's Encrypt SSL/TLS termination, HTTPS, load balancing
πŸ“ˆ Scalability Resource limits Memory/CPU constraints, horizontal scaling ready

βš™οΈ Technology Stack

🎨 Frontend Technologies

Next.js React TypeScript TailwindCSS

  • Next.js 14.0.4 - React framework with server-side rendering
  • React 18.2.0 - UI component library
  • TypeScript 5 - Type-safe JavaScript
  • TailwindCSS 3.4.1 - Utility-first CSS framework

βš™οΈ Backend Technologies

Python FastAPI MongoDB Node.js

  • FastAPI 0.109.0 - High-performance Python REST API
  • Motor 3.3.2 - Async MongoDB driver
  • PyMongo 4.6.1 - MongoDB Python driver
  • Python 3.9+ - Backend programming language
  • Node.js 18+ - MCP server runtime

πŸ€– AI/ML Technologies

OpenRouter HuggingFace

  • OpenRouter API - Primary LLM provider (Mistral-7B-Instruct-v0.2)
  • HuggingFace API - Backup LLM provider
  • Dual LLM System - Intent detection + Response generation
  • Model Context Protocol (MCP) - Anthropic's standard for AI-DB communication

πŸš€ DevOps & Cloud Technologies

Docker Jenkins Terraform Ansible AWS NGINX Prometheus Grafana

  • Docker - Container runtime and image building
  • Docker Compose - Multi-container orchestration
  • Jenkins 2.528.3 - CI/CD automation server
  • Terraform - Infrastructure as Code for AWS
  • Ansible - Configuration management and deployment automation
  • AWS EC2 - Cloud compute (t3.micro optimized)
  • NGINX - High-performance reverse proxy and SSL termination
  • Let's Encrypt - Free SSL/TLS certificates with auto-renewal
  • Prometheus v2.47.0 - Metrics collection and alerting
  • Grafana 10.2.0 - Metrics visualization and dashboards
  • Node Exporter v1.6.1 - System metrics exporter
  • cAdvisor v0.49.1 - Container metrics exporter

πŸ”„ CI/CD Pipeline

πŸ“‹ Jenkins Pipeline Overview

The project uses a comprehensive Jenkins pipeline with the following stages:

pipeline {
  agent any
  
  stages {
    1️⃣ Checkout        β†’ Pull latest code from GitHub
    2️⃣ Test Backend    β†’ Python unit tests (optimized)
    3️⃣ Test Frontend   β†’ Node.js unit tests (optimized)
    4️⃣ Build Images    β†’ Docker multi-stage builds
    5️⃣ Push to Hub     β†’ Docker Hub image registry
    6️⃣ Deploy to EC2   β†’ SSH deployment with retry logic
    7️⃣ Health Check    β†’ Verify deployment success
  }
}

🎯 Pipeline Features

βœ… Automated Testing βœ… Docker Image Management

  • Automated push to Docker Hub registry βœ… Deployment Automation
  • SSH-based deployment to EC2
  • Force pull latest images (--pull always)
  • Automatic container restart
  • Zero-downtime deployment strategy βœ… Health Checks βœ… Notifications

Infrastructure Operations

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   INFRASTRUCTURE & OPERATIONS (ON DEMAND)                   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         TERRAFORM (IaC)                                      β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  β€’ Create EC2 instances                                                      β”‚
β”‚  β€’ Create Security Groups                                                    β”‚
β”‚  β€’ Allocate Elastic IP                                                       β”‚
β”‚  β€’ Define VPC / Subnets                                                      β”‚
β”‚  β€’ Create NEW environments (dev/staging/prod)                               β”‚
β”‚                                                                              β”‚
β”‚  Executed ONLY when:                                                         β”‚
β”‚  βœ“ New environment needed                                                    β”‚
β”‚  βœ“ Instance type change                                                      β”‚
β”‚  βœ“ Infrastructure scaling                                                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                    β”‚
                                    β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         ANSIBLE (CONFIG MGMT)                                β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  β€’ Install Docker & Docker Compose                                           β”‚
β”‚  β€’ Create /home/ubuntu/Work-Zen                                              β”‚
β”‚  β€’ Configure OS, users, permissions                                          β”‚
β”‚  β€’ Install monitoring stack                                                  β”‚
β”‚  β€’ Bootstrap server to be CI/CD-ready                                       β”‚
β”‚                                                                              β”‚
β”‚  Executed ONLY when:                                                         β”‚
β”‚  βœ“ New EC2 created                                                           β”‚
β”‚  βœ“ Base config changes                                                       β”‚
β”‚  βœ“ Disaster recovery                                                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”’ NGINX + SSL Configuration

🌐 Production Setup with HTTPS

Work-Zen uses NGINX as a reverse proxy with Let's Encrypt SSL certificates for secure HTTPS communication in production.

Live Production URL: https://workzen.duckdns.org

πŸ“‹ NGINX Configuration Overview

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         NGINX Reverse Proxy Architecture                     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

        Internet (Port 443/80)
                β”‚
                β–Ό
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚  NGINX Server β”‚ ← Let's Encrypt SSL Certificate
        β”‚  Port 80/443  β”‚    (Auto-renewal via certbot)
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚                β”‚
        β–Ό                β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Frontend    β”‚  β”‚  Backend     β”‚
β”‚  :3000       β”‚  β”‚  :8000/api/  β”‚
β”‚  (Next.js)   β”‚  β”‚  (FastAPI)   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ” SSL/TLS Features

βœ… Automatic HTTPS Redirect - HTTP (80) β†’ HTTPS (443)
βœ… Let's Encrypt Certificate - Free, auto-renewing SSL/TLS
βœ… TLS 1.2 & 1.3 Support - Modern encryption protocols
βœ… A+ SSL Rating - Strong cipher configuration
βœ… HSTS Enabled - HTTP Strict Transport Security
βœ… Certificate Auto-Renewal - Automated via certbot cron job

πŸ“š Related Documentation

  • NGINX_SETUP.md - Detailed NGINX configuration guide
  • AWS_EC2_DEPLOYMENT.md - EC2 deployment with NGINX
  • DEPLOYMENT_QUICK_START.md - Quick deployment guide

πŸ—„οΈ Database Features

  • πŸ”— Foreign Key Relationships: Proper indexes on employee_id linking all collections
  • ⚑ Optimized MongoDB Queries: Efficient aggregation pipelines
  • 🎯 62+ Filter Parameters: Comprehensive filtering across all collections

πŸš€ Quick Start

Prerequisites πŸ“‹

Tool Version Purpose
🐳 Docker 20.10+ Container runtime
🎡 Docker Compose 2.0+ Multi-container orchestration
☁️ AWS Account - Cloud infrastructure (optional)
πŸ”§ Terraform 1.0+ Infrastructure provisioning (optional)
πŸ€– Ansible 2.9+ Configuration management (optional)
πŸš€ Jenkins 2.5+ CI/CD automation (optional)

Option 1: 🐳 Docker Deployment (Recommended)

Fastest way to get started - production-ready in 3 minutes!

# 1️⃣ Clone the repository
git clone https://github.com/shiranthaDS/Work-Zen.git
cd Work-Zen

# 2️⃣ Configure environment
cp .env.example .env
# Edit .env and add your MongoDB URL and API keys

# 3️⃣ Start all services
docker-compose up -d --build

# 4️⃣ Check container status
docker-compose ps

# 5️⃣ View logs
docker-compose logs -f              # All containers
docker-compose logs -f backend      # Backend only
docker-compose logs -f frontend     # Frontend only

# 6️⃣ Access the application
# 🌐 Frontend: http://localhost:3000
# βš™οΈ Backend API: http://localhost:8000
# πŸ“š API Docs: http://localhost:8000/docs
# πŸ“Š Prometheus: http://localhost:9090
# πŸ“ˆ Grafana: http://localhost:3001

# 🌍 Production URL (when deployed):
# πŸ”’ Production: https://workzen.duckdns.org
# πŸ”’ API: https://workzen.duckdns.org/api/
# πŸ“š API Docs: https://workzen.duckdns.org/api/docs

Common Docker Commands πŸ› οΈ

# Start containers
docker-compose up -d                # πŸš€ Start in background
docker-compose up                   # πŸ“‹ Start with logs in foreground

# Stop containers
docker-compose stop                 # ⏸️ Stop containers
docker-compose down                 # πŸ—‘οΈ Stop and remove containers

# Restart containers
docker-compose restart              # πŸ”„ Restart all
docker-compose restart backend      # πŸ”„ Restart backend only

# View logs
docker-compose logs -f backend      # πŸ“‹ Follow backend logs
docker-compose logs --tail=100 backend  # πŸ“„ Last 100 lines
docker-compose logs --since 30m     # ⏰ Last 30 minutes

# Check container status
docker-compose ps                   # πŸ“Š List all containers
docker ps                          # 🐳 List running containers

# Execute commands in container
docker-compose exec backend bash    # πŸ’» Access backend shell
docker-compose exec frontend sh     # πŸ’» Access frontend shell

# Rebuild specific service
docker-compose up -d --build backend

# Clean restart (remove volumes)
docker-compose down -v
docker-compose up -d --build

πŸ” Verifying Your Setup

Backend Startup Messages:

βœ… Connected to MongoDB: ems_database
βœ… OpenRouter API configured (Primary LLM)
πŸš€ Starting MCP Server from: /app/mcp-server
βœ… MCP Server started successfully
INFO: Application startup complete.

MCP Server Startup:

πŸ”Œ Connecting to MongoDB...
βœ… Connected to MongoDB database: ems_database
βœ… Database indexes created successfully
EMS MCP Server running on stdio

Container Status (Docker):

$ docker-compose ps
NAME                  STATUS          PORTS
work-zen-backend      Up 5 minutes    0.0.0.0:8000->8000/tcp
work-zen-frontend     Up 5 minutes    0.0.0.0:3000->3000/tcp
work-zen-prometheus   Up 5 minutes    0.0.0.0:9090->9090/tcp
work-zen-grafana      Up 5 minutes    0.0.0.0:3001->3001/tcp
work-zen-node-exporter Up 5 minutes   0.0.0.0:9100->9100/tcp
work-zen-cadvisor     Up 5 minutes    0.0.0.0:8081->8081/tcp

πŸ“ Project Structure

work-zen/
β”œβ”€β”€ πŸ”§ infrastructure/           # DevOps & Infrastructure
β”‚   β”œβ”€β”€ terraform/              # Infrastructure as Code
β”‚   β”‚   β”œβ”€β”€ main.tf            # AWS resource definitions
β”‚   β”‚   β”œβ”€β”€ variables.tf       # Input variables
β”‚   β”‚   β”œβ”€β”€ outputs.tf         # Output values
β”‚   β”‚   └── README.md          # Terraform documentation
β”‚   └── ansible/               # Configuration Management
β”‚       β”œβ”€β”€ inventory/         # Dynamic inventory
β”‚       β”œβ”€β”€ playbooks/         # Automation playbooks
β”‚       β”‚   β”œβ”€β”€ setup.yml     # Server provisioning
β”‚       β”‚   β”œβ”€β”€ deploy.yml    # App deployment
β”‚       β”‚   β”œβ”€β”€ monitoring.yml # Monitoring setup
β”‚       β”‚   └── rollback.yml  # Rollback procedures
β”‚       └── README.md          # Ansible documentation
β”‚
β”œβ”€β”€ πŸ“Š monitoring/              # Observability Stack
β”‚   β”œβ”€β”€ prometheus/
β”‚   β”‚   └── prometheus.yml     # Prometheus configuration
β”‚   β”œβ”€β”€ grafana/
β”‚   β”‚   └── provisioning/
β”‚   β”‚       β”œβ”€β”€ datasources/   # Auto-provisioned datasources
β”‚   β”‚       └── dashboards/    # Pre-configured dashboards
β”‚   └── docker-compose.monitoring.yml
β”‚
β”œβ”€β”€ βš™οΈ backend/                 # FastAPI Backend
β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”œβ”€β”€ database.py        # MongoDB connection
β”‚   β”‚   β”œβ”€β”€ main.py            # FastAPI app
β”‚   β”‚   β”œβ”€β”€ mcp_client.py      # MCP Client (stdio)
β”‚   β”‚   β”œβ”€β”€ models/            # Pydantic models
β”‚   β”‚   └── routes/            # API endpoints
β”‚   β”‚       β”œβ”€β”€ employees.py
β”‚   β”‚       β”œβ”€β”€ job_data.py
β”‚   β”‚       β”œβ”€β”€ attendance.py
β”‚   β”‚       β”œβ”€β”€ leaves.py
β”‚   β”‚       β”œβ”€β”€ payroll.py
β”‚   β”‚       └── chat.py        # AI chat endpoint
β”‚   β”œβ”€β”€ Dockerfile             # Multi-stage build
β”‚   β”œβ”€β”€ requirements.txt
β”‚   └── .env
β”‚
β”œβ”€β”€ πŸ”Œ mcp-server/              # MCP Server (Node.js)
β”‚   β”œβ”€β”€ index.js              # MCP server with 16 MongoDB tools
β”‚   β”œβ”€β”€ database.js           # MongoDB connection
β”‚   β”œβ”€β”€ package.json
β”‚   └── .env
β”‚
β”œβ”€β”€ 🎨 frontend/                # Next.js Frontend
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ app/
β”‚   β”‚   β”‚   β”œβ”€β”€ page.tsx              # Dashboard
β”‚   β”‚   β”‚   β”œβ”€β”€ employees/            # Employee pages
β”‚   β”‚   β”‚   β”œβ”€β”€ job-data/             # Job data pages
β”‚   β”‚   β”‚   β”œβ”€β”€ attendance/           # Attendance pages
β”‚   β”‚   β”‚   β”œβ”€β”€ leaves/               # Leave pages
β”‚   β”‚   β”‚   β”œβ”€β”€ payroll/              # Payroll pages
β”‚   β”‚   β”‚   β”œβ”€β”€ salary-structures/    # Salary pages
β”‚   β”‚   β”‚   └── chat/                 # AI chat page
β”‚   β”‚   β”œβ”€β”€ components/               # Reusable components
β”‚   β”‚   β”‚   β”œβ”€β”€ Sidebar.tsx
β”‚   β”‚   β”‚   └── Header.tsx
β”‚   β”‚   └── services/                 # API services
β”‚   β”œβ”€β”€ Dockerfile             # Multi-stage build
β”‚   β”œβ”€β”€ package.json
β”‚   └── .env.local
β”‚
β”œβ”€β”€ πŸ”„ Jenkinsfile              # CI/CD Pipeline Definition
β”œβ”€β”€ 🐳 docker-compose.yml       # Application orchestration
β”œβ”€β”€ πŸ“Š docker-compose.monitoring.yml  # Monitoring stack
β”œβ”€β”€ πŸ“š Documentation/
β”‚   β”œβ”€β”€ README.md              # This file
β”‚   β”œβ”€β”€ ARCHITECTURE.md        # System architecture
β”‚   β”œβ”€β”€ DOCKER_SETUP.md        # Docker guide
β”‚   β”œβ”€β”€ AWS_EC2_DEPLOYMENT.md  # AWS deployment
β”‚   β”œβ”€β”€ JENKINS_SETUP.md       # CI/CD setup
β”‚   └── DEPLOYMENT_QUICK_START.md
└── .env.example               # Environment template

πŸ”‘ MCP Tools Available

The MCP Server provides 16 specialized tools for database operations:

Tool Description
list_employees Get all employees
get_employee Get employee by ID
search_employees Advanced employee search
list_job_data Get all job data
get_job_data Get job data by employee
list_attendance Get attendance records
get_attendance Get attendance by employee
list_leaves Get leave requests
get_leave Get specific leave
pending_leaves Get pending approvals
get_leave_balance Calculate leave balance
list_payroll Get payroll records
get_payroll Get payroll by employee
department_employees Get employees by dept
stats_summary System statistics
search General search

πŸ“ License

MIT License - See LICENSE file for details


πŸ‘₯ Contributors

Shirantha Dissanayake


πŸ“§ Support & Contact

For issues, questions, or contributions:


⭐ Star This Repository!

If you find this project helpful, please consider giving it a star on GitHub!

GitHub stars GitHub forks GitHub issues GitHub license


Built with ❀️ using FastAPI, Next.js, Model Context Protocol, and Enterprise DevOps Practices

πŸš€ Showcasing: Docker β€’ Kubernetes β€’ Terraform β€’ Ansible β€’ Jenkins β€’ Prometheus β€’ Grafana β€’ AWS β€’ CI/CD


This project demonstrates production-grade DevOps practices and cloud-native architecture suitable for enterprise environments.

About

Employee Management System built on FastAPI, Next.js, integrating Model Context Protocol (MCP) with a dual-LLM architecture for AI-driven, natural-language database interaction..

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published