# yogeshsheoran01/ai-powered-study-assistant-main architecture

> Architecture diagram of the GitHub repository yogeshsheoran01/ai-powered-study-assistant-main, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yogeshsheoran01/ai-powered-study-assistant-main
- Repository: https://github.com/yogeshsheoran01/ai-powered-study-assistant-main

## Overview

#### Purpose and Runtime
SGPA is a Python/Streamlit study-assistant application. It provides chat-oriented academic help through three AI modes: concept explanation, note/PDF summarization, and quiz generation/solving/evaluation. The application runs as a Streamlit app, locally or on Streamlit Community Cloud, with Google Gemini 2.5 Flash as its model backend.

Entry point: `main.py`  
UI configuration: `.streamlit/config.toml`  
Dependencies: `requirements.txt`

#### Application Composition
`main.py` is the orchestration layer: it initializes Streamlit state, selects the active mode, accepts user inputs, dispatches requests to domain modules, and renders responses. It composes reusable UI pieces rather than exposing a separate API/server layer.

Primary paths:
- `main.py`
- `components/sidebar.py`
- `components/chat_ui.py`

#### UI, Session, and Mode Selection
The sidebar supplies mode selection and likely reset/new-chat controls; the chat UI owns interactive message display and input rendering. Streamlit session state is the key in-process boundary for conversation context, selected workflow, upload state, and anonymous session-level analytics. Streamlit reruns the script on interaction, so state must persist through Streamlit mechanisms rather than a dedicated backend database.

Primary paths:
- `components/sidebar.py`
- `components/chat_ui.py`
- `main.py`

#### AI Dispatch and Gemini Boundary
Mode-specific modules construct academic prompts and delegate model execution through shared AI/Gemini utilities. This isolates Gemini API configuration, secure key retrieval (`.env` or `st.secrets`), and provider calls from UI and domain behavior. The external-service boundary is Google’s Gemini API via `google-generativeai`; failures, unavailable credentials, and model-response formatting should be handled at this shared layer.

Primary paths:
- `core/ai_utils.py`
- `utils/gemini_helper.py`
- `core/explainer.py`

#### Explainer Workflow
Explainer accepts a concept or question and returns simplified, exam-oriented teaching content. Its domain prompt behavior includes suggesting a simple sketchable diagram, making this mode a direct text-in/model-out pipeline with chat history potentially enriching follow-up requests.

Primary paths:
- `core/explainer.py`
- `core/ai_utils.py`
- `components/chat_ui.py`

#### Summarization and PDF Ingestion
Summarizer accepts pasted notes or text extracted from uploaded PDFs, then produces structured, exam-ready summaries and practice material. PDF processing is separated from summarization: UI-facing upload handling and core text extraction are represented independently, allowing extraction validation before costly model calls. Empty, very short, and scanned/non-extractable PDFs are guarded and surfaced as warnings rather than treated as valid source text.

Primary paths:
- `components/pdf_handler.py`
- `core/pdf_handler.py`
- `core/summarizer.py`

#### Quizzer Multi-Stage Workflow
Quizzer is a single domain module with three request shapes: generate mixed questions plus answer key, solve supplied exam questions, and evaluate submitted answers for feedback/correction/scoring. Input parsing—especially question/answer separators and sequential evaluation prompts—is an important boundary before prompt construction. Outputs remain model-generated text rendered in the shared chat UI.

Primary paths:
- `core/quizzer.py`
- `core/ai_utils.py`
- `components/chat_ui.py`

#### Operations and Persistence
The system is intentionally lightweight: no repository evidence of a database, asynchronous worker, or standalone HTTP backend. Usage analytics are privacy-oriented and CSV-based, implying local/app-runtime file persistence rather than an external analytics platform. Logging support exists for runtime diagnostics. Deployment is Streamlit Community Cloud; credentials must remain in environment variables or Streamlit secrets and never flow into prompts, UI output, or CSV analytics.

Primary paths:
- `utils/logger.py`
- `main.py`
- `.streamlit/config.toml`

Main entry points: [`main.py`](https://github.com/yogeshsheoran01/ai-powered-study-assistant-main/blob/main/main.py) (Application Orchestrator), [`components/chat_ui.py`](https://github.com/yogeshsheoran01/ai-powered-study-assistant-main/blob/main/components/chat_ui.py) (Chat Interface), [`core/summarizer.py`](https://github.com/yogeshsheoran01/ai-powered-study-assistant-main/blob/main/core/summarizer.py) (Notes Summarizer), [`core/ai_utils.py`](https://github.com/yogeshsheoran01/ai-powered-study-assistant-main/blob/main/core/ai_utils.py) (AI Request Layer)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Streamlit UI"]
  node_app["Application Orchestrator<br/>Streamlit app<br/>[main.py]"]
  node_sidebar["Sidebar Controls<br/>UI component<br/>[sidebar.py]"]
  node_chat_ui["Chat Interface<br/>UI component<br/>[chat_ui.py]"]
  node_session_state[("Session State<br/>in-process state")]
  node_upload_handler["PDF Upload Handling<br/>UI component<br/>[pdf_handler.py]"]
end

subgraph group_workflows["Academic Workflows"]
  node_explainer["Concept Explainer<br/>domain workflow<br/>[explainer.py]"]
  node_summarizer["Notes Summarizer<br/>domain workflow<br/>[summarizer.py]"]
  node_pdf_extractor["PDF Text Extraction<br/>core processing<br/>[pdf_handler.py]"]
  node_quizzer["Quiz Workflow<br/>domain workflow<br/>[quizzer.py]"]
end

subgraph group_ai["AI Integration"]
  node_ai_utils["AI Request Layer<br/>shared AI utility<br/>[ai_utils.py]"]
  node_gemini_helper["Gemini Configuration<br/>provider utility<br/>[gemini_helper.py]"]
  node_gemini_api{{"Google Gemini API<br/>external model service"}}
end

subgraph group_runtime["Runtime &amp; Operations"]
  node_analytics_csv[("Usage Analytics CSV<br/>file persistence")]
  node_logger["Runtime Logging<br/>diagnostics<br/>[logger.py]"]
  node_streamlit_config["Streamlit Configuration<br/>deployment config<br/>[config.toml]"]
  node_streamlit_runtime{{"Streamlit Runtime<br/>hosting runtime"}}
end

node_streamlit_runtime -->|"runs"| node_app
node_streamlit_config -->|"configures"| node_streamlit_runtime
node_app -->|"composes"| node_sidebar
node_app -->|"composes"| node_chat_ui
node_app -->|"reads and updates"| node_session_state
node_sidebar -->|"selects mode"| node_session_state
node_chat_ui -->|"stores conversation"| node_session_state
node_app -->|"dispatches explanation"| node_explainer
node_app -->|"handles uploads"| node_upload_handler
node_upload_handler -->|"sends PDF"| node_pdf_extractor
node_pdf_extractor -->|"provides extracted text"| node_summarizer
node_app -->|"dispatches notes"| node_summarizer
node_app -->|"dispatches quiz requests"| node_quizzer
node_explainer -->|"requests generation"| node_ai_utils
node_summarizer -->|"requests generation"| node_ai_utils
node_quizzer -->|"requests generation"| node_ai_utils
node_ai_utils -->|"uses configuration"| node_gemini_helper
node_gemini_helper -->|"authenticates and calls"| node_gemini_api
node_app -->|"records anonymous usage"| node_analytics_csv
node_app -->|"emits diagnostics"| node_logger
node_explainer -->|"renders response"| node_chat_ui
node_summarizer -->|"renders response"| node_chat_ui
node_quizzer -->|"renders response"| node_chat_ui

click node_app "https://github.com/yogeshsheoran01/ai-powered-study-assistant-main/blob/main/main.py"
click node_sidebar "https://github.com/yogeshsheoran01/ai-powered-study-assistant-main/blob/main/components/sidebar.py"
click node_chat_ui "https://github.com/yogeshsheoran01/ai-powered-study-assistant-main/blob/main/components/chat_ui.py"
click node_upload_handler "https://github.com/yogeshsheoran01/ai-powered-study-assistant-main/blob/main/components/pdf_handler.py"
click node_explainer "https://github.com/yogeshsheoran01/ai-powered-study-assistant-main/blob/main/core/explainer.py"
click node_summarizer "https://github.com/yogeshsheoran01/ai-powered-study-assistant-main/blob/main/core/summarizer.py"
click node_pdf_extractor "https://github.com/yogeshsheoran01/ai-powered-study-assistant-main/blob/main/core/pdf_handler.py"
click node_quizzer "https://github.com/yogeshsheoran01/ai-powered-study-assistant-main/blob/main/core/quizzer.py"
click node_ai_utils "https://github.com/yogeshsheoran01/ai-powered-study-assistant-main/blob/main/core/ai_utils.py"
click node_gemini_helper "https://github.com/yogeshsheoran01/ai-powered-study-assistant-main/blob/main/utils/gemini_helper.py"
click node_logger "https://github.com/yogeshsheoran01/ai-powered-study-assistant-main/blob/main/utils/logger.py"
click node_streamlit_config "https://github.com/yogeshsheoran01/ai-powered-study-assistant-main/blob/main/.streamlit/config.toml"

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_chat_ui,node_session_state,node_upload_handler toneBlue
class node_explainer,node_summarizer,node_pdf_extractor,node_quizzer toneAmber
class node_ai_utils,node_gemini_helper,node_gemini_api toneMint
class node_analytics_csv,node_logger,node_streamlit_config,node_streamlit_runtime toneRose
```

## Components

### Streamlit UI

- [Application Orchestrator](https://github.com/yogeshsheoran01/ai-powered-study-assistant-main/blob/main/main.py): Streamlit app · Initializes state, dispatches modes, and renders results. · `main.py`
- [Sidebar Controls](https://github.com/yogeshsheoran01/ai-powered-study-assistant-main/blob/main/components/sidebar.py): UI component · Selects modes and chat controls. · `components/sidebar.py`
- [Chat Interface](https://github.com/yogeshsheoran01/ai-powered-study-assistant-main/blob/main/components/chat_ui.py): UI component · Renders messages and captures interactive input. · `components/chat_ui.py`
- **Session State**: in-process state · Persists workflow, conversation, uploads, and anonymous session data across reruns.
- [PDF Upload Handling](https://github.com/yogeshsheoran01/ai-powered-study-assistant-main/blob/main/components/pdf_handler.py): UI component · Validates uploaded PDF inputs before processing. · `components/pdf_handler.py`

### Academic Workflows

- [Concept Explainer](https://github.com/yogeshsheoran01/ai-powered-study-assistant-main/blob/main/core/explainer.py): domain workflow · Builds exam-oriented concept explanation prompts. · `core/explainer.py`
- [Notes Summarizer](https://github.com/yogeshsheoran01/ai-powered-study-assistant-main/blob/main/core/summarizer.py): domain workflow · Produces structured exam-ready summaries and practice material. · `core/summarizer.py`
- [PDF Text Extraction](https://github.com/yogeshsheoran01/ai-powered-study-assistant-main/blob/main/core/pdf_handler.py): core processing · Extracts and validates usable PDF text. · `core/pdf_handler.py`
- [Quiz Workflow](https://github.com/yogeshsheoran01/ai-powered-study-assistant-main/blob/main/core/quizzer.py): domain workflow · Generates, solves, and evaluates quizzes after input parsing. · `core/quizzer.py`

### AI Integration

- [AI Request Layer](https://github.com/yogeshsheoran01/ai-powered-study-assistant-main/blob/main/core/ai_utils.py): shared AI utility · Centralizes provider calls, response handling, and failures. · `core/ai_utils.py`
- [Gemini Configuration](https://github.com/yogeshsheoran01/ai-powered-study-assistant-main/blob/main/utils/gemini_helper.py): provider utility · Loads credentials and configures Gemini access. · `utils/gemini_helper.py`
- **Google Gemini API**: external model service · Gemini 2.5 Flash inference backend.

### Runtime & Operations

- **Usage Analytics CSV**: file persistence · Privacy-oriented local/runtime usage records.
- [Runtime Logging](https://github.com/yogeshsheoran01/ai-powered-study-assistant-main/blob/main/utils/logger.py): diagnostics · `utils/logger.py`
- [Streamlit Configuration](https://github.com/yogeshsheoran01/ai-powered-study-assistant-main/blob/main/.streamlit/config.toml): deployment config · Supports local and Community Cloud runtime configuration. · `.streamlit/config.toml`
- **Streamlit Runtime**: hosting runtime · Reruns the app on user interaction.

## Connections

- Streamlit Runtime → Application Orchestrator: runs
- Streamlit Configuration → Streamlit Runtime: configures
- Application Orchestrator → Sidebar Controls: composes
- Application Orchestrator → Chat Interface: composes
- Application Orchestrator → Session State: reads and updates
- Sidebar Controls → Session State: selects mode
- Chat Interface → Session State: stores conversation
- Application Orchestrator → Concept Explainer: dispatches explanation
- Application Orchestrator → PDF Upload Handling: handles uploads
- PDF Upload Handling → PDF Text Extraction: sends PDF
- PDF Text Extraction → Notes Summarizer: provides extracted text
- Application Orchestrator → Notes Summarizer: dispatches notes
- Application Orchestrator → Quiz Workflow: dispatches quiz requests
- Concept Explainer → AI Request Layer: requests generation
- Notes Summarizer → AI Request Layer: requests generation
- Quiz Workflow → AI Request Layer: requests generation
- AI Request Layer → Gemini Configuration: uses configuration
- Gemini Configuration → Google Gemini API: authenticates and calls
- Application Orchestrator → Usage Analytics CSV: records anonymous usage
- Application Orchestrator → Runtime Logging: emits diagnostics
- Concept Explainer → Chat Interface: renders response
- Notes Summarizer → Chat Interface: renders response
- Quiz Workflow → Chat Interface: renders response
