ClearWake Routing is a B2B API platform designed for logistics companies and cargo fleet operators. The system is an intelligent engine for calculating optimal maritime routes, reducing carbon emissions by utilizing favorable ocean currents and dynamically avoiding protected ecological zones.
- Python 3.11+
- MongoDB running locally on port 27017
- Clone the repository
git clone <https://github.com/TUES-2026-PBL-11-klas/Bees_Project_2>
cd Bees_Project_2- Create and activate a virtual environment
python3 -m venv venv
source venv/bin/activate # Mac/Linux
venv\Scripts\activate # Windows- Install dependencies
pip install -r requirements.txt- Install pre-commit hooks
pip install pre-commit
pre-commit install- Set up environment variables
cp .env.example .envThen open .env and fill in your values.
- Run the application
uvicorn src.main:app --reload --port 8080docker-compose up --build -dAPI will be available at http://localhost:8080/docs
Run the bootstrap script once to create indexes and seed demo records:
python -m src.infrastructure.database.bootstrapIf you are running with Docker Compose, execute it inside the app container:
docker-compose exec app python -m src.infrastructure.database.bootstrapThe script is idempotent and can be re-run safely.
- Open the API docs http://localhost:8080/docs
The map page uses a free CARTO basemap through Leaflet.
- Set the style in
.env:
MAP_PROVIDER=carto-voyager- Restart the app:
docker-compose up --build -d- Open the map page: http://localhost:8080/map
Notes:
carto-voyagergives the best default visual style.carto-positronis a lighter alternative if you want a cleaner look.- The route and zone overlays still come from the app itself.
The API ships with JWT-based auth and role-based access control (admin / operator / viewer).
- Bootstrap the first admin for a company:
curl -X POST http://localhost:8080/api/v1/auth/bootstrap-admin \
-H "Content-Type: application/json" \
-d '{"company_id": "<oid>", "email": "you@example.com", "password": "supersecret", "role": "admin"}'- Log in to get a bearer token:
curl -X POST http://localhost:8080/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"email": "you@example.com", "password": "supersecret"}'- Call protected endpoints with
Authorization: Bearer <token>. Use/api/v1/auth/meto verify.
Set JWT_SECRET in .env to a long random value in any non-dev environment.
The platform is multi-tenant: a company has an admin (the master account),
operator and viewer sub-accounts. Admins manage staff through
/api/v1/auth/users; operators can move ships; viewers can only look.
Live tracking. POST /api/v1/vessels/{id}/position ingests AIS/GPS fixes.
Each one appends to the vessel's track, updates the fleet view, and is pushed
to that company's dashboards over ws://…/ws/ai/notifications. Fixes implying
an impossible speed are rejected rather than stored, so one bad report cannot
corrupt a track or the routes planned from it. Track history ages out after 30
days via a TTL index.
Course control. POST /api/v1/vessels/{id}/course plots a route from where
the vessel actually is to a named port, stores it, writes an audit entry and
notifies the fleet. Restricted to admins and operators.
Automatic rerouting. Closing a zone re-plans every voyage already sailing through it. Close the Suez Canal and the ships committed to it are recomputed around the Cape, with the operator told which ones moved and which could not be routed at all.
Zones. Twelve chokepoint presets (Suez, Panama, Hormuz, Bab-el-Mandeb,
Malacca, Gulf of Aden…) mean closing a passage is one click rather than a
hand-drawn polygon, and POST /api/v1/zones/circle closes a radius around a
point. Zones with no company_id are shared — official closures and imported
hazards, editable only by an admin; a company's own zones are private to it.
Real hazard data. POST /api/v1/zones/import/nga pulls live navigational
warnings from NGA Maritime Safety Information — piracy,
live firing, wrecks, drifting hazards — parses the positions out of the warning
text and buffers them into keep-clear circles, classified by what the warning
says. POST /api/v1/zones/import/marine-regions imports maritime boundary
polygons from Marine Regions. Both are free and
need no key; imports are idempotent and land inactive so nothing reroutes
before a human has looked.
Weather. Conditions are graded on the Beaufort and Douglas scales. A vessel
with an engine is penalised by severe weather; a vessel without one is
blocked by it, because it may be unable to steer clear. Wind-assisted cargo
ships carry propulsion and are treated as motorised. See
src/core/weather_safety.py.
Vessel types. 60 types under conventional trade names across ten categories, each declaring its fuel multiplier and propulsion. Four are engineless sail; one is wind-assisted.
SEED_ADMIN_PASSWORD='choose-one' venv/bin/python scripts/seed_demo_fleet.pyCreates one company, three sub-accounts and a 38-vessel fleet scattered across real trading areas. Re-running is safe. Omit the variable and a password is generated and printed once.
The platform has an in-process task queue for GRIB ingest, analytics rollups, AI reroutes, and weather refresh. Admins can enqueue jobs by name and inspect their state:
curl -X POST http://localhost:8080/api/v1/jobs/grib_ingest \
-H "Authorization: Bearer <admin_token>" \
-H "Content-Type: application/json" \
-d '{"path": "/data/currents.grib2"}'Production deployments can swap the in-process implementation for an RQ + Redis backend; the TaskQueue interface (src/infrastructure/queue/task_queue.py) is the only thing that needs to change.
See docs/architecture.md for the module map, class diagrams (routing, AI, auth/tenancy), sequence diagrams (route calculation, JWT login, background jobs), and deployment topology.
Run strategy-only tests:
pytest -q tests/unit/test_strategy.pyRun all unit tests:
pytest -q tests/unitRun the full suite with coverage:
pytest --cov=src --cov-report=term tests/pre-commit run --all-files