# leonardo-develop/rally architecture

> Architecture diagram of the GitHub repository leonardo-develop/rally, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/leonardo-develop/rally
- Repository: https://github.com/leonardo-develop/rally

## Overview

Rally is a gamer-community web prototype whose main workflow is account registration or login, followed by a community lobby interface and a protected gaming-assistant chat. The backend validates requests, issues JWTs, persists users in a SQL database, and sends chat prompts to Gemini. The lobby and friends experience is represented in the frontend; the README describes a community lobby UI, but the available evidence does not establish a live lobby backend. Edges reflect shown calls and documented capabilities; no unsampled implementation details are assumed.

Main entry points: [`routers/auth.py`](https://github.com/leonardo-develop/rally/blob/main/routers/auth.py) (Auth endpoints), [`routers/ai_chat.py`](https://github.com/leonardo-develop/rally/blob/main/routers/ai_chat.py) (Chat endpoint), [`frontend/src/App.jsx`](https://github.com/leonardo-develop/rally/blob/main/frontend/src/App.jsx) (App shell), [`auth.py`](https://github.com/leonardo-develop/rally/blob/main/auth.py) (JWT and passwords)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Community frontend"]
  node_app["App shell<br/>[App.jsx]"]
  node_auth_ui["Sign-in UI<br/>[Auth.jsx]"]
  node_lobbies["Lobby interface<br/>[LobbyList.jsx]"]
  node_chat_ui["Chat widget<br/>[AIChatWidget.jsx]"]
end

subgraph group_api["API and routing"]
  node_api_app["FastAPI app<br/>[main.py]"]
  node_auth_routes["Auth endpoints<br/>[auth.py]"]
  node_chat_route["Chat endpoint<br/>[ai_chat.py]"]
  node_request_models["API schemas<br/>[schemas.py]"]
end

subgraph group_identity["Identity and data"]
  node_auth_logic["JWT and passwords<br/>[auth.py]"]
  node_user_model["User model<br/>[models.py]"]
  node_database[("SQL database<br/>[database.py]")]
end

subgraph group_assistant["AI assistant"]
  node_gemini{{"Gemini service"}}
end

node_player(("Player"))

node_player -->|"uses"| node_app
node_app -->|"renders"| node_auth_ui
node_app -->|"renders"| node_lobbies
node_app -->|"renders"| node_chat_ui
node_auth_ui -->|"submits credentials"| node_auth_routes
node_chat_ui -->|"posts prompt"| node_chat_route
node_api_app -->|"registers router"| node_auth_routes
node_api_app -->|"registers router"| node_chat_route
node_api_app -->|"creates tables"| node_database
node_auth_routes -->|"hashes and issues tokens"| node_auth_logic
node_auth_routes -->|"queries users"| node_database
node_auth_routes -->|"reads and writes"| node_user_model
node_auth_routes -->|"validates and returns"| node_request_models
node_auth_logic -->|"loads user session"| node_database
node_auth_logic -->|"loads user"| node_user_model
node_user_model -->|"uses declarative base"| node_database
node_chat_route -->|"requires user token"| node_auth_logic
node_chat_route -->|"validates and returns"| node_request_models
node_chat_route -->|"generates response"| node_gemini

click node_app "https://github.com/leonardo-develop/rally/blob/main/frontend/src/App.jsx"
click node_auth_ui "https://github.com/leonardo-develop/rally/blob/main/frontend/src/components/Auth.jsx"
click node_lobbies "https://github.com/leonardo-develop/rally/blob/main/frontend/src/components/LobbyList.jsx"
click node_chat_ui "https://github.com/leonardo-develop/rally/blob/main/frontend/src/components/AIChatWidget.jsx"
click node_api_app "https://github.com/leonardo-develop/rally/blob/main/main.py"
click node_auth_routes "https://github.com/leonardo-develop/rally/blob/main/routers/auth.py"
click node_chat_route "https://github.com/leonardo-develop/rally/blob/main/routers/ai_chat.py"
click node_request_models "https://github.com/leonardo-develop/rally/blob/main/schemas.py"
click node_auth_logic "https://github.com/leonardo-develop/rally/blob/main/auth.py"
click node_user_model "https://github.com/leonardo-develop/rally/blob/main/models.py"
click node_database "https://github.com/leonardo-develop/rally/blob/main/database.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_auth_ui,node_lobbies,node_chat_ui toneBlue
class node_api_app,node_auth_routes,node_chat_route,node_request_models toneAmber
class node_auth_logic,node_user_model,node_database toneMint
class node_gemini toneRose
class node_player toneIndigo
```

## Components

### Community frontend

- [App shell](https://github.com/leonardo-develop/rally/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Sign-in UI](https://github.com/leonardo-develop/rally/blob/main/frontend/src/components/Auth.jsx): `frontend/src/components/Auth.jsx`
- [Lobby interface](https://github.com/leonardo-develop/rally/blob/main/frontend/src/components/LobbyList.jsx): `frontend/src/components/LobbyList.jsx`
- [Chat widget](https://github.com/leonardo-develop/rally/blob/main/frontend/src/components/AIChatWidget.jsx): `frontend/src/components/AIChatWidget.jsx`

### API and routing

- [FastAPI app](https://github.com/leonardo-develop/rally/blob/main/main.py): `main.py`
- [Auth endpoints](https://github.com/leonardo-develop/rally/blob/main/routers/auth.py): `routers/auth.py`
- [Chat endpoint](https://github.com/leonardo-develop/rally/blob/main/routers/ai_chat.py): `routers/ai_chat.py`
- [API schemas](https://github.com/leonardo-develop/rally/blob/main/schemas.py): `schemas.py`

### Identity and data

- [JWT and passwords](https://github.com/leonardo-develop/rally/blob/main/auth.py): `auth.py`
- [User model](https://github.com/leonardo-develop/rally/blob/main/models.py): `models.py`
- [SQL database](https://github.com/leonardo-develop/rally/blob/main/database.py): `database.py`

### AI assistant

- **Gemini service**

### Other components

- **Player**

## Connections

- Player → App shell: uses (evidence: `frontend/src/App.jsx`)
- App shell → Sign-in UI: renders (evidence: `frontend/src/App.jsx`)
- App shell → Lobby interface: renders (evidence: `frontend/src/App.jsx`)
- App shell → Chat widget: renders (evidence: `frontend/src/App.jsx`)
- Sign-in UI → Auth endpoints: submits credentials (evidence: `frontend/src/components/Auth.jsx`)
- Chat widget → Chat endpoint: posts prompt (evidence: `frontend/src/components/AIChatWidget.jsx`)
- FastAPI app → Auth endpoints: registers router (evidence: `main.py`)
- FastAPI app → Chat endpoint: registers router (evidence: `main.py`)
- FastAPI app → SQL database: creates tables (evidence: `main.py`)
- Auth endpoints → JWT and passwords: hashes and issues tokens (evidence: `routers/auth.py`)
- Auth endpoints → SQL database: queries users (evidence: `routers/auth.py`)
- Auth endpoints → User model: reads and writes (evidence: `routers/auth.py`)
- Auth endpoints → API schemas: validates and returns (evidence: `routers/auth.py`)
- JWT and passwords → SQL database: loads user session (evidence: `auth.py`)
- JWT and passwords → User model: loads user (evidence: `auth.py`)
- User model → SQL database: uses declarative base (evidence: `models.py`)
- Chat endpoint → JWT and passwords: requires user token (evidence: `routers/ai_chat.py`)
- Chat endpoint → API schemas: validates and returns (evidence: `routers/ai_chat.py`)
- Chat endpoint → Gemini service: generates response (evidence: `routers/ai_chat.py`)
