How rishab-bansal/backend works
This is a FastAPI web application for interactive cart-pendulum simulations, with LQR, sliding-mode, and uncontrolled strategies and a browser canvas display. The main workflow is to open a strategy page, start a simulation, compute the system evolution, stream state updates over a WebSocket, and render them. The README is empty; route and simulation wiring are supported by sampled source, while some template-to-script connections are inferred only from the file tree and are left out.
Main entry points: main.py FastAPI app · loop.py Simulation loop · main.js WebSocket client · controller.py Control strategies
Components 11
Web interface
- FastAPI app
main.py - Home page
templates/home.html - Strategy pages
templates/projects/self_balance - WebSocket client
static/script/main.js - Display state
static/script/sb_state.js - Canvas renderer
static/script/sb.js
Simulation runtime
- Simulation loop
projects/pend_on_cart/loop.py - Simulation plot
projects/pend_on_cart/loop.py
Control and physics
- Control strategies
projects/pend_on_cart/controller.py - Pendulum model
projects/pend_on_cart/system.py
Other components
- Visitor
Connections 14
- Visitor → FastAPI app: opens pages
- FastAPI app → Home page: renders
- FastAPI app → Strategy pages: renders
- Visitor → WebSocket client: starts simulation
- WebSocket client → FastAPI app: sends context
- FastAPI app → Simulation loop: dispatches simulation
- Simulation loop → Control strategies: selects strategy
- Control strategies → Pendulum model: queries dynamics
- Simulation loop → Pendulum model: creates model
- Simulation loop → FastAPI app: sends state updates
- FastAPI app → WebSocket client: delivers updates
- WebSocket client → Display state: updates state
- Canvas renderer → Display state: reads state
- Simulation loop → Simulation plot: plots results