Local Development Setup
This guide covers setting up UIP - Urban Intelligence Platform for local development without Docker.
π― Overviewβ
Local development allows for:
- Faster iteration with hot-reload
- Direct debugging in your IDE
- Easier access to logs and breakpoints
- Customizable development environment
π Prerequisitesβ
Ensure you have installed:
- Python 3.9+
- Node.js 18+
- Git
- MongoDB (local or Docker)
- Neo4j (local or Docker)
- Redis (local or Docker)
See Prerequisites for detailed installation instructions.
π Backend Setupβ
1. Clone Repositoryβ
git clone https://github.com/UIP-Urban-Intelligence-Platform/UIP-Urban_Intelligence_Platform.git
cd UIP-Urban_Intelligence_Platform
2. Create Virtual Environmentβ
# Create virtual environment
python -m venv venv
# Activate (Windows)
venv\Scripts\activate
# Activate (macOS/Linux)
source venv/bin/activate
3. Install Dependenciesβ
# Install in development mode
pip install -e .
# Or install from requirements
pip install -r requirements/dev.txt
4. Configure Environmentβ
Create .env file in project root:
# Application
APP_ENV=development
DEBUG=true
# API Configuration
API_HOST=127.0.0.1
API_PORT=8001
# Database URLs
MONGO_URI=mongodb://localhost:27017/hcmc_traffic_dev
NEO4J_URI=bolt://localhost:7687
NEO4J_USER=neo4j
NEO4J_PASSWORD=password
# Redis
REDIS_URL=redis://localhost:6379
# Context Broker
STELLIO_URL=http://localhost:8080
FUSEKI_URL=http://localhost:3030
5. Start Backend Serverβ
# Using uvicorn (recommended for development)
uvicorn src.api.main:app --reload --host 127.0.0.1 --port 8001
# Or using the main script
python main.py
The API will be available at http://localhost:8001.
6. Verify Backendβ
# Health check
curl http://localhost:8001/health
# API documentation
open http://localhost:8001/docs
π Frontend Setupβ
1. Navigate to Frontend Directoryβ
cd apps/traffic-web-app/frontend
2. Install Dependenciesβ
# Using npm
npm install
# Or using yarn
yarn install
3. Configure Environmentβ
Create .env file in frontend directory:
VITE_API_URL=http://localhost:8001
VITE_WS_URL=ws://localhost:8001/ws
4. Start Development Serverβ
# Using npm
npm run dev
# Or using yarn
yarn dev
The frontend will be available at http://localhost:5173.
ποΈ Database Setupβ
Start Infrastructure with Dockerβ
The easiest way to run databases locally:
# Start only databases
docker-compose up -d mongo neo4j redis
# Verify
docker-compose ps
Manual Database Setupβ
MongoDBβ
# Install MongoDB (Ubuntu)
sudo apt-get install -y mongodb
# Start service
sudo systemctl start mongodb
# Verify
mongosh --eval "db.version()"
Neo4jβ
# Download and extract Neo4j
# From: https://neo4j.com/download/
# Start Neo4j
./bin/neo4j start
# Access browser: http://localhost:7474
Redisβ
# Install Redis (Ubuntu)
sudo apt-get install redis-server
# Start service
sudo systemctl start redis
# Verify
redis-cli ping
# Should return: PONG
π Development Workflowβ
Typical Development Sessionβ
# 1. Start databases (if using Docker)
docker-compose up -d mongo neo4j redis fuseki stellio
# 2. Activate Python environment
source venv/bin/activate # Linux/macOS
# or
venv\Scripts\activate # Windows
# 3. Start backend (terminal 1)
uvicorn src.api.main:app --reload --host 127.0.0.1 --port 8001
# 4. Start frontend (terminal 2)
cd apps/traffic-web-app/frontend
npm run dev
Running Testsβ
# Backend tests
pytest
# Frontend tests
cd apps/traffic-web-app/frontend
npm test
Code Formattingβ
# Python (backend)
black src/
ruff check --fix src/
# TypeScript (frontend)
cd apps/traffic-web-app/frontend
npm run lint
npm run format
π Debuggingβ
Backend Debugging (VS Code)β
Add to .vscode/launch.json:
{
"version": "0.2.0",
"configurations": [
{
"name": "Python: FastAPI",
"type": "python",
"request": "launch",
"module": "uvicorn",
"args": ["src.api.main:app", "--reload", "--port", "8001"],
"jinja": true,
"justMyCode": false
}
]
}
Frontend Debugging (VS Code)β
Add to .vscode/launch.json:
{
"name": "Chrome: Frontend",
"type": "chrome",
"request": "launch",
"url": "http://localhost:5173",
"webRoot": "${workspaceFolder}/apps/traffic-web-app/frontend/src"
}
β οΈ Common Issuesβ
Port Already in Useβ
# Find process
lsof -i :8001 # Linux/macOS
netstat -ano | findstr :8001 # Windows
# Kill process
kill -9 <PID> # Linux/macOS
taskkill /PID <PID> /F # Windows
Python Module Not Foundβ
# Ensure virtual environment is activated
which python # Should show venv path
# Reinstall dependencies
pip install -e .
Database Connection Refusedβ
# Check if database is running
docker-compose ps
# Restart database
docker-compose restart mongo
π Next Stepsβ
- Docker Setup - Production deployment with Docker
- Environment Configuration - Advanced configuration
- Development Guide - Coding standards and workflow
Need help? Check the Troubleshooting Guide or open an issue.