How othmaneabder2303/smartroute works
Project Type and Purpose
• SmartRoute is a full-stack, real-time intelligent route optimization platform built as an Nx monorepo.
• It consists of:
• A frontend (Angular 17) for map-based user interaction
• A backend (Spring Boot + PostgreSQL) for business logic, authentication, data persistence
• An AI module (Flask + Python) for route optimization and traffic/time prediction
• It integrates machine learning (XGBoost, Random Forest), graph algorithms (Dijkstra, A*), external APIs (OpenWeather, OpenStreetMap via OSMnx), and OAuth2 (Google, GitHub) to deliver traffic-aware routes in Marrakech.
File Structure Analysis
• Top-level monorepo governed by Nx (nx.json, tsconfig.base.json), with global configs (.editorconfig, .gitignore, .prettierrc).
• apps/data-generating: Python script (run_sql.py) for data ingestion or DB seeding.
• apps/ml-api: Flask service with model artifacts (xgboost_model.pkl), caching, Dockerfile, requirements.txt.
• apps/opt-backend: Spring Boot service (Maven wrapper, pom.xml) under src/main/java for controllers, services, repositories, security, OAuth2, JWT utils.
• apps/opt-frontend: Angular application (package.json, tsconfig.json) under src/ for components, services, environment, styling, routing, tests.
• A cache folder at root holds persisted HTTP responses (used by ml-api).
• CI pipeline in .github/workflows/ci.yml automates build/test.
README Insights
• Confirms three-layer architecture: Frontend, Backend, AI Module.
• Details key technologies and use cases: real-time route optimization, ML based traffic/time prediction, secure JWT/OAuth2, map rendering with Leaflet.
• Mentions external data sources (OpenWeatherAPI, Hugging Face, OpenStreetMap).
a. Main Components
• User’s Web Browser
• Frontend (Angular app on localhost:4200)
• Backend API (Spring Boot at :8080)
• AI Module (Flask at :5000)
• Database (PostgreSQL)
• External Services:
– OAuth2 Providers (Google, GitHub)
– OpenWeatherAPI
– OpenStreetMap (via OSMnx)
– Hugging Face (model storage)
• Data-Generating Script (one-time DB setup)
b. Relationships & Data Flows
1. User → Frontend: HTTP(S) requests for UI and map interactions
2. Frontend ↔ Backend:
• Authentication (OAuth2 redirects → backend → external provider → callback → JWT issued)
• API calls (route requests, user profile, history) with JWT in headers
3. Backend → AI Module: REST calls to compute optimal routes and predictions
4. AI Module → External APIs:
• Fetch weather data from OpenWeatherAPI
• Query street graphs from OpenStreetMap/OSMnx
• Optionally download models from Hugging Face
5. Backend ↔ Database: CRUD via Spring Data JPA (users, events, history, places)
c. Architectural Patterns & Principles
• Layered architecture: Presentation → Business → Data
• Monorepo with Nx workspace for code sharing and unified CI
• Micro-service style separation: independent apps (frontend, backend, AI)
• Security patterns: JWT authentication, OAuth2 flow, CSRF filter
• ML service abstraction: decouple heavy computation from core API
d. Key Technologies & Frameworks
• Angular, RxJS, Leaflet, Angular Material (frontend)
• Spring Boot, Spring Security, Spring Data JPA, JWT, OAuth2 (backend)
• Flask, XGBoost, Random Forest, OSMnx, Hugging Face, caching (AI module)
• PostgreSQL, Maven, Docker, Python 3.8+, Java 17, Node.js 16+