# tanishachandani/insight architecture

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

- Interactive diagram: https://gitdiagram.com/tanishachandani/insight
- Repository: https://github.com/tanishachandani/insight

## Overview

- Frontend: Represented by the “frontend” directory, it is built with Next.js and contains pages, components (Header, Footer, FlashCards, Quiz, Summary, etc.), styling files (Tailwind CSS, globals.css), and build configurations. This component is responsible for capturing user inputs, handling file uploads, and presenting the generated resources.
- Backend: Located in the “backend” folder, it is most likely a Python/Flask application (given the “backend.py” and related generator scripts for flashcards, quizzes, summaries). It coordinates the processing of input documents, calls AI modules (in files like “speech_to_text.py”, “gemini_call.py”), and handles file conversions.
- AI Modules: Notice the separate “AI” folder and the AI-specific Python scripts. These likely encapsulate certain specialized AI functionalities (e.g., advanced speech-to-text conversion) and are used by the backend.
- Database/Storage: Within the “backend/database” folder, many JSON files are stored. These files likely serve as storage for generated study material, examples, or configuration data.
- External Services: Integration with Google Cloud services (Speech-to-Text, Cloud Storage, etc.) is essential. This external dependency should be depicted as a separate component, showing that the backend interacts with these services (using credentials from a service account key).

##### Relationships and Data Flow
- Backend Processing: Within the backend block, include subcomponents representing:
- Resource Generators: Flashcard, Quiz, and Summary generator modules.
- Speech-to-Text Module: This might call out to both an internal script and the external Google Cloud Speech-to-Text API.
- File Processing: Components that handle document parsing and conversion (including the “gemini_call.py” utility).
- Database: Show the connection from the backend to the JSON-based database files.
- Data Storage and Export: Illustrate that the backend stores generated content (like learning resources) in the database folder and can export these as .docx files (referencing the examples and docx files scattered in the backend).

##### Architectural Patterns and Key Technologies
- Clearly divide the frontend and backend with a separation boundary, emphasizing the typical full-stack split.
- Usage of Node.js and npm for frontend dependency management and Python (with a virtual environment) for backend dependencies.
- Additional configuration/deployment elements like environment variable management (.env files), Google Cloud SDK setup, and local development modes.
- That the backend makes use of Flask (or a similar lightweight framework) to handle API requests and that the frontend utilizes the capabilities of Next.js for server-side rendering (as indicated by the .next directory structure).

## Diagram (Mermaid)

```mermaid
flowchart TD
    User("User/Browser"):::externalColor

    FE("Frontend (Next.js UI)"):::frontendColor
    FEComp("Frontend Components"):::frontendColor
    FEHeader("Header"):::frontendColor
    FEUpload("UploadButton"):::frontendColor
    FEFooter("Footer"):::frontendColor
    FEFlash("FlashCards"):::frontendColor
    FEQuiz("Quiz"):::frontendColor
    FESummary("Summary"):::frontendColor

    BE("Backend (Flask/Python server)"):::backendColor

    subgraph "Backend Processing"
        FG("Flashcard Generator"):::backendColor
        QG("Quiz Generator"):::backendColor
        SG("Summary Generator"):::backendColor
        BSTT("Speech-to-Text (Backend)"):::backendColor
        GCU("Gemini Call Utility"):::backendColor
        AISTT("AI Speech-to-Text"):::backendColor
        DB("JSON Database"):::storageColor
        FEExport("File Export (.docx)"):::backendColor
    end

    ES("Google Cloud Speech-to-Text API"):::externalColor

    %% Data Flow
    User -->|"access"| FE
    FE -->|"HTTP/APIrequests"| BE

    %% Frontend Components
    FE --> FEComp
    FEComp --> FEHeader
    FEComp --> FEUpload
    FEComp --> FEFooter
    FEComp --> FEFlash
    FEComp --> FEQuiz
    FEComp --> FESummary

    %% Backend Processing Flow
    BE --> FG
    BE --> QG
    BE --> SG
    BE --> BSTT
    BE --> GCU
    BE --> AISTT
    BE --> DB
    BE --> FEExport

    BSTT -->|"APIcall(credentials)"| ES
    AISTT -->|"APIcall(credentials)"| ES

    FG -->|"store"| DB
    QG -->|"store"| DB
    SG -->|"store"| DB
    DB -->|"export"| FEExport

    %% Click Events
    click FE "https://github.com/tanishachandani/insight/tree/main/frontend/"
    click FEHeader "https://github.com/tanishachandani/insight/blob/main/frontend/components/Header.jsx"
    click FEUpload "https://github.com/tanishachandani/insight/blob/main/frontend/components/UploadButton.jsx"
    click FEFooter "https://github.com/tanishachandani/insight/blob/main/frontend/components/Footer.jsx"
    click FEFlash "https://github.com/tanishachandani/insight/blob/main/frontend/components/FlashCards.jsx"
    click FEQuiz "https://github.com/tanishachandani/insight/blob/main/frontend/components/Quiz.jsx"
    click FESummary "https://github.com/tanishachandani/insight/blob/main/frontend/components/Summary.jsx"
    click BE "https://github.com/tanishachandani/insight/blob/main/backend/backend.py"
    click FG "https://github.com/tanishachandani/insight/blob/main/backend/flash_card_generator.py"
    click QG "https://github.com/tanishachandani/insight/blob/main/backend/quiz_generator.py"
    click SG "https://github.com/tanishachandani/insight/blob/main/backend/summary_generator.py"
    click BSTT "https://github.com/tanishachandani/insight/blob/main/backend/speech_to_text.py"
    click GCU "https://github.com/tanishachandani/insight/blob/main/backend/gemini_call.py"
    click AISTT "https://github.com/tanishachandani/insight/blob/main/AI/speech_to_text.py"
    click DB "https://github.com/tanishachandani/insight/tree/main/backend/database/"

    %% Styles
    classDef frontendColor fill:#a8e6cf,stroke:#333,stroke-width:2px;
    classDef backendColor fill:#dcedc1,stroke:#333,stroke-width:2px;
    classDef storageColor fill:#ffcc80,stroke:#333,stroke-width:2px;
    classDef externalColor fill:#ffd180,stroke:#333,stroke-width:2px;
```
