# adlinef06/brainbuddy-ai architecture

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

- Interactive diagram: https://gitdiagram.com/adlinef06/brainbuddy-ai
- Repository: https://github.com/adlinef06/brainbuddy-ai

## Overview

BrainBuddy AI is a study assistant whose main user workflows are general Q&A, personalized study planning and quizzes, and Drive-backed book Q&A. A separate agent API coordinates planning, research, checking, and persistent memory. The graph separates React screens and API transport from FastAPI route handling and backend services. Some route implementations and services are only partly sampled; those links are included only where excerpts, the SOURCE INDEX, or the README support them.

Main entry points: [`frontend/src/App.jsx`](https://github.com/adlinef06/brainbuddy-ai/blob/main/frontend/src/App.jsx) (App and routing), [`backend/main.py`](https://github.com/adlinef06/brainbuddy-ai/blob/main/backend/main.py) (FastAPI application), [`backend/app/services/groq_service.py`](https://github.com/adlinef06/brainbuddy-ai/blob/main/backend/app/services/groq_service.py) (Groq chat service), [`frontend/src/api.js`](https://github.com/adlinef06/brainbuddy-ai/blob/main/frontend/src/api.js) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Study assistant UI"]
  node_app["App and routing<br/>[App.jsx]"]
  node_sidebar["Navigation<br/>[Sidebar.jsx]"]
  node_home["Home<br/>[Home.jsx]"]
  node_ask_ui["General Q&amp;A screen<br/>[AskQuestion.jsx]"]
  node_plan_ui["Study plan and quizzes<br/>[StudyPlan.jsx]"]
  node_book_ui["Book Q&amp;A screen<br/>[BookQA.jsx]"]
  node_api_client["API client<br/>[api.js]"]
end

subgraph group_api["Backend API"]
  node_fastapi["FastAPI application<br/>[main.py]"]
  node_qa_routes["General Q&amp;A route<br/>[main.py]"]
  node_plan_routes["Study plan route<br/>[main.py]"]
  node_quiz_routes["Quiz and progress routes<br/>[main.py]"]
  node_book_routes["Book Q&amp;A routes<br/>[main.py]"]
  node_agent_route["Agent workflow route<br/>[main.py]"]
end

subgraph group_services["AI and study services"]
  node_groq_service["Groq chat service<br/>[groq_service.py]"]
  node_agent_graph["LangGraph agents"]
  node_book_service["Book indexing and retrieval<br/>[book_service.py]"]
  node_drive_service["Drive book access<br/>[drive_service.py]"]
  node_text_utils["Text processing<br/>[text_utils.py]"]
end

subgraph group_integrations["External services and storage"]
  node_vector_store[("ChromaDB store<br/>[vector_store.py]")]
  node_mysql_store[("MySQL study and quiz store<br/>[mysql_store.py]")]
end

node_student(("Student"))
node_groq{{"Groq LLM"}}
node_google_drive[("Google Drive")]

node_student -->|"uses"| node_app
node_app -->|"renders"| node_sidebar
node_app -->|"routes to"| node_home
node_app -->|"routes to"| node_ask_ui
node_app -->|"routes to"| node_plan_ui
node_app -->|"routes to"| node_book_ui
node_ask_ui -->|"calls"| node_api_client
node_plan_ui -->|"calls"| node_api_client
node_book_ui -->|"calls"| node_api_client
node_api_client -->|"sends API requests"| node_fastapi
node_fastapi -->|"handles"| node_qa_routes
node_fastapi -->|"handles"| node_plan_routes
node_fastapi -->|"handles"| node_quiz_routes
node_fastapi -->|"handles"| node_book_routes
node_fastapi -->|"handles"| node_agent_route
node_qa_routes -->|"calls"| node_groq_service
node_plan_routes -->|"calls"| node_groq_service
node_book_routes -->|"searches books"| node_book_service
node_book_routes -->|"generates answers"| node_groq_service
node_book_routes -->|"lists and reads books"| node_drive_service
node_agent_route -->|"runs workflow"| node_agent_graph
node_quiz_routes -->|"stores quiz attempts"| node_mysql_store
node_quiz_routes -->|"stores completed topics"| node_vector_store
node_agent_graph -->|"requests agent output"| node_groq_service
node_agent_graph -->|"reads and saves memory"| node_vector_store
node_book_service -->|"indexes and searches"| node_vector_store
node_book_service -->|"cleans and chunks"| node_text_utils
node_drive_service -->|"lists and downloads"| node_google_drive
node_groq_service -->|"invokes model"| node_groq

click node_app "https://github.com/adlinef06/brainbuddy-ai/blob/main/frontend/src/App.jsx"
click node_sidebar "https://github.com/adlinef06/brainbuddy-ai/blob/main/frontend/src/components/Sidebar.jsx"
click node_home "https://github.com/adlinef06/brainbuddy-ai/blob/main/frontend/src/pages/Home.jsx"
click node_ask_ui "https://github.com/adlinef06/brainbuddy-ai/blob/main/frontend/src/pages/AskQuestion.jsx"
click node_plan_ui "https://github.com/adlinef06/brainbuddy-ai/blob/main/frontend/src/pages/StudyPlan.jsx"
click node_book_ui "https://github.com/adlinef06/brainbuddy-ai/blob/main/frontend/src/pages/BookQA.jsx"
click node_api_client "https://github.com/adlinef06/brainbuddy-ai/blob/main/frontend/src/api.js"
click node_fastapi "https://github.com/adlinef06/brainbuddy-ai/blob/main/backend/main.py"
click node_qa_routes "https://github.com/adlinef06/brainbuddy-ai/blob/main/backend/main.py"
click node_plan_routes "https://github.com/adlinef06/brainbuddy-ai/blob/main/backend/main.py"
click node_quiz_routes "https://github.com/adlinef06/brainbuddy-ai/blob/main/backend/main.py"
click node_book_routes "https://github.com/adlinef06/brainbuddy-ai/blob/main/backend/main.py"
click node_agent_route "https://github.com/adlinef06/brainbuddy-ai/blob/main/backend/main.py"
click node_groq_service "https://github.com/adlinef06/brainbuddy-ai/blob/main/backend/app/services/groq_service.py"
click node_agent_graph "https://github.com/adlinef06/brainbuddy-ai/blob/main/backend/app/services/agent_graph_service.py"
click node_book_service "https://github.com/adlinef06/brainbuddy-ai/blob/main/backend/app/services/book_service.py"
click node_drive_service "https://github.com/adlinef06/brainbuddy-ai/blob/main/backend/app/services/drive_service.py"
click node_vector_store "https://github.com/adlinef06/brainbuddy-ai/blob/main/backend/app/services/vector_store.py"
click node_mysql_store "https://github.com/adlinef06/brainbuddy-ai/blob/main/backend/app/services/mysql_store.py"
click node_text_utils "https://github.com/adlinef06/brainbuddy-ai/blob/main/backend/app/services/text_utils.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_sidebar,node_home,node_ask_ui,node_plan_ui,node_book_ui,node_api_client toneBlue
class node_fastapi,node_qa_routes,node_plan_routes,node_quiz_routes,node_book_routes,node_agent_route,node_google_drive toneAmber
class node_groq_service,node_agent_graph,node_book_service,node_drive_service,node_text_utils toneMint
class node_vector_store,node_mysql_store toneRose
class node_student,node_groq toneIndigo
```

## Components

### Study assistant UI

- [App and routing](https://github.com/adlinef06/brainbuddy-ai/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Navigation](https://github.com/adlinef06/brainbuddy-ai/blob/main/frontend/src/components/Sidebar.jsx): `frontend/src/components/Sidebar.jsx`
- [Home](https://github.com/adlinef06/brainbuddy-ai/blob/main/frontend/src/pages/Home.jsx): `frontend/src/pages/Home.jsx`
- [General Q&A screen](https://github.com/adlinef06/brainbuddy-ai/blob/main/frontend/src/pages/AskQuestion.jsx): `frontend/src/pages/AskQuestion.jsx`
- [Study plan and quizzes](https://github.com/adlinef06/brainbuddy-ai/blob/main/frontend/src/pages/StudyPlan.jsx): `frontend/src/pages/StudyPlan.jsx`
- [Book Q&A screen](https://github.com/adlinef06/brainbuddy-ai/blob/main/frontend/src/pages/BookQA.jsx): `frontend/src/pages/BookQA.jsx`
- [API client](https://github.com/adlinef06/brainbuddy-ai/blob/main/frontend/src/api.js): `frontend/src/api.js`

### Backend API

- [FastAPI application](https://github.com/adlinef06/brainbuddy-ai/blob/main/backend/main.py): `backend/main.py`
- [General Q&A route](https://github.com/adlinef06/brainbuddy-ai/blob/main/backend/main.py): `backend/main.py`
- [Study plan route](https://github.com/adlinef06/brainbuddy-ai/blob/main/backend/main.py): `backend/main.py`
- [Quiz and progress routes](https://github.com/adlinef06/brainbuddy-ai/blob/main/backend/main.py): `backend/main.py`
- [Book Q&A routes](https://github.com/adlinef06/brainbuddy-ai/blob/main/backend/main.py): `backend/main.py`
- [Agent workflow route](https://github.com/adlinef06/brainbuddy-ai/blob/main/backend/main.py): `backend/main.py`

### AI and study services

- [Groq chat service](https://github.com/adlinef06/brainbuddy-ai/blob/main/backend/app/services/groq_service.py): `backend/app/services/groq_service.py`
- [LangGraph agents](https://github.com/adlinef06/brainbuddy-ai/blob/main/backend/app/services/agent_graph_service.py): `backend/app/services/agent_graph_service.py`
- [Book indexing and retrieval](https://github.com/adlinef06/brainbuddy-ai/blob/main/backend/app/services/book_service.py): `backend/app/services/book_service.py`
- [Drive book access](https://github.com/adlinef06/brainbuddy-ai/blob/main/backend/app/services/drive_service.py): `backend/app/services/drive_service.py`
- [Text processing](https://github.com/adlinef06/brainbuddy-ai/blob/main/backend/app/services/text_utils.py): `backend/app/services/text_utils.py`

### External services and storage

- [ChromaDB store](https://github.com/adlinef06/brainbuddy-ai/blob/main/backend/app/services/vector_store.py): `backend/app/services/vector_store.py`
- [MySQL study and quiz store](https://github.com/adlinef06/brainbuddy-ai/blob/main/backend/app/services/mysql_store.py): `backend/app/services/mysql_store.py`

### Other components

- **Student**
- **Groq LLM**
- **Google Drive**

## Connections

- Student → App and routing: uses (evidence: `README.md`)
- App and routing → Navigation: renders (evidence: `frontend/src/App.jsx`)
- App and routing → Home: routes to (evidence: `frontend/src/App.jsx`)
- App and routing → General Q&A screen: routes to (evidence: `frontend/src/App.jsx`)
- App and routing → Study plan and quizzes: routes to (evidence: `frontend/src/App.jsx`)
- App and routing → Book Q&A screen: routes to (evidence: `frontend/src/App.jsx`)
- General Q&A screen → API client: calls (evidence: `frontend/src/pages/AskQuestion.jsx`)
- Study plan and quizzes → API client: calls (evidence: `frontend/src/pages/StudyPlan.jsx`)
- Book Q&A screen → API client: calls (evidence: `frontend/src/pages/BookQA.jsx`)
- API client → FastAPI application: sends API requests (evidence: `frontend/src/api.js`)
- FastAPI application → General Q&A route: handles (evidence: `backend/main.py`)
- FastAPI application → Study plan route: handles (evidence: `backend/main.py`)
- FastAPI application → Quiz and progress routes: handles (evidence: `backend/main.py`)
- FastAPI application → Book Q&A routes: handles (evidence: `backend/main.py`)
- FastAPI application → Agent workflow route: handles (evidence: `README.md`)
- General Q&A route → Groq chat service: calls (evidence: `backend/main.py`)
- Study plan route → Groq chat service: calls (evidence: `backend/main.py`)
- Book Q&A routes → Book indexing and retrieval: searches books (evidence: `backend/main.py`)
- Book Q&A routes → Groq chat service: generates answers (evidence: `backend/main.py`)
- Book Q&A routes → Drive book access: lists and reads books (evidence: `backend/main.py`)
- Agent workflow route → LangGraph agents: runs workflow (evidence: `README.md`)
- Quiz and progress routes → MySQL study and quiz store: stores quiz attempts (evidence: `backend/main.py`)
- Quiz and progress routes → ChromaDB store: stores completed topics (evidence: `backend/main.py`)
- LangGraph agents → Groq chat service: requests agent output (evidence: `backend/app/services/agent_graph_service.py`)
- LangGraph agents → ChromaDB store: reads and saves memory (evidence: `backend/app/services/agent_graph_service.py`)
- Book indexing and retrieval → ChromaDB store: indexes and searches (evidence: `backend/app/services/book_service.py`)
- Book indexing and retrieval → Text processing: cleans and chunks (evidence: `backend/app/services/book_service.py`)
- Drive book access → Google Drive: lists and downloads (evidence: `backend/app/services/drive_service.py`)
- Groq chat service → Groq LLM: invokes model (evidence: `backend/app/services/groq_service.py`)
