# faizanahmad3/lawgpt_api architecture

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

- Interactive diagram: https://gitdiagram.com/faizanahmad3/lawgpt_api
- Repository: https://github.com/faizanahmad3/lawgpt_api

## Overview

##### Project type and purpose
- From the file tree and README title “LawGPT_api,” this is a standalone Python-based backend API service. Its purpose is to load or index legal documents (PDFs) and expose endpoints that leverage a GPT-based model (probably via an external OpenAI API) to answer legal queries or process legal text.

##### File structure
- Top-level files:
- main.py – application entrypoint, likely defines the HTTP server and routes
- Classes.py – domain or business-logic classes (e.g., PDF loader, query handler)
- utilities.py – helper functions (e.g., PDF parsing, text cleaning, embedding)
- requirements.txt – lists Python dependencies (e.g., FastAPI or Flask, OpenAI SDK, PDF libraries)
- .env – environment variables (e.g., API keys, model settings)
- pdfs_demo/ – sample legal PDF files used for testing or demonstration
- No obvious database directory; PDF files are kept in-filesystem for now.

##### README for additional insights
1. Exposes an HTTP API
2. Reads and processes legal PDFs
3. Sends text to GPT
4. Returns responses to the client

##### Detail
- Call out the .env config loader feeding into runtime
- Sample PDFs folder as a mounted volume or data directory
- Which Python dependencies live in which module (e.g., PDF parser in utilities, OpenAI SDK in business logic)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client
    Client["Client"]:::external

    %% Configuration and Dependencies
    Config["Configuration (.env)"]:::config
    Dependencies["Dependencies (requirements.txt)"]:::config

    %% Internal Modules
    API_Layer["API Layer (main.py)"]:::internal
    Business_Logic["Business Logic Module (Classes.py)"]:::internal
    Utilities["Utilities Module (utilities.py)"]:::internal

    %% Storage and External
    PDF_Storage["PDF Storage (pdfs_demo/)"]:::storage
    External_AI["External AI Service"]:::external

    %% Flow
    Client -->|"HTTP request"| API_Layer
    Config -->|"env vars"| API_Layer
    Dependencies -->|"libraries"| API_Layer

    API_Layer -->|"invoke logic"| Business_Logic
    Business_Logic -->|"parse request"| Utilities
    Utilities -->|"read PDF files"| PDF_Storage
    PDF_Storage -->|"raw text"| Utilities
    Utilities -->|"cleaned text"| Business_Logic

    Business_Logic -->|"GPT prompt"| External_AI
    External_AI -->|"GPT response"| Business_Logic
    Business_Logic -->|"response data"| API_Layer
    API_Layer -->|"JSON response"| Client

    %% Click Events
    click API_Layer "https://github.com/faizanahmad3/lawgpt_api/blob/main/main.py"
    click Business_Logic "https://github.com/faizanahmad3/lawgpt_api/blob/main/Classes.py"
    click Utilities "https://github.com/faizanahmad3/lawgpt_api/blob/main/utilities.py"
    click PDF_Storage "https://github.com/faizanahmad3/lawgpt_api/tree/main/pdfs_demo/"
    click Config "https://github.com/faizanahmad3/lawgpt_api/blob/main/.env"
    click Dependencies "https://github.com/faizanahmad3/lawgpt_api/blob/main/requirements.txt"

    %% Styles
    classDef internal fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef storage fill:#90EE90,stroke:#000,stroke-width:1px
    classDef external fill:#FFA500,stroke:#000,stroke-width:1px
    classDef config fill:#D3D3D3,stroke:#000,stroke-width:1px
```
