Simulates traffic on the border bridges with realistic car queue modeling and telemetry generation.
- M/M/1 Queue Simulation: Implements queuing theory for realistic car arrival and service patterns
- Physics-Based Car Movement: Enhanced car models with acceleration, velocity limits, and realistic physics
- Realistic Telemetry Generation: Generates GPS, accelerometer, and motion data matching real mobile device sensors
- REST API: FastAPI-based server for simulation management
- Realtime Streaming: WebSocket support for live telemetry data feed
- Phone Parameters: Configurable sampling rates, sensor noise, and device orientations
- Multi-Border Support: US-Mexico and US-Canada border crossings
- Dynamic GeoJSON Loading: Support for custom border crossing geometries
- Crossing-Specific Simulation: Unique traffic patterns per border location
- Lane Switching: Realistic simulation of cars changing lanes
- Multi-Lane Queues: Support for crossings with multiple parallel lanes
- Enhanced Gyroscope Data: Rotational motion simulation during lane changes
This project uses uv
for Python package management. Install dependencies using:
uv pip install -r requirements.txt
Or add individual packages:
uv add package_name
uv run python scripts/run_api.py
The API will be available at http://localhost:8000
with interactive docs at http://localhost:8000/docs
.
All Python scripts should be run using uv
:
uv run python your_script.py
uv run python -m unittest
# Start a simulation
curl -X POST "http://localhost:8000/simulate" \
-H "Content-Type: application/json" \
-d '{
"queue_config": {
"arrival_rate": 0.5,
"service_rate": 0.8
},
"phone_config": {
"sampling_rate": 10
},
"simulation_config": {
"duration": 3600
}
}'
POST /simulate
- Start a new simulationGET /simulation/{id}/status
- Get simulation statusGET /simulation/{id}/telemetry
- Download telemetry CSVWebSocket /ws/{id}
- Realtime telemetry streaming
cascabel/
├── models/ # Core simulation models
│ ├── car.py # Enhanced car with physics
│ ├── waitline.py # Geographic path model
│ ├── queuing/ # Queue theory implementations
│ └── simulation.py # Main simulation orchestrator
├── simulation/
│ ├── telemetry/ # Sensor data generators
│ └── csv_generator.py # CSV output formatting
├── utils/
│ └── io/ # GeoJSON file handling
└── tests/ # Unit tests
api/ # FastAPI server
scripts/ # Utility scripts
raw_data/ # Real telemetry samples
- Docker and Docker Compose installed
- At least 4GB RAM available for containers
# Start both services
docker-compose up --build
# Access:
# Frontend: http://localhost:3000
# Backend API: http://localhost:8000
# Start services
docker-compose up -d
# Stop services
docker-compose down
# Rebuild
docker-compose up --build
For development with hot reload:
# Start only backend
docker-compose up backend
# Start only frontend
docker-compose up frontend
# Run tests in container
docker-compose exec backend uv run python -m unittest
- VSCode with Python and JavaScript/TypeScript extensions
- Python Debugger extension (
ms-python.debugpy
) - Chrome Debugger extension (optional)
The project includes basic debug configurations in .vscode/launch.json
:
- Debug API - Debug the Python FastAPI server
- Debug Frontend - Debug the React development server
- Debug Frontend in Chrome - Debug in Chrome browser
- Open the project in VSCode
- Go to Run and Debug (Ctrl+Shift+D)
- Select a configuration from the dropdown
- Click the green play button or press F5
Additional tasks are available in .vscode/tasks.json
:
docker-compose:up
- Start Docker servicesdocker-compose:down
- Stop Docker servicesinstall-frontend-deps
- Install npm dependenciesinstall-backend-deps
- Install Python dependenciesstart-backend
- Start backend serverstart-frontend
- Start frontend server
Test contained in cascabel/tests/
can be run using the standard python library unittest
by running the following command.
python -m unittest
The project includes comprehensive documentation in .agentic-docs/
including:
- Project analysis and MVP requirements
- API specification
- Queuing theory implementation details
- Telemetry generation methodology