{"id":30069104,"url":"https://github.com/mohammed-khubaib/n-tier","last_synced_at":"2026-04-07T18:31:56.180Z","repository":{"id":301417550,"uuid":"1008481463","full_name":"Mohammed-Khubaib/N-Tier","owner":"Mohammed-Khubaib","description":"3-Tier Web Application","archived":false,"fork":false,"pushed_at":"2025-08-04T17:01:39.000Z","size":2982,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-04T20:18:50.062Z","etag":null,"topics":["argocd","docker","docker-compose","fastapi","github-actions","github-pages","helm","helm-charts","kubernetes","kubernetes-cluster","mkdocs","mkdocs-material","orbstack","pgadmin4","postgresql","python","streamlit","uv"],"latest_commit_sha":null,"homepage":"https://mohammed-khubaib.github.io/N-Tier/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Mohammed-Khubaib.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-25T15:56:24.000Z","updated_at":"2025-08-04T17:01:11.000Z","dependencies_parsed_at":"2025-06-26T19:34:46.963Z","dependency_job_id":"54bc7dd0-8166-44fb-b095-12083065bf2d","html_url":"https://github.com/Mohammed-Khubaib/N-Tier","commit_stats":null,"previous_names":["mohammed-khubaib/n-tier"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Mohammed-Khubaib/N-Tier","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mohammed-Khubaib%2FN-Tier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mohammed-Khubaib%2FN-Tier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mohammed-Khubaib%2FN-Tier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mohammed-Khubaib%2FN-Tier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Mohammed-Khubaib","download_url":"https://codeload.github.com/Mohammed-Khubaib/N-Tier/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Mohammed-Khubaib%2FN-Tier/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269410221,"owners_count":24412157,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-08T02:00:09.200Z","response_time":72,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["argocd","docker","docker-compose","fastapi","github-actions","github-pages","helm","helm-charts","kubernetes","kubernetes-cluster","mkdocs","mkdocs-material","orbstack","pgadmin4","postgresql","python","streamlit","uv"],"created_at":"2025-08-08T11:01:44.556Z","updated_at":"2025-12-30T19:54:05.403Z","avatar_url":"https://github.com/Mohammed-Khubaib.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# N-Tier Application with Automated CI/CD Pipeline\n\nA complete 3-tier web application with FastAPI backend, Streamlit frontend, and PostgreSQL database, featuring automated CI/CD pipeline using Docker, Kubernetes, Helm, GitHub Actions, and ArgoCD.\n\n## 🏗️ Architecture\n\n```mermaid\narchitecture-beta\n    group fs(cloud)[3 Tier Architecture]\n    group ui(internet)[Frontend] in fs\n    group api(internet)[Backend] in fs\n    \n    service client(server)[Streamlit] in ui\n    service db(database)[PostgreSQL] in api\n    service server(server)[FastAPI] in api\n\n    client:R \u003c--\u003e L:server\n    db:L \u003c--\u003e R:server\n```\n\n## 📁 Project Structure\n\n```\n.\n├── .github/workflows/main.yaml     # CI/CD Pipeline\n├── app/                           # FastAPI Application\n├── client/                        # Streamlit Application\n├── helm/                          # Helm Charts\n├── kubernetes/                    # K8s Manifests\n├── docker-compose.yml             # Local Development\n├── Dockerfile.server              # API Docker Image\n├── Dockerfile.client              # UI Docker Image\n├── argocd-application.yaml        # ArgoCD Application\n└── pyproject.toml                 # Python Dependencies\n```\n\n## 🚀 Manual Deployment Guide\n\n### 1. Python Environment Setup with UV\n\n- **Install UV** (if not already installed):\n   ```bash\n    # macOS using Homebrew (recommended)\n    brew install uv\n    \n    # macOS/Linux using installer\n    curl -LsSf https://astral.sh/uv/install.sh | sh\n    \n    # Windows\n    powershell -c \"irm https://astral.sh/uv/install.ps1 | iex\"\n    \n    # Using pip\n    pip install uv\n    ```\n- Setting up UV (Python's Package Manager):\n    ```bash\n    # Initialize UV project\n    uv init --name n-tier --app\n\n    # Create virtual environment\n    uv venv --python 3.13\n\n    # Activate environment (Linux/macOS)\n    source .venv/bin/activate\n\n    # Install dependencies\n    uv sync\n    ```\n- Run The Application locally:\n    - Run API(FastAPI)\n        ```bash\n        uv run uvicorn app.main:app --reload --host 0.0.0.0 --port 8000\n        ```\n    - Run Streamlit application \n        ```bash\n        uv run streamlit run main.py\n        ```\n\n### 2. Docker Operations\n\n#### Build Docker Images\n\n```bash\n# Build FastAPI server image\ndocker build -f Dockerfile.server -t \u003cdockerhub-user-name\u003e/fastapi-server:latest .\n\n# Build Streamlit client image  \ndocker build -f Dockerfile.client -t \u003cdockerhub-user-name\u003e/streamlit-client:latest .\n```\n\n#### Push to DockerHub\n\n```bash\n# Login to DockerHub\ndocker login\n\n# Push images\ndocker push \u003cdockerhub-user-name\u003e/fastapi-server:latest\ndocker push \u003cdockerhub-user-name\u003e/streamlit-client:latest\n```\n\n#### Test with Docker Compose\n\n```bash\n# Start application stack\ndocker compose up -d\n\n# View logs\ndocker compose logs -f\n\n# Stop and cleanup\ndocker compose down\n```\n\n**Access Points:**\n- **Frontend:** http://localhost:8501\n- **API:** http://localhost:8000\n- **PgAdmin:** http://localhost:5050\n\n### 3. Kubernetes Deployment (OrbStack)\n\n#### Deploy with Kubectl\n\n```bash\n# Create namespace\nkubectl apply -f kubernetes/namespace.yaml\n\n# Deploy all services\nkubectl apply -f kubernetes/\n\n# Check deployment status\nkubectl get pods -n fastapi-app\nkubectl get services -n fastapi-app\n\n# Port forward for local access\nkubectl port-forward -n fastapi-app svc/client-service 8501:8501\nkubectl port-forward -n fastapi-app svc/api-service 8000:8000\n```\n\n#### Cleanup\n\n```bash\n# Delete all resources\nkubectl delete -f kubernetes/\n\n# Delete namespace\nkubectl delete namespace fastapi-app\n```\n\n### 4. Helm Deployment\n\n#### Deploy with Helm\n\n```bash\n# Install application\nhelm install n-tier-app ./helm\n\n# Upgrade deployment\nhelm upgrade n-tier-app ./helm\n\n# Check status\nhelm status n-tier-app\nkubectl get pods -n fastapi-app\n```\n\n#### Cleanup\n\n```bash\n# Uninstall Helm release\nhelm uninstall n-tier-app\n\n# Delete namespace if needed\nkubectl delete namespace fastapi-app\n```\n\n### 5. ArgoCD Setup\n![argocd setup](./docs/assets/argocd_setup.png)\n#### Install ArgoCD\n\n```bash\n# Create ArgoCD namespace\nkubectl create namespace argocd\n\n# Install ArgoCD\nkubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml\n\n# Wait for pods to be ready\nkubectl wait --for=condition=available --timeout=300s deployment/argocd-server -n argocd\n```\n\n#### Access ArgoCD\n\n```bash\n# Port forward ArgoCD server\nkubectl port-forward svc/argocd-server -n argocd 8080:443\n\n# Get admin password\nkubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath=\"{.data.password}\" | base64 -d\n```\n\n**ArgoCD Access:** https://localhost:8080\n- **Username:** admin\n- **Password:** (from command above)\n\n#### Deploy Application via ArgoCD\n\n```bash\n# Apply ArgoCD application\nkubectl apply -f argocd-application.yaml\n\n# Sync application\nargocd app sync test-three-tier-app\n```\n\n#### Cleanup ArgoCD\n\n```bash\n# Delete application\nkubectl delete -f argocd-application.yaml\n\n# Uninstall ArgoCD\nkubectl delete -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml\nkubectl delete namespace argocd\n```\n\n## 🔄 Automated CI/CD Pipeline\n\n### CI/CD Flow Diagram\n\n![img](./docs/assets/CICD_Pipeline_Image.png)\n\n### Pipeline Features\n\n- **Continuous Integration:**\n  - Automated Docker image builds\n  - Automatic tagging with commit SHA\n  - DockerHub registry push\n  - Automatic Helm values update\n\n- **Continuous Deployment:**\n  - GitOps approach with ArgoCD\n  - Auto Sync with Updated Helm values\n  - Self-healing deployments\n  - Rollback capabilities\n\n### Pipeline Triggers\n\n- Triggers on push to `main` branch\n- Builds both FastAPI and Streamlit images\n- Updates Helm chart with new image tags\n- ArgoCD automatically syncs changes to cluster\n\n### Required Secrets\n\nConfigure these secrets in GitHub repository settings:\n\n```\nDOCKERHUB_USRNAME=your_dockerhub_username\nDOCKERHUB_PSWD=your_dockerhub_password\n```\n\n## 🛠️ Technology Stack\n\n- **Frontend:** Streamlit\n- **Backend:** FastAPI\n- **Database:** PostgreSQL\n- **Containerization:** Docker\n- **Orchestration:** Kubernetes\n- **Package Management:** Helm\n- **CI/CD:** GitHub Actions\n- **GitOps:** ArgoCD\n- **Local K8s:** OrbStack\n\n## 📝 Development Workflow\n\n1. **Local Development:** Use UV for dependency management\n2. **Testing:** Docker Compose for integration testing\n3. **Deployment:** Kubernetes with Helm charts\n4. **Production:** Automated CI/CD with ArgoCD\n\n## 🔍 Monitoring \u0026 Debugging\n\n```bash\n# Check application logs\nkubectl logs -f deployment/api-deployment -n fastapi-app\nkubectl logs -f deployment/client-deployment -n fastapi-app\n\n# Check ArgoCD application status\nkubectl get applications -n argocd\nargocd app get test-three-tier-app\n\n# Monitor resource usage\nkubectl top pods -n fastapi-app\n```\n---\n\n**Note:** Ensure OrbStack or another local Kubernetes solution is running before executing Kubernetes commands.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohammed-khubaib%2Fn-tier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmohammed-khubaib%2Fn-tier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmohammed-khubaib%2Fn-tier/lists"}