Skip to content

sathwikshetty33/JanGo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

10 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

โšก JanGo

Lightning-fast Django deployment to Azure with automated CI/CD setup

A developer-friendly tool that eliminates the complexity of Django deployment. Built by a Django developer, for Django developers who want to deploy applications quickly without the usual hassles of PythonAnywhere and other complex platforms.

โœจ Features

  • โšก One-Click Deployment: Deploy Django apps to Azure VMs in minutes
  • ๐Ÿ”„ Automatic CI/CD: GitHub Actions pipeline configured automatically via GitHub API
  • ๐Ÿ› ๏ธ Infrastructure as Code: Terraform provisions Azure resources with security best practices
  • ๐ŸŽฏ Minimal Configuration: Just provide repo URL, credentials, and environment variables
  • ๐Ÿ“Š Real-time Monitoring: Live deployment logs and status updates via React frontend
  • ๐Ÿ”ง Smart Detection: Automatically detects WSGI vs ASGI applications and configures accordingly
  • ๐Ÿ” Secure: SSH key-based authentication and proper security group configuration
  • ๐Ÿš€ Production Ready: Nginx reverse proxy, Supervisor process management, and rate limiting

๐ŸŽฏ Why JanGo?

As Django developers, we've all been there:

  • โŒ Spending hours configuring deployment pipelines
  • โŒ Wrestling with complex PaaS platforms like PythonAnywhere
  • โŒ Manual server setup and configuration
  • โŒ Repetitive deployment tasks for every new project

JanGo solves all of this with a single, streamlined workflow.

๐Ÿ—๏ธ System Architecture

JanGo System Architecture

Complete system architecture showing the flow from user interaction to deployed Django application

๐Ÿ—๏ธ Architecture & Workflow

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚   React Frontend โ”‚โ—„โ”€โ”€โ–บโ”‚   Go Backend     โ”‚โ—„โ”€โ”€โ–บโ”‚   Azure VM      โ”‚
โ”‚   (Logs & Status)โ”‚    โ”‚  (Orchestration) โ”‚    โ”‚  (Ubuntu 22.04) โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                                โ”‚
                                โ–ผ
                   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                   โ”‚    Deployment Pipeline   โ”‚
                   โ”‚                          โ”‚
                   โ”‚ 1. Terraform โ†’ VM Setup โ”‚
                   โ”‚ 2. SSH Key Generation   โ”‚
                   โ”‚ 3. Ansible โ†’ App Config โ”‚
                   โ”‚ 4. GitHub Actions Setup โ”‚
                   โ”‚ 5. Nginx + Supervisor  โ”‚
                   โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Deployment Workflow

  1. Infrastructure Provisioning (Terraform)

    • Creates Azure Resource Group, VNet, and VM
    • Configures security groups (SSH, HTTP, HTTPS, port 8000)
    • Generates SSH key pair for secure access
  2. Server Configuration (Ansible)

    • Installs system dependencies (Python3, Nginx, Supervisor, etc.)
    • Clones your repository
    • Creates virtual environment
    • Auto-detects Django project structure
  3. Application Setup

    • Installs requirements automatically
    • Configures CORS and ALLOWED_HOSTS
    • Runs migrations and collects static files
    • Sets up Gunicorn (WSGI) or Uvicorn (ASGI) workers
  4. Production Services

    • Configures Nginx as reverse proxy with rate limiting
    • Sets up Supervisor for process management
    • Creates comprehensive logging system
  5. CI/CD Integration

    • Adds SSH key to GitHub Actions secrets
    • Creates automated deployment workflow
    • Enables push-to-deploy functionality

๐Ÿš€ Quick Start

Prerequisites

  • Azure CLI logged in (az login)
  • Terraform installed (v1.0+)
  • Ansible installed (v2.9+)
  • Go 1.19+ installed
  • Node.js 16+ and npm
  • GitHub personal access token with repo permissions

Installation

  1. Clone the repository

    git clone https://github.com/sathwikshetty33/JanGo.git
    cd JanGo
  2. Configure Azure credentials

    # Login to Azure CLI
    az login
    
    # Create .env file in /api/ directory
    cd api
    echo "AZURE_SUBSCRIPTION_ID=your-azure-subscription-id" > .env
    cd ..
  3. Install dependencies

    # Backend dependencies
    go mod tidy
    
    # Frontend dependencies
    cd frontend
    npm install
    cd ..
  4. Start the application

    # Start backend
    go run main.go
    
    # In another terminal, start frontend
    cd frontend
    cd deployment-dashbaord
    npm start
  5. Access the application Open your browser and navigate to http://localhost:3000

๐ŸŽฎ Usage

Deployment Parameters

Fill in the deployment form with the following information:

  • Username: Your preferred username for the deployment
  • Repository URL: Your Django project's GitHub repository
  • GitHub Token: Personal access token with repo and workflow permissions
  • Additional Commands: Custom setup commands (e.g., pip install requirements.txt)
  • Environment Variables: Key-value pairs for Django settings
  • ASGI Application: Check if using Django Channels, FastAPI, etc.
  • Auto Deploy: Enable automatic deployment after setup

Environment Variables Format

DEBUG=False
SECRET_KEY=your-secret-key-here
DATABASE_URL=postgresql://user:pass@host:port/db
ALLOWED_HOSTS=yourdomain.com,www.yourdomain.com

Supported Application Types

  • WSGI Applications: Traditional Django apps (uses Gunicorn)
  • ASGI Applications: Django Channels, FastAPI (uses Gunicorn + Uvicorn workers)

๐Ÿ”ง System Requirements & Dependencies

Automatically Installed on VM

# System packages
- python3
- python3-pip
- python3-dev
- python3-venv
- git
- nginx
- supervisor
- build-essential
- libpq-dev
- pkg-config
- default-libmysqlclient-dev

# Python packages (auto-detected)
- gunicorn (for WSGI apps)
- uvicorn (for ASGI apps)
- Your project's requirements.txt

Server Configuration

Nginx Configuration

# Rate limiting zones
limit_req_zone $binary_remote_addr zone=general:10m rate=30r/m;
limit_req_zone $binary_remote_addr zone=auth:10m rate=5r/m;
limit_req_zone $binary_remote_addr zone=api:10m rate=100r/m;
limit_req_zone $binary_remote_addr zone=static:10m rate=200r/m;

Supervisor Configuration

[program:django-server]
command=/home/azureuser/app/start_server.sh
directory={{ django_project_path }}
user=azureuser
autostart=true
autorestart=true
stdout_logfile=/home/azureuser/logs/django-server-stdout.log
stderr_logfile=/home/azureuser/logs/django-server-stderr.log

๐Ÿ”„ Automated CI/CD

After deployment, your repository will automatically include a GitHub Actions workflow:

name: Auto Deploy Django Application
on:
  push:
    branches: [ main, master ]
  pull_request:
    branches: [ main, master ]
    types: [closed]

jobs:
  deploy:
    if: github.event_name == 'push' || (github.event_name == 'pull_request' && github.event.pull_request.merged == true)
    runs-on: ubuntu-latest
    
    steps:
    - name: Deploy to server
      uses: appleboy/ssh-action@v1.0.3
      with:
        host: ${{ secrets.SERVER_IP }}
        username: azureuser
        key: ${{ secrets.SSH_PRIVATE_KEY }}
        script: |
          # Automated deployment script
          # - Stops Django server
          # - Pulls latest changes
          # - Updates dependencies
          # - Runs migrations
          # - Collects static files
          # - Restarts server

๐Ÿ“Š What Gets Deployed

Azure Resources Created

  • โœ… Resource Group with your specified name
  • โœ… Virtual Network with proper subnets
  • โœ… Ubuntu 22.04 LTS VM with your chosen size
  • โœ… Public IP with static allocation
  • โœ… Security Groups (SSH, HTTP, HTTPS, 8000)
  • โœ… Auto-shutdown schedule (saves costs)

Application Stack

  • โœ… Nginx as reverse proxy with rate limiting
  • โœ… Gunicorn/Uvicorn as WSGI/ASGI server
  • โœ… Supervisor for process management
  • โœ… Virtual environment isolation
  • โœ… Comprehensive logging system
  • โœ… Auto-restart on failures

๐Ÿ› ๏ธ Customization

Terraform Template

You can customize the Azure infrastructure by editing:

/Providers/azureProvider.go

The template includes:

  • VM size configuration
  • Security group rules
  • Network settings
  • Storage options
  • Auto-shutdown policies

Supported Configurations

  • VM Sizes: Standard_B1s, Standard_B2s, Standard_D2s_v3, etc.
  • Regions: East US, West Europe, Southeast Asia, etc.
  • Storage: Standard_LRS, Premium_LRS
  • Auto-shutdown: Configurable time and timezone

โš ๏ธ Important Notes

Security & Monitoring

โš ๏ธ IMPORTANT: This tool provisions real Azure resources that incur costs. It is your responsibility to:

  • Monitor your Azure spending and usage
  • Configure appropriate security settings for production use
  • Review and test deployments before using in production
  • Regularly update and patch your deployed applications
  • Monitor application logs and performance

Best Practices

  • Resource Management: Use auto-shutdown to control costs
  • Security: Restrict SSH access to your IP range in production
  • Monitoring: Set up Azure Monitor and alerts
  • Backups: Configure regular database backups
  • SSL: Add SSL certificates for production domains

๐Ÿ› Troubleshooting

Common Issues

Q: Terraform fails with authentication error

# Ensure you're logged into Azure CLI
az login
az account show  # Verify correct subscription

Q: Ansible connection timeout

# Check if VM is running and SSH is accessible
ssh -i azure_vm_key azureuser@<vm-ip>

Q: Django app not starting

# Check supervisor logs
sudo supervisorctl status django-server
sudo tail -f /home/azureuser/logs/django-server-stderr.log

Q: GitHub Actions workflow fails

# Verify SSH key is properly added to secrets
# Check if repository has proper permissions

Deployment Logs

Monitor real-time deployment progress through the React frontend:

  • Terraform execution logs
  • Ansible playbook progress
  • Application startup status
  • Error messages and troubleshooting hints

๐Ÿค Contributing

We welcome contributions! Areas for improvement:

  • Multi-cloud support (AWS, GCP)
  • Database automation (PostgreSQL, MySQL setup)
  • SSL certificate automation
  • Monitoring dashboard integration
  • Backup automation

๐Ÿ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ”— Useful Commands

# Check VM status
az vm show -g <resource-group> -n <vm-name> --show-details

# SSH into deployed VM
ssh -i azure_vm_key azureuser@<public-ip>

# Monitor Django application
sudo supervisorctl status django-server
sudo tail -f /home/azureuser/logs/django-server-stdout.log

# Check Nginx status
sudo systemctl status nginx
sudo nginx -t  # Test configuration

Made with โค๏ธ by Django developers, for Django developers

๐Ÿš€ Get Started โ€ข ๐Ÿ› Report Issues โ€ข ๐Ÿ’ก Request Features

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published