# mr-vicky-01/legal-doc-analyzer architecture

> Architecture diagram of the GitHub repository mr-vicky-01/legal-doc-analyzer, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mr-vicky-01/legal-doc-analyzer
- Repository: https://github.com/mr-vicky-01/legal-doc-analyzer

## Overview

##### Project type and purpose
- This is a lightweight full-stack web application (“Legal Doc Analyzer”) that exposes a user interface for uploading legal documents or text prompts, processes them locally (parsing/extraction), then calls out to an external AI service (Google’s Gemini via the Google Generative AI SDK) to generate responses.

##### File structure
- Top-level files:
- .env – environment variable storage (GOOGLE_API_KEY)
- README.md – user and developer documentation
- requirements.txt – pinned Python dependencies (e.g., google-generativeai, Flask/Gradio/Streamlit if used)
- app.py – main entry point / web server and request router
- extractor.py – document-parsing module (text, metadata extraction)
- llm.py – wrapper module handling interaction with the Gemini model API

##### Key insights from README
- The app runs via `python app.py`
- Users can upload documents or send prompts
- Workflow: user → app.py (UI & routing) → extractor.py (preprocessing) → llm.py (API client) → Gemini API → llm.py → app.py → user

##### Final advice
- Be explicit about data flows and module interfaces
- Dependencies (API keys, third-party libraries)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        Frontend["Frontend / Web Interface"]:::frontend
    end

    %% Application Logic
    subgraph "Application Logic"
        App["Application Server (app.py)"]:::internal
    end

    %% Domain Services
    subgraph "Domain Services"
        Extractor["Document Extractor (extractor.py)"]:::internal
        LLM["LLM Client (llm.py)"]:::internal
    end

    %% External & Config
    subgraph "External & Config"
        Config["Configuration Store (.env)"]:::config
        Deps["Dependencies (requirements.txt)"]:::config
        Docs["Documentation (README.md)"]:::config
        Gemini["Google Gemini API"]:::external
    end

    %% Data Flow
    User(("User"))
    User --> Frontend
    Frontend --> App
    App --> Extractor
    Extractor --> App
    App --> LLM
    LLM --> Gemini
    Gemini --> LLM
    LLM --> App
    App --> Frontend
    Frontend --> User

    %% Config & Docs Associations
    App -.->|uses| Config
    App -.->|uses| Deps
    App -.->|references| Docs

    %% Click Events
    click Frontend "https://github.com/mr-vicky-01/legal-doc-analyzer/blob/main/app.py"
    click App "https://github.com/mr-vicky-01/legal-doc-analyzer/blob/main/app.py"
    click Extractor "https://github.com/mr-vicky-01/legal-doc-analyzer/blob/main/extractor.py"
    click LLM "https://github.com/mr-vicky-01/legal-doc-analyzer/blob/main/llm.py"
    click Config "https://github.com/mr-vicky-01/legal-doc-analyzer/blob/main/.env"
    click Deps "https://github.com/mr-vicky-01/legal-doc-analyzer/blob/main/requirements.txt"
    click Docs "https://github.com/mr-vicky-01/legal-doc-analyzer/blob/main/README.md"

    %% Styling
    classDef frontend fill:#cce5ff,stroke:#4d90fe,stroke-width:2px
    classDef internal fill:#d4edda,stroke:#28a745,stroke-width:2px
    classDef external fill:#ffe5b4,stroke:#ff8c00,stroke-width:2px
    classDef config fill:#f0f0f0,stroke:#999999,stroke-width:2px
```
