How javithnaseem-j/laneiq works
1. What this repo is
LANEIQ is an optimization pipeline, not just an API. It takes a free-text freight shipment brief, turns it into structured shipment data, runs a multi-agent planning workflow, solves a vehicle routing problem, checks exceptions, and returns a JSON result plus a dashboard view.
2. Primary runtime shape
The system is split into three user-facing surfaces:
- FastAPI backend in api/ for programmatic optimization requests and status polling
- Streamlit dashboard in dashboard/ for human review and analytics
- Async task worker in src/tasks/ using Celery, with Redis as the queue/broker per the README
3. Core request flow
The main business flow starts with a shipment brief. The brief is parsed by the agent pipeline in src/agents/, then passed to routing/optimization in src/solver/, then checked for exceptions in src/agents/exception.py and related modules, and finally formatted into a response schema in api/schemas/. The README’s diagram shows the optimization result as the final output artifact.
4. Agent orchestration boundary
src/agents/ is the decision-making layer. It contains separate nodes for planning, route construction, exception handling, report generation, and graph/state management. This is the boundary where LLM-driven or rule-driven orchestration happens before the solver is called.
5. Optimization and solver boundary
src/solver/ is the deterministic optimization layer. It contains:
- a greedy baseline
- constraint modeling
- VRP / CVRPTW solve logic
- staged optimization helpers
This is the part that materially affects the architecture because it is the cost-optimization engine and the source of the business metric improvements reported in the README.
6. Data and external inputs
src/data/ handles synthetic generation, validation, and a vessel ETA/API integration. That implies two kinds of input: generated training/evaluation data and live/external shipping data used during exception checks or route feasibility checks.
7. API layer and async execution
api/main.py plus the routers in api/routers/ expose the service contract. The router split suggests:
- health/status endpoints for operational checks
- optimize endpoint for submission
- status endpoint for async result polling
api/middleware/rate_limit.py adds a request-boundary control, so the API is not just a pass-through; it enforces usage limits and likely protects expensive optimization runs.
8. Output contracts
The Pydantic schemas in api/schemas/ define the stable architecture boundary between solver/agents and external callers. shipment.py and result.py indicate a strict input/output contract for shipment briefs and optimization results.
9. Dashboard role
The Streamlit app in dashboard/ is a separate consumer of the backend, not part of the core optimization path. Its pages are organized around the operational workflow:
- shipment submission
- route map
- cost comparison
- exception monitoring
- drift reporting
dashboard/utils/api_client.py shows it talks to the API rather than directly to solver internals.
10. MLOps and reproducibility
This repo has a strong experiment/reproducibility layer:
- pipelines/dvc.yaml and pipelines/params.yaml define the data/solve/evaluate pipeline
- mlruns/ stores MLflow tracking and model artifacts
- .dvc_remote/ is the remote artifact store
This means optimization runs are tracked as experiments, not just executed ad hoc.
11. Monitoring and model/data health
src/monitoring/drift.py plus the README’s Evidently/CloudWatch mention show a monitoring path for detecting data drift after deployment. This is a separate control plane from request processing: it watches the behavior of incoming shipment distributions and feeds alarms/alerts.
12. Operational deployment boundary
The docker/ directory and GitHub Actions workflows indicate containerized deployment with CI/CD. There are distinct Dockerfiles for API and dashboard, and docker-compose.yml ties together the runtime pieces. The README also indicates Redis, ECR, and EC2 as deployment targets/components.
13. Testing and validation
tests/unit/ and tests/integration/ reflect two validation layers:
- unit tests for generator, schemas, state, vessel API, VRP logic
- integration tests for API and agent graph behavior
tests/locustfile.py adds load testing, which matters because optimization requests can be expensive and asynchronous.
14. Engineering support modules
config/settings.py and config/agents.py centralize runtime configuration for the app and agents. benchmarks/performance.py measures solver/runtime characteristics. Together they support tuning, benchmarking, and environment-specific deployment without changing the core routing logic.
15. How to draw the architecture
A good diagram would show four main zones:
- external users and shipment brief input
- API/dashboard edge layer
- async agent + solver core
- MLOps/monitoring/storage sidecar systems
The most important arrows are: brief submission → async task/API → agent graph → VRP solver → exception/report generation → structured result, with experiment tracking and drift monitoring branching off the solve/eval path.
Main entry points: main.py API app · api_client.py API client · vrp.py VRP solver · route.py Route agent
Components 34
User Surfaces
External entrypoints for submission, review, and polling.
- Shipment brief · Free-text freight shipment request provided by a user or client.
- API app · Main backend application entrypoint for optimization requests.
api/main.py - Optimize API · Submits shipment briefs into the async optimization workflow.
api/routers/optimize.py - Status API · Exposes async job status and result retrieval.
api/routers/status.py - Health API · Operational health and readiness checks for the backend.
api/routers/health.py - Rate limit · Request-boundary control protecting expensive optimization runs.
api/middleware/rate_limit.py - Dashboard · Human-facing review and analytics interface.
dashboard/app.py - API client · Dashboard helper that talks to the FastAPI service.
dashboard/utils/api_client.py - Submit page · Shipment submission workflow in the dashboard.
dashboard/pages/01_submit_shipment.py - Route map · Route visualization and operational review page.
dashboard/pages/02_route_map.py - Cost compare · Compares baseline and optimized routing cost.
dashboard/pages/03_cost_comparison.py - Exception monitor · Monitors detected exceptions and operational issues.
dashboard/pages/04_exception_monitor.py - Drift report · Shows data drift and monitoring signals.
dashboard/pages/05_drift_report.py
Optimization Core
Agent orchestration and deterministic routing engine.
- Task worker · Async execution boundary for optimization and evaluation tasks.
src/tasks/celery_app.py - Planner · Orchestrates the agent workflow from brief to route plan.
src/agents/planner.py - Route agent · Constructs candidate routes and coordinates routing decisions.
src/agents/route.py - State graph · Shared workflow state and graph management for the agent pipeline.
src/agents/graph.py - Exception agent · Checks feasibility and flags exceptions after optimization.
src/agents/exception.py - Report agent · Formats the final optimization narrative and summary output.
src/agents/report.py - Baseline · Greedy reference solution used for comparison and staging.
src/solver/baseline.py - Constraints · Business and route constraints used by the solver.
src/solver/constraints.py - VRP solver · Deterministic vehicle routing optimization engine.
src/solver/vrp.py - Optimize stage · Staged optimization helpers and solve orchestration.
src/solver/optimise.py - Solve stage · Pipeline stage wrapper around the core solve logic.
src/solver/solve_stage.py
Data & Ops
Data generation, monitoring, tracking, and deployment support.
- Generator · Synthetic shipment and routing data generation.
src/data/generator.py - Validator · Data and shipment validation boundary.
src/data/validator.py - Vessel API · Live vessel ETA or shipping data integration.
src/data/vessel_api.py - Transform · Feature preparation for downstream solve or evaluation steps.
src/features/transform.py - Drift monitor · Data drift detection for deployed shipment distributions.
src/monitoring/drift.py - Eval stage · Asynchronous evaluation and benchmarking stage.
src/tasks/eval_stage.py - Settings · Central application and environment settings.
config/settings.py - Agent config · Central configuration for agent behavior and prompts.
config/agents.py
Contracts
Stable request and response schemas exposed by the API.
- Shipment schema · Pydantic contract for shipment brief inputs.
api/schemas/shipment.py - Result schema · Pydantic contract for optimization results.
api/schemas/result.py
Connections 36
- Shipment brief → Optimize API: submit · User submits a freight brief to the optimization endpoint.
- Optimize API → Rate limit: guard · Requests are filtered before expensive execution.
- Rate limit → API app: enter · Accepted requests reach the backend application.
- API app → Shipment schema: validate · Incoming payloads are validated against request contracts.
- API app → Task worker: enqueue · Optimization jobs are dispatched to async execution.
- Status API → Task worker: poll · Clients poll worker-backed job status and results.
- Health API → API app: check · Health endpoints expose service readiness.
- Task worker → Planner: orchestrate · The worker starts the agent planning workflow.
- Planner → State graph: manage · Planning updates the shared workflow state.
- State graph → Route agent: drive · Workflow state guides route construction.
- Route agent → Baseline: compare · Constructed plans are compared against a greedy baseline.
- Route agent → Constraints: bound · Route generation is constrained by business rules.
- Route agent → VRP solver: solve · Candidate routing problems are sent to the VRP engine.
- Baseline → Optimize stage: seed · Baseline output seeds staged optimization and comparison.
- Constraints → VRP solver: constrain · Constraint model shapes the routing solve.
- Optimize stage → Solve stage: stage · Higher-level optimization delegates into solve stages.
- Solve stage → VRP solver: run · Solve stage executes the deterministic routing solver.
- VRP solver → Exception agent: check · Solved routes are reviewed for operational exceptions.
- Exception agent → Report agent: summarize · Exceptions are incorporated into the final narrative.
- Report agent → Result schema: format · Final outputs are normalized to the response contract.
- VRP solver → Result schema: emit · Optimized routes are serialized as structured results.
- Generator → Validator: verify · Generated data is validated for experiments and tests.
- Validator → Transform: prepare · Validated records are transformed into model-ready features.
- Vessel API → Exception agent: feed · External vessel data informs exception and feasibility checks.
- Transform → Eval stage: evaluate · Prepared features feed evaluation and benchmark tasks.
- Eval stage → Drift monitor: observe · Evaluation outputs help monitor behavior changes over time.
- Settings → API app: configure · Runtime settings configure the backend.
- Settings → Task worker: configure · Worker behavior is driven by shared configuration.
- Agent config → Planner: configure · Agent orchestration uses centralized agent settings.
- Dashboard → API client: uses · The dashboard accesses backend services through a client.
- API client → API app: call · Dashboard pages call the API rather than solver internals.
- Submit page → API client: submit · Shipment submission page invokes the backend client.
- Route map → API client: fetch · Route view pulls optimization results from the backend.
- Cost compare → API client: fetch · Cost comparison reads structured result data.
- Exception monitor → API client: fetch · Exception monitoring consumes backend output.
- Drift report → Drift monitor: display · Drift reporting surfaces monitoring signals.