How yogeshsheoran01/ai-powered-study-assistant-main works
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 Application Orchestrator · chat_ui.py Chat Interface · summarizer.py Notes Summarizer · ai_utils.py AI Request Layer
Components 16
Streamlit UI
- Application Orchestrator · Initializes state, dispatches modes, and renders results.
main.py - Sidebar Controls · Selects modes and chat controls.
components/sidebar.py - Chat Interface · Renders messages and captures interactive input.
components/chat_ui.py - Session State · Persists workflow, conversation, uploads, and anonymous session data across reruns.
- PDF Upload Handling · Validates uploaded PDF inputs before processing.
components/pdf_handler.py
Academic Workflows
- Concept Explainer · Builds exam-oriented concept explanation prompts.
core/explainer.py - Notes Summarizer · Produces structured exam-ready summaries and practice material.
core/summarizer.py - PDF Text Extraction · Extracts and validates usable PDF text.
core/pdf_handler.py - Quiz Workflow · Generates, solves, and evaluates quizzes after input parsing.
core/quizzer.py
AI Integration
- AI Request Layer · Centralizes provider calls, response handling, and failures.
core/ai_utils.py - Gemini Configuration · Loads credentials and configures Gemini access.
utils/gemini_helper.py - Google Gemini API · Gemini 2.5 Flash inference backend.
Runtime & Operations
- Usage Analytics CSV · Privacy-oriented local/runtime usage records.
- Runtime Logging
utils/logger.py - Streamlit Configuration · Supports local and Community Cloud runtime configuration.
.streamlit/config.toml - Streamlit Runtime · Reruns the app on user interaction.
Connections 23
- 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