Skip to content

nishanth-kj/NexPyRS

Repository files navigation

NexPyRS

A production-ready full-stack monorepo featuring Next.js, FastAPI, Django, Rust (Actix), Python gRPC, PostgreSQL, Jenkins CI/CD, and Traefik reverse proxy - all containerized with Docker.

πŸš€ Quick Start

Prerequisites

Getting Started

  1. Clone the repository

    git clone https://github.com/nishanth-kj/NexPyRS.git
    cd NexPyRS
  2. Start all services

    docker-compose up -d --build
  3. Access your services (see URLs below)

That's it! All services will be running and accessible through Traefik.

🌐 Service URLs

All services are accessible through Traefik reverse proxy with subdomain-based routing:

Service URL Description
Frontend http://localhost Next.js application (Port 80)
FastAPI http://api.localhost FastAPI backend with auto docs
Django Admin http://django.localhost/admin Django administration panel
PgAdmin http://pgadmin.localhost PostgreSQL database management
Jenkins http://jenkins.localhost CI/CD automation server
Traefik Dashboard http://localhost:8090 Monitor all routes and services
gRPC Service http://grpc.localhost Python gRPC service
Rust Service http://rust.localhost Actix-web microservice

πŸ” Default Credentials

PgAdmin:

  • Email: admin@nexpyrs.dev
  • Password: admin

PostgreSQL:

  • User: postgres
  • Password: password
  • Database: nexpyrs

Jenkins:

  • Get initial password:
    docker exec nexpyrs-jenkins-1 cat /var/jenkins_home/secrets/initialAdminPassword

πŸ“ Project Structure

NexPyRS/
β”œβ”€β”€ web/                    # Next.js 14 frontend
β”‚   β”œβ”€β”€ app/               # App router pages
β”‚   β”œβ”€β”€ components/        # React components
β”‚   └── Dockerfile
β”œβ”€β”€ api/                    # Python backend services
β”‚   β”œβ”€β”€ fastapi_app/       # FastAPI application
β”‚   β”œβ”€β”€ django_app/        # Django application
β”‚   β”œβ”€β”€ Dockerfile.fastapi
β”‚   └── Dockerfile.django
β”œβ”€β”€ grpcsvc/               # Python gRPC service
β”‚   β”œβ”€β”€ server.py
β”‚   └── Dockerfile
β”œβ”€β”€ rustsvc/               # Rust Actix-web service
β”‚   β”œβ”€β”€ src/
β”‚   └── Dockerfile
β”œβ”€β”€ traefik/               # Traefik configuration
β”‚   └── dynamic.yml        # Static route definitions
β”œβ”€β”€ docker-compose.yml     # Main orchestration file
└── .env.example          # Environment variables template

πŸ› οΈ Development

Local Development Setup

  1. Copy environment file

    cp .env.example .env
  2. Install Python dependencies (optional, for IDE support)

    cd api
    uv sync
  3. Install Node dependencies (optional, for IDE support)

    cd web
    npm install

Running Services Locally (Without Docker)

Frontend:

cd web
npm run dev
# Access at http://localhost:3000

FastAPI:

cd api
uv run main.py fastapi
# Access at http://localhost:8000

Django:

cd api
uv run main.py django
# Access at http://localhost:8001

Direct Port Access (For Debugging)

Uncomment the ports section in docker-compose.yml to enable direct access:

# Example for frontend:
ports:  # Uncomment for direct access (bypassing Traefik)
  - "3000:3000"

This allows accessing services directly:

  • Frontend: http://localhost:3000
  • FastAPI: http://localhost:8000
  • Django: http://localhost:8001

🐳 Docker Commands

Multi-Environment Support

This project includes specialized Docker configurations for different environments:

Environment Command Description
Development docker-compose -f docker-compose.dev.yml up -d Hot-reloading, debug mode, direct port access.
Staging docker-compose -f docker-compose.stage.yml up -d Pre-production testing with staging URLs.
Production docker-compose -f docker-compose.prod.yml up -d Hardened security, HTTPS (TLS), resource limits.

Default Start

docker-compose up -d

View logs

# All services
docker-compose logs -f

# Specific service
docker-compose logs -f frontend

Restart a service

docker-compose restart frontend

Check running containers

docker-compose ps

πŸ”§ Configuration

Environment Variables

Create a .env file in the project root (use .env.example as template):

# Project
PROJECT_NAME=NexPyRS
STACK_NAME=nexpyrs
DOMAIN=localhost

# Database
POSTGRES_SERVER=db
POSTGRES_PORT=5432
POSTGRES_USER=postgres
POSTGRES_PASSWORD=password
POSTGRES_DB=nexpyrs

# PgAdmin
PGADMIN_DEFAULT_EMAIL=admin@nexpyrs.dev
PGADMIN_DEFAULT_PASSWORD=admin

# Ports (for direct access)
FRONTEND_PORT=3000
API_PORT=8000
DJANGO_PORT=8001

Traefik Configuration

Traefik uses two configuration methods:

  1. Docker Labels (in docker-compose.yml) - For auto-discovery
  2. Static File (traefik/dynamic.yml) - For manual route definitions

The static file is used as a fallback on Windows where Docker socket access may have issues.

πŸ—οΈ Architecture

Tech Stack

Frontend:

  • Next.js 14 (React 18, App Router)
  • TailwindCSS
  • Shadcn UI
  • TypeScript

Backend:

  • FastAPI (Python 3.12) - REST API
  • Django 5.0 (Python 3.12) - Admin & ORM
  • Python gRPC - Microservices communication
  • Rust Actix-web - High-performance service

Infrastructure:

  • PostgreSQL 17 - Database
  • Traefik v3.0 - Reverse proxy & load balancer
  • Jenkins LTS - CI/CD automation
  • PgAdmin - Database management
  • Docker & Docker Compose

Traffic Flow

Browser Request
    ↓
Traefik (Port 80)
    ↓
β”œβ”€β†’ localhost              β†’ Frontend (Next.js)
β”œβ”€β†’ api.localhost          β†’ FastAPI Backend
β”œβ”€β†’ django.localhost       β†’ Django Backend
β”œβ”€β†’ pgadmin.localhost      β†’ PgAdmin
β”œβ”€β†’ jenkins.localhost      β†’ Jenkins
β”œβ”€β†’ grpc.localhost         β†’ gRPC Service
└─→ rust.localhost         β†’ Rust Service

πŸ”„ CI/CD

GitHub Actions

A CI/CD workflow is included in .github/workflows/ci.yml that:

  • Runs backend tests (FastAPI & Django)
  • Runs frontend tests (linting, build, unit tests)
  • Builds Docker images
  • Performs code quality checks (ruff, mypy)

Jenkins

Jenkins is pre-configured with Docker-in-Docker support for building and deploying containers.

First-time setup:

  1. Access http://jenkins.localhost
  2. Get password: docker exec nexpyrs-jenkins-1 cat /var/jenkins_home/secrets/initialAdminPassword
  3. Install suggested plugins
  4. Create admin user

πŸ“Š Database Management

PgAdmin Access

  1. Go to http://pgadmin.localhost
  2. Login with credentials (see above)
  3. Add server:
    • Host: db
    • Port: 5432
    • Username: postgres
    • Password: password

Direct Database Access

docker exec -it nexpyrs-db-1 psql -U postgres -d nexpyrs

πŸ§ͺ Testing

Backend Tests

cd api
uv run pytest

Frontend Tests

cd web
npm test

πŸ“ API Documentation

πŸ› Troubleshooting

Port 80 shows 404

Database connection errors

  • Wait 10-15 seconds for PostgreSQL to initialize
  • Check DB health: docker-compose ps db

Jenkins 403 Forbidden

Service not accessible

# Check if container is running
docker-compose ps

# View logs
docker-compose logs <service-name>

# Restart service
docker-compose restart <service-name>

Traefik can't discover containers (Windows)

  • The project uses static file configuration as fallback
  • Routes are defined in traefik/dynamic.yml
  • No action needed - everything should work

πŸ” Security Notes

For Production:

  1. Change all default passwords in .env
  2. Enable HTTPS in Traefik configuration
  3. Set secure database credentials
  4. Configure proper CORS settings
  5. Enable authentication on all services
  6. Review and update security headers

πŸ“š Additional Resources

🀝 Contributing

See CONTRIBUTING.md for guidelines.

πŸ“„ License

MIT License - see LICENSE file for details

πŸ‘₯ Authors


Built with ❀️ using Next.js, FastAPI, Django, Rust, and Docker

About

No description, website, or topics provided.

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published