--- description: "Use when editing the Python backend, FastAPI endpoints, ESI integration, or route-planning modules under backend/src. Covers service boundaries, side effects, and runtime assumptions." name: "Python Backend Boundaries" applyTo: "backend/src/**/*.py" --- # Python Backend Boundaries - Keep `backend/src/main.py` thin. Add request/response wiring there, but keep orchestration in `backend/src/manager.py`. - Keep live ESI calls, token refresh, waypoint updates, and market-window side effects inside `backend/src/esi/`. Do not introduce direct ESI `requests` calls in `graph.py`, `market.py`, `arbitrage.py`, `pathfinder.py`, or `route.py`. - Treat `Manager` as the mutable state boundary. If you add background work, keep thread and polling ownership explicit instead of spreading shared state across modules. - Preserve the current data-oriented style in the route-planning pipeline: dataclasses, module-level constants, and functions that transform orders, trades, and graph data. - The active frontend depends on `/route`, `/route_info`, `/create_route`, `/data_stream`, and `/open_market_window/{type_id}` on `http://localhost:8000`. Keep those contracts stable unless the task includes coordinated frontend changes. - ESI-backed code needs local auth and data files that are not checked in. Avoid assuming clean-room execution unless the task is specifically about environment setup.