How deepanshugupta8772/modelswitch-chat works
ModelSwitch Chat is a React/FastAPI LLM chat application. A user submits a message through the composer; the frontend sends it to the chat route, which loads session history, checks the response cache, optionally simulates failures and attempts configured provider keys, then persists a successful exchange and returns reply metadata. The README also documents health monitoring and session-history retrieval. The backend excerpts show the orchestration and persistence boundaries; provider and cache relationships are supported by the README, while deployment details are omitted as runtime architecture.
Main entry points: routes.py Chat and history routes · App.jsx Chat application · main.py API server and health · db.py Session history
Components 15
Chat frontend
- Chat application
frontend/src/App.jsx - Message composer
frontend/src/components/Composer.jsx - Chat API client
frontend/src/api.js - Message display
frontend/src/components/Message.jsx - Reply metadata
frontend/src/components/Metadata.jsx
Backend API
- Chat and history routes
backend/app/routes.py - API server and health
backend/app/main.py - Request and response schemas
backend/app/schemas.py - Application settings
backend/app/config.py
Inference resilience
- Failure simulation
backend/app/simulate.py - Response cache
backend/app/llm.py - Provider inference
backend/app/llm.py
Session state
- Session history
backend/app/db.py
Other components
- Chat user
- LLM provider
Connections 17
- Chat user → Chat application: submits chat
frontend/src/App.jsx - Chat application → Message composer: renders
frontend/src/App.jsx - Chat application → Chat API client: sends message
frontend/src/App.jsx - Chat API client → Chat and history routes: POST /chat
README.md - Chat and history routes → Session history: loads history
backend/app/routes.py - Chat and history routes → Response cache: checks cache
backend/app/routes.py - Chat and history routes → Failure simulation: parses simulation
backend/app/routes.py - Chat and history routes → Provider inference: requests inference
backend/app/routes.py - Provider inference → LLM provider: calls model
README.md - Chat and history routes → Session history: saves exchange
backend/app/routes.py - Chat and history routes → Request and response schemas: validates and shapes
backend/app/routes.py - API server and health → Chat and history routes: registers routes
backend/app/main.py - API server and health → Session history: initializes database
backend/app/main.py - Chat and history routes → Application settings: reads settings
backend/app/routes.py - API server and health → Application settings: configures health
backend/app/main.py - Chat application → Message display: renders messages
frontend/src/App.jsx - Message display → Reply metadata: renders metadata
frontend/src/components/Message.jsx