# studycompanion1/study_companion architecture

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

- Interactive diagram: https://gitdiagram.com/studycompanion1/study_companion
- Repository: https://github.com/studycompanion1/study_companion

## Overview

Study Companion is a React/FastAPI study app. A user can register, log in, or start a guest session; after the app checks the session, the UI presents a home dashboard and collection screens. The backend provides cookie-based authentication and documented AI endpoints for analyzing uploaded study materials and generating study guides. The README describes broader study capabilities, but the sampled frontend is largely static and does not show the upload-to-analysis flow or persistent collection APIs. Edges reflect only shown calls or documented relationships.

Main entry points: [`frontend/src/App.tsx`](https://github.com/studycompanion1/study_companion/blob/dev/frontend/src/App.tsx) (App and routing), [`backend/app/auth/router.py`](https://github.com/studycompanion1/study_companion/blob/dev/backend/app/auth/router.py) (Auth endpoints), [`frontend/src/auth/api.ts`](https://github.com/studycompanion1/study_companion/blob/dev/frontend/src/auth/api.ts) (Auth API client), [`backend/app/main.py`](https://github.com/studycompanion1/study_companion/blob/dev/backend/app/main.py) (FastAPI application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_app["App and routing<br/>[App.tsx]"]
  node_authform["Sign-in form<br/>[AuthForm.tsx]"]
  node_authapi["Auth API client<br/>[api.ts]"]
  node_home["Study dashboard<br/>[Home.tsx]"]
  node_collections["Collections screens"]
  node_collectiondata["Collection data<br/>[collectionsData.ts]"]
  node_theme["Theme preferences<br/>[ThemeContext.tsx]"]
end

subgraph group_identity["Authentication"]
  node_authrouter["Auth endpoints<br/>[router.py]"]
  node_security["Password and tokens<br/>[security.py]"]
  node_authdeps["Current-user dependency<br/>[dependencies.py]"]
end

subgraph group_learning["Study materials and AI"]
  node_api["FastAPI application<br/>[main.py]"]
  node_ai["Keyword and concept extraction"]
end

subgraph group_persistence["Persistence"]
  node_models["Study and user models<br/>[group.py]"]
  node_db[("SQL database<br/>[db.py]")]
end

node_student(("Student"))
node_gemini{{"Google Gemini"}}

node_student -->|"uses"| node_app
node_app -->|"checks session"| node_authapi
node_app -->|"shows when signed out"| node_authform
node_app -->|"shows when signed in"| node_home
node_app -->|"routes collections"| node_collections
node_app -->|"provides theme"| node_theme
node_authform -->|"submits credentials"| node_authapi
node_authapi -->|"HTTP auth requests"| node_authrouter
node_collections -->|"loads collection data"| node_collectiondata
node_api -->|"registers router"| node_authrouter
node_api -->|"routes analysis"| node_ai
node_ai -->|"uses for generation"| node_gemini
node_authrouter -->|"hashes and signs"| node_security
node_authrouter -->|"uses current user"| node_authdeps
node_authrouter -->|"uses session"| node_db
node_db -->|"registers tables"| node_models

click node_app "https://github.com/studycompanion1/study_companion/blob/dev/frontend/src/App.tsx"
click node_authform "https://github.com/studycompanion1/study_companion/blob/dev/frontend/src/pages/AuthForm.tsx"
click node_authapi "https://github.com/studycompanion1/study_companion/blob/dev/frontend/src/auth/api.ts"
click node_home "https://github.com/studycompanion1/study_companion/blob/dev/frontend/src/pages/Home.tsx"
click node_collections "https://github.com/studycompanion1/study_companion/blob/dev/frontend/src/collections/CollectionsRoute.tsx"
click node_collectiondata "https://github.com/studycompanion1/study_companion/blob/dev/frontend/src/collections/collectionsData.ts"
click node_theme "https://github.com/studycompanion1/study_companion/blob/dev/frontend/src/theme/ThemeContext.tsx"
click node_authrouter "https://github.com/studycompanion1/study_companion/blob/dev/backend/app/auth/router.py"
click node_security "https://github.com/studycompanion1/study_companion/blob/dev/backend/app/auth/security.py"
click node_authdeps "https://github.com/studycompanion1/study_companion/blob/dev/backend/app/auth/dependencies.py"
click node_api "https://github.com/studycompanion1/study_companion/blob/dev/backend/app/main.py"
click node_ai "https://github.com/studycompanion1/study_companion/blob/dev/backend/ai_processing/keyword_concept_extraction.py"
click node_models "https://github.com/studycompanion1/study_companion/blob/dev/backend/app/models/group.py"
click node_db "https://github.com/studycompanion1/study_companion/blob/dev/backend/app/db.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_authform,node_authapi,node_home,node_collections,node_collectiondata,node_theme toneBlue
class node_authrouter,node_security,node_authdeps toneAmber
class node_api,node_ai toneMint
class node_models,node_db toneRose
class node_student,node_gemini toneIndigo
```

## Components

### Client experience

- [App and routing](https://github.com/studycompanion1/study_companion/blob/dev/frontend/src/App.tsx): `frontend/src/App.tsx`
- [Sign-in form](https://github.com/studycompanion1/study_companion/blob/dev/frontend/src/pages/AuthForm.tsx): `frontend/src/pages/AuthForm.tsx`
- [Auth API client](https://github.com/studycompanion1/study_companion/blob/dev/frontend/src/auth/api.ts): `frontend/src/auth/api.ts`
- [Study dashboard](https://github.com/studycompanion1/study_companion/blob/dev/frontend/src/pages/Home.tsx): `frontend/src/pages/Home.tsx`
- [Collections screens](https://github.com/studycompanion1/study_companion/blob/dev/frontend/src/collections/CollectionsRoute.tsx): `frontend/src/collections/CollectionsRoute.tsx`
- [Collection data](https://github.com/studycompanion1/study_companion/blob/dev/frontend/src/collections/collectionsData.ts): `frontend/src/collections/collectionsData.ts`
- [Theme preferences](https://github.com/studycompanion1/study_companion/blob/dev/frontend/src/theme/ThemeContext.tsx): `frontend/src/theme/ThemeContext.tsx`

### Authentication

- [Auth endpoints](https://github.com/studycompanion1/study_companion/blob/dev/backend/app/auth/router.py): `backend/app/auth/router.py`
- [Password and tokens](https://github.com/studycompanion1/study_companion/blob/dev/backend/app/auth/security.py): `backend/app/auth/security.py`
- [Current-user dependency](https://github.com/studycompanion1/study_companion/blob/dev/backend/app/auth/dependencies.py): `backend/app/auth/dependencies.py`

### Study materials and AI

- [FastAPI application](https://github.com/studycompanion1/study_companion/blob/dev/backend/app/main.py): `backend/app/main.py`
- [Keyword and concept extraction](https://github.com/studycompanion1/study_companion/blob/dev/backend/ai_processing/keyword_concept_extraction.py): `backend/ai_processing/keyword_concept_extraction.py`

### Persistence

- [Study and user models](https://github.com/studycompanion1/study_companion/blob/dev/backend/app/models/group.py): `backend/app/models/group.py`
- [SQL database](https://github.com/studycompanion1/study_companion/blob/dev/backend/app/db.py): `backend/app/db.py`

### Other components

- **Student**
- **Google Gemini**

## Connections

- Student → App and routing: uses (evidence: `frontend/src/App.tsx`)
- App and routing → Auth API client: checks session (evidence: `frontend/src/App.tsx`)
- App and routing → Sign-in form: shows when signed out (evidence: `frontend/src/App.tsx`)
- App and routing → Study dashboard: shows when signed in (evidence: `frontend/src/App.tsx`)
- App and routing → Collections screens: routes collections (evidence: `frontend/src/App.tsx`)
- App and routing → Theme preferences: provides theme (evidence: `frontend/src/App.tsx`)
- Sign-in form → Auth API client: submits credentials (evidence: `frontend/src/pages/AuthForm.tsx`)
- Auth API client → Auth endpoints: HTTP auth requests (evidence: `frontend/src/auth/api.ts`)
- Collections screens → Collection data: loads collection data (evidence: `frontend/src/collections/CollectionsRoute.tsx`)
- FastAPI application → Auth endpoints: registers router (evidence: `backend/app/main.py`)
- FastAPI application → Keyword and concept extraction: routes analysis (evidence: `backend/app/main.py`)
- Keyword and concept extraction → Google Gemini: uses for generation (evidence: `README.md`)
- Auth endpoints → Password and tokens: hashes and signs (evidence: `backend/app/auth/router.py`)
- Auth endpoints → Current-user dependency: uses current user (evidence: `backend/app/auth/router.py`)
- Auth endpoints → SQL database: uses session (evidence: `backend/app/auth/router.py`)
- SQL database → Study and user models: registers tables (evidence: `backend/app/db.py`)
