Advanced traffic prediction and urban mobility analytics for Barranquilla, Colombia
VíaBaq is a production-ready urban mobility platform that combines real-time geospatial data, historical analytics, and machine learning to optimize traffic flow in Barranquilla. The system provides:
- Real-time traffic monitoring with WebSocket updates
- Weather-aware predictions considering Barranquilla's flood-prone zones (arroyos)
- Advanced analytics with 4,000+ historical data points
- ML-ready architecture for predictive modeling
- High-performance API with Redis caching and background jobs
- Interactive map with real-time traffic visualization
- Weather-based traffic predictions
- Smart Alert System with 4 alert types (arroyo floods, congestion, weather impact, events)
- flood warnings integration
- Event-based congestion alerts
- Real-time WebSocket notifications
- 46+ RESTful API endpoints (including 5 alert endpoints)
- TypeScript strict mode (100% type-safe)
- Repository pattern architecture
- Comprehensive error handling
- Production-grade logging (Winston)
- Real-time updates (Socket.IO with Redis adapter)
- Background job processing (BullMQ) - alerts every 2 min
- 4,038 historical traffic records
- Feature-rich dataset (weather, events, rush hour)
- PostGIS geospatial queries
- Ready for ML model integration
Next.js ← Frontend (MapLibre GL + Recharts)
Frontend
HTTP/WebSocket
↓
Express API ← Backend (TypeScript + Express)
+ Socket.IO
↓ ↓
Postgres Redis ← Cache + Jobs
PostGIS BullMQ
Tech Stack:
- Frontend: Next.js 16, TypeScript, Tailwind CSS, shadcn/ui, MapLibre GL
- Backend: Node.js 22, Express, TypeScript (strict), Zod validation
- Database: PostgreSQL 15 + PostGIS 3.4
- Cache/Jobs: Redis 7.2, ioredis, BullMQ
- Real-time: Socket.IO with Redis adapter
- Logging: Winston
- Security: Helmet, CORS, Rate Limiting
- Node.js 22+ (LTS recommended)
- Docker & Docker Compose
- PostgreSQL 15+ (or use Docker)
- Redis 7+ (or use Docker)
# Clone repository
git clone https://github.com/yourusername/viabaq-node-network.git
cd viabaq-node-network
# Install dependencies
npm install
# Start infrastructure (PostgreSQL + Redis)
docker-compose up -d
# Setup backend
cd server
npm install
npm run db:migrate # Run migrations
npm run db:seed # Seed database
npm run dev # Start backend (port 4000)
# In another terminal - Setup frontend
cd ..
npm run dev # Start frontend (port 3000)Backend Health Check:
curl http://localhost:4000/healthFrontend:
Open browser → http://localhost:3000
npm run preflightSee docs/ADMIN_AUTH_AND_PREFLIGHT.md for admin session auth and smoke checks.
viabaq-node-network/
├── .github/ # CI/CD workflows
├── docs/ # All documentation
│ ├── architecture/ # System design
│ ├── guides/ # Setup & testing guides
│ ├── planning/ # Roadmap & plans
│ └── changelogs/ # Change history
├── data/ # External data files
│ └── raw/ # Raw data (not in git)
├── scripts/ # Utility scripts
│ ├── test-api.sh
│ └── setup.sh
├── server/ # Backend API
│ ├── src/
│ │ ├── api/ # Controllers, routes, middleware
│ │ ├── core/ # Services, repositories
│ │ ├── infrastructure/ # DB, cache, jobs
│ │ └── shared/ # Config, types, utils
│ ├── tests/ # Unit, integration, e2e tests
│ └── db/ # Migrations & seeds
├── src/ # Frontend (Next.js)
│ ├── app/ # Pages & layouts
│ ├── components/ # React components
│ └── hooks/ # Custom hooks
├── docker-compose.yml
└── README.md # This file
GET /api/v1/geo/zones- City zonesGET /api/v1/geo/arroyos- Flood-prone areasGET /api/v1/geo/roads- Road networkGET /api/v1/geo/pois- Points of interest
GET /api/v1/traffic/realtime- Real-time trafficGET /api/v1/traffic/summary- Traffic summaryGET /api/v1/traffic/road/:id- Road-specific traffic
GET /api/v1/weather/current- Current weatherGET /api/v1/weather/forecast- Weather forecast
GET /api/v1/analytics/traffic-patterns- Traffic patternsGET /api/v1/analytics/hotspots- Congestion hotspotsGET /api/v1/analytics/weather-impact- Weather impact
GET /api/v1/events- Urban eventsGET /api/v1/events/upcoming- Upcoming eventsPOST /api/v1/events- Create event (admin)
GET /api/v1/alerts/active- All active alertsGET /api/v1/alerts/critical- Critical alerts onlyGET /api/v1/alerts/summary- Alert statisticsGET /api/v1/alerts/by-severity/:severity- Filter by severityGET /api/v1/alerts/by-type/:type- Filter by type
See full API docs → WebSocket API → Alerts System →
# Backend tests
cd server
npm test # Run all tests
npm run test:watch # Watch mode
npm run test:coverage # Coverage report
# Frontend tests
npm test
# E2E tests
npm run test:e2e
# API integration test
bash scripts/test-api.sh- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'feat: add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
Commit Convention: We use Conventional Commits
feat:New featuresfix:Bug fixesdocs:Documentationchore:Maintenancetest:Tests
NODE_ENV=development
PORT=4000
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/viabaq_db
REDIS_URL=redis://localhost:6379
OPENWEATHER_API_KEY=your_api_key_here # OptionalNEXT_PUBLIC_API_URL=http://localhost:4000
NEXT_PUBLIC_SOCKET_URL=http://localhost:4000MIT License - see LICENSE file for details
Marcos GoO - GitHub
Built for Barranquilla's urban mobility