8.9 KiB
ERPNext Hanzo Deployment - LLM Context
Project Overview
This repository contains ERPNext (Open Source ERP System) configured for deployment on Hanzo (Dokploy) platform. The setup is self-initializing with Docker Compose configurations for both production and development environments.
Key Components
1. ERPNext Application
- Framework: Built on Frappe Framework
- Version: v15.62.0 (as per Docker images)
- Languages: Python (backend), JavaScript (frontend)
- Database: MariaDB 10.6
- Cache/Queue: Redis 7
2. Deployment Architecture
Services Structure
┌─────────────────────────────────────────────────┐
│ Internet │
└─────────────────────┬───────────────────────────┘
│
┌─────────────────────▼───────────────────────────┐
│ Traefik (SSL Termination) │
└─────────────────────┬───────────────────────────┘
│
┌─────────────────────▼───────────────────────────┐
│ Frontend (Nginx) - Port 8080 │
│ ┌─────────────┬──────────────┬──────────────┐ │
│ │ /socket.io/ │ /assets/ │ /* │ │
│ └──────┬──────┴───────┬──────┴──────┬───────┘ │
└─────────┼──────────────┼─────────────┼─────────┘
│ │ │
┌─────────▼────────┐ │ ┌───────▼────────┐
│ WebSocket :9000 │ │ │ Backend :8000 │
└──────────────────┘ │ └───────┬────────┘
│ │
Static Files │
│
┌───────────────────────┼───────────────────────┐
│ │ │
┌───────▼────────┐ ┌───────▼────────┐ ┌───────▼────────┐
│ MariaDB :3306 │ │ Redis Cache │ │ Redis Queue │
└────────────────┘ └────────────────┘ └────────────────┘
Key Services
-
Configurator: One-time initialization service that:
- Configures bench settings
- Creates ERPNext site
- Installs ERPNext app
- Enables scheduler
- Sets production/dev mode
-
Frontend: Nginx reverse proxy (only exposed service)
- Routes to backend, websocket, and static files
- Traefik labels for SSL/routing
- CSP headers for security
-
Backend: Frappe/ERPNext application server
-
WebSocket: Real-time communication (Socket.io)
-
Workers: Background job processors (short & long queues)
-
Scheduler: Cron-like task runner
-
Database: MariaDB for data persistence
-
Redis: Cache and job queue management
3. Environment Configuration
Required Variables (set in Hanzo UI)
DB_PASSWORD: MariaDB root passwordADMIN_PASSWORD: ERPNext Administrator password
Domains
- Production: erp.hanzo.ai
- Development: erp-dev.hanzo.ai
4. Key Features
Self-Initialization
- No manual setup required
- Configurator service handles all initialization
- Site creation automated with checks for existing sites
- Database wait loop ensures proper startup order
Security
- External
hanzo-networkfor service isolation - Traefik handles SSL/TLS termination
- CSP headers prevent XSS attacks
- HTTPS redirect enforced
- tmpfs for temporary files
Routing
- Single domain handles all services
- Frontend nginx proxies to appropriate backends
- WebSocket support with proper upgrade headers
- Static asset serving optimized
5. Development Patterns
Docker Compose Structure
- Service dependencies with health checks
- Platform specification (linux/amd64)
- Restart policies for reliability
- Volume persistence for data
- Network isolation
Traefik Integration
labels:
- "traefik.enable=true"
- "traefik.http.routers.{service}-http.rule=Host(`{domain}`)"
- "traefik.http.routers.{service}-https.tls.certresolver=letsencrypt"
- "traefik.http.services.{service}.loadbalancer.server.port=8080"
6. Deployment Process
- Set environment variables in Hanzo UI
- Upload compose file to Hanzo
- Deploy - system auto-initializes:
- Waits for database
- Creates site if not exists
- Configures all settings
- Starts all services
7. Maintenance Operations
Backup
docker exec <backend-container> bench --site <domain> backup --with-files
Updates
- Change image version in compose file
- Redeploy in Hanzo
- Migrations run automatically
Monitoring
- Check configurator logs for initialization issues
- Monitor worker queues for job processing
- Verify scheduler for cron tasks
8. File Structure
/Users/z/work/hanzo/erp/
├── compose.prod.yml # Production Docker config
├── compose.dev.yml # Development Docker config
├── docs/
│ ├── ENVIRONMENT_VARIABLES.md
│ ├── HANZO_DEPLOYMENT.md
│ └── ROUTING_ARCHITECTURE.md
├── erpnext/ # ERPNext application code
│ ├── accounts/
│ ├── assets/
│ ├── buying/
│ ├── crm/
│ ├── manufacturing/
│ ├── selling/
│ ├── stock/
│ └── ...
├── README.md
├── package.json # Node dependencies
└── pyproject.toml # Python project config
9. Technology Stack
- Backend: Python 3.10+, Frappe Framework
- Frontend: JavaScript, Vue.js (in Frappe)
- Database: MariaDB 10.6
- Cache: Redis 7
- Web Server: Nginx
- Process Manager: Bench (Frappe's CLI)
- Container Runtime: Docker
- Orchestration: Docker Compose
- Reverse Proxy: Traefik
10. Best Practices Implemented
-
12-Factor App Principles
- Config via environment variables
- Stateless services (state in DB/Redis)
- Dev/prod parity
-
Container Best Practices
- Single process per container
- Health checks for reliability
- Non-root user execution
- Minimal base images
-
Security Best Practices
- Network isolation
- Least privilege principle
- CSP headers
- HTTPS enforcement
11. Common Tasks
Access Console
docker exec -it <backend-container> bench console
Clear Cache
docker exec <backend-container> bench --site <domain> clear-cache
Run Migrations
docker exec <backend-container> bench --site <domain> migrate
12. Integration Points
- Hanzo/Dokploy: Via Docker Compose deployment
- Traefik: Via container labels for routing
- Let's Encrypt: Via Traefik for SSL certificates
- External Services: Can integrate with email, payment gateways, etc.
Notes for AI Assistants
When working with this project:
- Deployment Changes: Always update both prod and dev compose files
- Security: Never expose internal services directly
- Configuration: Use environment variables, not hardcoded values
- Initialization: Let configurator handle all setup
- Updates: Change image tags, not individual service configs
- Debugging: Check configurator logs first for setup issues
- Networking: All services must be on
hanzo-network - Routing: Frontend service handles all external traffic
This setup prioritizes simplicity and reliability for production deployments while maintaining flexibility for development environments.
Context for All AI Assistants
This file (LLM.md) is symlinked as:
.AGENTS.mdCLAUDE.mdQWEN.mdGEMINI.md
All files reference the same knowledge base. Updates here propagate to all AI systems.
Rules for AI Assistants
- ALWAYS update LLM.md with significant discoveries
- NEVER commit symlinked files (.AGENTS.md, CLAUDE.md, etc.) - they're in .gitignore
- NEVER create random summary files - update THIS file