# aianytime/graphy-v1 architecture

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

- Interactive diagram: https://gitdiagram.com/aianytime/graphy-v1
- Repository: https://github.com/aianytime/graphy-v1

## Overview

##### Project type and purpose
- This is a full-stack, single-page Python Streamlit application (“Graphy v1”) that implements a real‐time Graph Retrieval-Augmented Generation (GraphRAG) workflow.
- It allows users to upload a PDF, extracts entities/relationships via OpenAI LLMs (through LangChain), stores results in Neo4j, and answers natural-language queries by translating them into Cypher.

##### File structure
- Top level:
- main.py (entry point, Streamlit app)
- requirements.txt (dependencies: streamlit, langchain, neo4j, openai…)
- .gitignore, LICENSE, README.md
- No separate “backend” or “frontend” subdirs: the frontend (UI) and backend (processing logic) live in main.py.

##### README for insights
- Key components: Streamlit UI, PDF file ingestion, LangChain + OpenAI integration, Neo4j graph database, natural-language interface.
- Environment configuration via `.env` or sidebar inputs – OpenAI and Neo4j credentials.

##### Essential architectural elements to capture
- The ingestion path: PDF → LangChain → OpenAI → entity/relationship extraction → Neo4j write
- The query path: NL question → LangChain → OpenAI → Cypher generation → Neo4j read → UI response
- Credential/configuration flow feeding into both OpenAI and Neo4j connectors
- Single Streamlit process acting as both server and client in a monolithic layout

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Layer
    User["User/Browser"]:::user

    %% Streamlit App Layer
    subgraph "Streamlit App (main.py)"
        UI["Streamlit UI<br/>(File Uploader, Text Input, Display)"]:::frontend
        Controller["Controller Logic"]:::frontend
        subgraph "Processing Pipeline"
            PDF["PDF Loader & Text Splitter"]:::processing
            LLM["LLM Chain (LangChain/OpenAI)"]:::processing
            Extract["Entity & Relationship Extraction"]:::processing
        end
    end

    %% Configuration
    Config["Configuration Store<br/>(.env / sidebar inputs)"]:::config

    %% External Services
    subgraph "External Services"
        OpenAI["OpenAI API"]:::external
        Neo4j["Neo4j Graph Database"]:::external
    end

    %% Documentation & Manifests
    README["README.md"]:::docs
    Gitignore[".gitignore"]:::docs
    License["LICENSE"]:::docs
    Requirements["requirements.txt"]:::docs

    %% Data Flows
    User -->|Upload PDF / Ask Question| UI
    UI -->|UI events| Controller
    Controller -->|ingest PDF| PDF
    PDF -->|text chunks| LLM
    LLM -->|extraction prompts| Extract
    Extract -->|write nodes & edges| Neo4j
    Neo4j -->|confirmation| Extract
    Extract -->|extracted data| Controller
    Controller -->|render answer| UI

    %% Query Path
    UI -->|NL question| Controller
    Controller -->|prompt for Cypher| LLM
    LLM -->|Cypher query| Neo4j
    Neo4j -->|query results| Controller
    Controller -->|display response| UI

    %% Config Flows
    Config -.->|credentials| Controller
    Config -.->|credentials| LLM
    Config -.->|credentials| Neo4j

    %% Click Events
    click UI "https://github.com/aianytime/graphy-v1/blob/main/main.py"
    click Controller "https://github.com/aianytime/graphy-v1/blob/main/main.py"
    click PDF "https://github.com/aianytime/graphy-v1/blob/main/main.py"
    click LLM "https://github.com/aianytime/graphy-v1/blob/main/main.py"
    click Extract "https://github.com/aianytime/graphy-v1/blob/main/main.py"
    click OpenAI "https://github.com/aianytime/graphy-v1/blob/main/main.py"
    click Neo4j "https://github.com/aianytime/graphy-v1/blob/main/main.py"
    click Config "https://github.com/aianytime/graphy-v1/blob/main/main.py"
    click Requirements "https://github.com/aianytime/graphy-v1/blob/main/requirements.txt"
    click README "https://github.com/aianytime/graphy-v1/blob/main/README.md"
    click Gitignore "https://github.com/aianytime/graphy-v1/blob/main/.gitignore"
    click License "https://github.com/aianytime/graphy-v1/tree/main/LICENSE"

    %% Styles
    classDef user fill:#D0E6A5,stroke:#5A7D3A,color:#2F4F4F;
    classDef frontend fill:#A2D2FF,stroke:#1E3A8A,color:#1E3A8A;
    classDef processing fill:#B8EAEA,stroke:#127475,color:#034748;
    classDef external fill:#FFD6A5,stroke:#FF8C00,color:#7F3608;
    classDef config fill:#E0E0E0,stroke:#666666,color:#333333;
    classDef docs fill:#EADCBD,stroke:#A67C00,color:#5A3E00;
```
