# overwatch-coder/studybot architecture

> Architecture diagram of the GitHub repository overwatch-coder/studybot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/overwatch-coder/studybot
- Repository: https://github.com/overwatch-coder/studybot

## Overview

##### Main Components

Frontend Layer:
- User Interface (components/)
- Pages (pages/)
- Hooks (hooks/)
- Utils (utils/)
- Types (types/)

Integration Layer:
- Supabase Client
- AI Service Integration
- PDF Processing Service

Backend Services:
- External services:
- OpenAI API
- Supabase Database
- File Storage System

##### Component Relationships

a) User Flow:
- Landing Page → Setup Form → Dashboard
- Dashboard → Study Options (Chat, Flashcards, Quiz, etc.)

b) Data Flow:
- Frontend → Supabase Client → Supabase Database
- Frontend → AI Integration → OpenAI API
- File Upload → PDF Extractor → AI Content Generator

##### Detailed Component Breakdown

Frontend Section:
**┌─ UI Components ─┐**
- SetupForm     │
- StudyOptions  │
- Chat          │
- Flashcards    │
- Quiz          │
- Summary       │
- ┘

Integration Layer:
**┌─ Services ──────┐**
- AI Service    │
- File Process  │
- Database      │
- ┘

##### Technical Details

Labels for:
- React + TypeScript
- Tailwind CSS
- Supabase
- OpenAI Integration
- PDF Processing
- Custom Hooks
- UI Components Library

##### Architecture Patterns

Emphasize:
- Component-based architecture
- Custom hooks for state management
- Service-based integration
- Utility-based processing

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Frontend
        UI[User Interface]
        Pages[Pages]
        Hooks[Hooks]
        Utils[Utils]
        Types[Types]

        subgraph UIComponents
            SetupForm[Setup Form]
            Chat[Chat Interface]
            Flash[Flashcards]
            Quiz[Quiz System]
            Summary[Summary]
            StudyOpt[Study Options]
            Practice[Practice Questions]
        end

        subgraph PageComponents
            Landing[Landing Page]
            Dashboard[Dashboard]
            Setup[Setup Page]
        end

        subgraph SetupFormComponents
            CourseDetails[Course Details]
            FileUpload[File Upload]
            SubmitBtn[Submit Button]
        end
    end

    subgraph Integration
        SupaClient[Supabase Client]
        AIService[AI Service]
        PDFService[PDF Processing]
    end

    subgraph External
        OpenAI[OpenAI API]
        SupaDB[(Supabase DB)]
        Storage[(File Storage)]
    end

    %% Relationships
    Landing --> Setup
    Setup --> Dashboard
    Dashboard --> StudyOpt
    StudyOpt --> Chat
    StudyOpt --> Flash
    StudyOpt --> Quiz
    StudyOpt --> Summary
    StudyOpt --> Practice

    FileUpload --> PDFService
    PDFService --> AIService
    AIService --> OpenAI
    SupaClient --> SupaDB

    %% Click Events
    click UI "https://github.com/overwatch-coder/studybot/tree/main/src/components/ui/"
    click SetupForm "https://github.com/overwatch-coder/studybot/blob/main/src/components/SetupForm.tsx"
    click Chat "https://github.com/overwatch-coder/studybot/blob/main/src/components/Chat.tsx"
    click Flash "https://github.com/overwatch-coder/studybot/blob/main/src/components/Flashcards.tsx"
    click Quiz "https://github.com/overwatch-coder/studybot/blob/main/src/components/Quiz.tsx"
    click Summary "https://github.com/overwatch-coder/studybot/blob/main/src/components/Summary.tsx"
    click StudyOpt "https://github.com/overwatch-coder/studybot/blob/main/src/components/StudyOptions.tsx"
    click Practice "https://github.com/overwatch-coder/studybot/blob/main/src/components/PracticeQuestions.tsx"
    click Landing "https://github.com/overwatch-coder/studybot/blob/main/src/pages/Landing.tsx"
    click Dashboard "https://github.com/overwatch-coder/studybot/blob/main/src/pages/Dashboard.tsx"
    click Setup "https://github.com/overwatch-coder/studybot/blob/main/src/pages/Setup.tsx"
    click SupaClient "https://github.com/overwatch-coder/studybot/blob/main/src/integrations/supabase/client.ts"
    click Types "https://github.com/overwatch-coder/studybot/blob/main/src/types/types.d.ts"
    click PDFService "https://github.com/overwatch-coder/studybot/blob/main/src/utils/pdfExtractor.ts"
    click AIService "https://github.com/overwatch-coder/studybot/blob/main/src/utils/aiContentGenerator.ts"
    click Utils "https://github.com/overwatch-coder/studybot/blob/main/src/lib/utils.ts"
    click CourseDetails "https://github.com/overwatch-coder/studybot/blob/main/src/components/setup-form/CourseDetails.tsx"
    click FileUpload "https://github.com/overwatch-coder/studybot/blob/main/src/components/setup-form/FileUpload.tsx"
    click SubmitBtn "https://github.com/overwatch-coder/studybot/blob/main/src/components/setup-form/SubmitButton.tsx"
    click Hooks "https://github.com/overwatch-coder/studybot/tree/main/src/hooks/"

    %% Styling
    classDef frontend fill:#3b82f6,color:white
    classDef integration fill:#22c55e,color:white
    classDef external fill:#a855f7,color:white
    classDef process fill:#f97316,color:white
    classDef storage fill:#6b7280,color:white

    class UI,Pages,Hooks,Utils,Types,UIComponents,PageComponents,SetupFormComponents frontend
    class SupaClient,AIService,PDFService integration
    class OpenAI external
    class SupaDB,Storage storage
    
    %% Legend
    subgraph Legend
        Frontend_L[Frontend]:::frontend
        Integration_L[Integration]:::integration
        External_L[External Services]:::external
        Storage_L[Storage]:::storage
    end
```
