# parthtiwa-ri/snapsummary architecture

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

- Interactive diagram: https://gitdiagram.com/parthtiwa-ri/snapsummary
- Repository: https://github.com/parthtiwa-ri/snapsummary

## Overview

##### Main Components

A. Frontend Layer:
- Client-Side Components (React/Next.js)
- Upload Interface (Dropzone)
- Summary Display
- Text Extraction View
- Navigation Components
- UI Components

B. Backend Layer (Next.js API Routes):
- File Processing Service
- Text Extraction Service
- PDF Processing (PDF.js)
- Image Processing (Tesseract.js)
- Summary Generation Service (Google Gemini API)

C. External Services:
- Google Gemini API
- File Storage System
- OCR Processing (Tesseract.js)

**[Client Layer]**
- ↕
**[Next.js Server Layer]**
- ↕
**[External Services Layer]**

##### Component Relationships

- File upload flow: Client → Server → Processing Services
- Summary generation flow: Processed Text → Gemini API → Summary Display
- Error handling paths across components
- State management flow (using the context provider)

##### Detailed Component Breakdown

Frontend (Blue):
- Upload Interface
- Dropzone
- File Preview
- Summary Interface
- Summary Display
- Key Points
- Control Buttons
- Text Display
- Extracted Text View

Backend Services (Green):
- File Processing
- PDF Parser
- Image Processor
- Text Extraction
- Summary Generation

External Services (Yellow):
- Google Gemini API
- Tesseract OCR
- PDF.js

##### Additional Elements

- API endpoint annotations
- Error handling pathways
- State management indicators
- Loading states and progress indicators

##### Important Architectural Notes

- Next.js pages router structure
- Separation between client and server components
- Where context providers wrap the application
- Authentication boundaries if implemented
- Error boundary implementations

##### Result display

Remember to indicate the asynchronous nature of operations and how the application handles loading states and errors during these processes.

This system design should reflect the modern Next.js architecture while clearly showing how the application processes documents and interacts with external services for OCR and AI-powered summarization.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        UI[Upload Interface]
        SD[Summary Display]
        TV[Text Extraction View]
        NAV[Navigation Components]
        UIC[UI Components]
        ERR[Error Handling]
        LOAD[Loading States]
    end

    subgraph Server
        FPS[File Processing Service]
        TES[Text Extraction Service]
        SGS[Summary Generation Service]
        SM[State Management]
    end

    subgraph External
        GEM[Google Gemini API]
        OCR[Tesseract OCR]
        PDF[PDF.js]
        FS[File Storage]
    end

    %% Client Layer Connections
    UI --> FPS
    FPS --> TES
    TES --> SGS
    SGS --> SD
    TES --> TV
    SM --> UI
    SM --> SD
    SM --> TV

    %% Server to External Connections
    TES --> OCR
    TES --> PDF
    SGS --> GEM
    FPS --> FS

    %% Error and Loading Flows
    UI --> ERR
    TES --> ERR
    SGS --> ERR
    UI --> LOAD
    TES --> LOAD
    SGS --> LOAD

    %% Component Mappings
    click UI "https://github.com/ParthTiwa-ri/SnapSummary/blob/main/components/dropzone/MyDropZone.js"
    click SD "https://github.com/ParthTiwa-ri/SnapSummary/blob/main/components/summary/SummaryDisplay.js"
    click TV "https://github.com/ParthTiwa-ri/SnapSummary/blob/main/components/ExtractedText.js"
    click NAV "https://github.com/ParthTiwa-ri/SnapSummary/blob/main/components/AppHeader.js"
    click UIC "https://github.com/ParthTiwa-ri/SnapSummary/tree/main/components/ui"
    click ERR "https://github.com/ParthTiwa-ri/SnapSummary/blob/main/components/ErrorDisplay.js"
    click LOAD "https://github.com/ParthTiwa-ri/SnapSummary/blob/main/components/LoadingBar.js"
    click FPS "https://github.com/ParthTiwa-ri/SnapSummary/blob/main/utils/fileProcessing.js"
    click SGS "https://github.com/ParthTiwa-ri/SnapSummary/blob/main/lib/api/geminiAPi.js"
    click SM "https://github.com/ParthTiwa-ri/SnapSummary/blob/main/context/textProvider.js"

    %% Styling
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef backend fill:#2ecc71,stroke:#27ae60,color:white
    classDef external fill:#f1c40f,stroke:#f39c12,color:black
    classDef error fill:#e74c3c,stroke:#c0392b,color:white

    class UI,SD,TV,NAV,UIC frontend
    class FPS,TES,SGS,SM backend
    class GEM,OCR,PDF,FS external
    class ERR,LOAD error

    %% Legend
    subgraph Legend
        F[Frontend]:::frontend
        B[Backend]:::backend
        E[External Services]:::external
        ER[Error/Loading]:::error
    end
```
