Development Workflow
Overview
Complete guide for local development, debugging, testing, and preparing contributions for the HCMC Traffic Management System.
Prerequisites
- Node.js v20.15.0 or higher
- Python 3.9+
- Docker Desktop
- Git
- VS Code (recommended)
Initial Setup
1. Clone Repository
git clone https://github.com/UIP-Urban-Intelligence-Platform/UIP-Urban_Intelligence_Platform.git
cd UIP-Urban_Intelligence_Platform
2. Install Dependencies
# Backend dependencies
pip install -r requirements/dev.txt
# Frontend dependencies
cd apps/traffic-web-app/frontend
npm install
cd ../../..
3. Environment Configuration
# Copy environment template
cp .env.example .env
# Edit configuration
nano .env
Example .env:
# Development settings
APP_ENV=development
DEBUG=true
LOG_LEVEL=debug
# API Configuration
API_PORT=8000
API_HOST=0.0.0.0
# Database URLs
MONGO_URI=mongodb://localhost:27017/hcmc_traffic_dev
REDIS_URL=redis://localhost:6379/0
NEO4J_URI=bolt://localhost:7687
FUSEKI_URL=http://localhost:3030
STELLIO_URL=http://localhost:8080
# Development Features
HOT_RELOAD=true
ENABLE_PROFILING=true
ENABLE_DEBUG_TOOLBAR=true
🐛 Debugging Guide
Backend Debugging (Python)
VS Code Configuration for Backend
.vscode/launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: FastAPI",
"type": "python",
"request": "launch",
"module": "uvicorn",
"args": [
"src.main:app",
"--reload",
"--port", "8000"
],
"jinja": true,
"justMyCode": false
},
{
"name": "Python: Orchestrator",
"type": "python",
"request": "launch",
"program": "${workspaceFolder}/orchestrator.py",
"console": "integratedTerminal",
"justMyCode": false
},
{
"name": "Python: Single Agent",
"type": "python",
"request": "launch",
"program": "${file}",
"args": [
"--config", "config/dev_config.yaml"
]
}
]
}
Debugging with pdb
# Add breakpoint in code
import pdb; pdb.set_trace()
# Or use built-in breakpoint() (Python 3.7+)
breakpoint()
# Common pdb commands:
# n (next) - Execute next line
# s (step) - Step into function
# c (continue)- Continue execution
# p variable - Print variable
# l (list) - Show source code
# q (quit) - Quit debugger
Logging Configuration
import logging
import sys
# Configure logging
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
handlers=[
logging.StreamHandler(sys.stdout),
logging.FileHandler('logs/debug.log')
]
)
logger = logging.getLogger(__name__)
# Use in code
logger.debug('Variable value: %s', variable)
logger.info('Processing started')
logger.warning('Potential issue detected')
logger.error('Error occurred', exc_info=True)