# hshaikusa/accountintelligence architecture

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

- Interactive diagram: https://gitdiagram.com/hshaikusa/accountintelligence
- Repository: https://github.com/hshaikusa/accountintelligence

## Overview

##### Project type and purpose
- This is an AI-powered account intelligence system written in Python.
- Purpose: Automate research on client companies by ingesting documents (RAG Dataset), querying via a chat interface, and using auxiliary tools (e.g., calculator).

##### File structure (three levels deep)
Level 1 (top-level):
- AgenticFrameWork.pdf (documentation)
- README.md
- account_intelligence/
- run.py

Level 2 (inside account_intelligence):
- RAG Dataset/
- account_intelligence_ai/

Level 3 (inside account_intelligence_ai):
- app.py (API entrypoint)
- core/
- iteration1/
- tools/

– core/chat_interface.py
– iteration1/factory.py, part1.py, part2.py, part3.py, prompts.py
– tools/calculator.py

##### README for additional insights
- Streams company reports into a RAG-backed retrieval system.
- Exposes a chat interface that synthesizes data via an LLM.
- Uses “tools” to perform auxiliary tasks (e.g., on-the-fly calculations).

##### Main components & their relationships
a. User & Client Applications
– Web or CLI client (external actor)
– Connects over HTTP/gRPC to the API layer in app.py
b. API Layer (app.py + run.py)
– Receives queries
– Routes requests to the Core service
c. Core Service (core/chat_interface.py)
– Orchestrates RAG retrieval, prompt assembly, LLM calls
– Uses iteration1 modules for modular prompt design
d. RAG Data Store (account_intelligence/RAG Dataset)
– Contains PDFs indexed by a vector store (external or in-process)
e. LLM Service (external, e.g., OpenAI API)
– Consumes prompts, returns completions
f. Tool Execution Service (tools/calculator.py)
– Provides deterministic operations plugged into the chat pipeline

##### Architectural patterns & principles
– Layered architecture (API → Core → Data / External Services)
– Modular “iteration1” pattern enabling plug-in prompt factories
– RAG pattern for augmenting LLM responses with retrieved docs
– Separation of concerns: Core logic vs. tool implementations

##### Essential elements
– Clear component names (app.py, chat_interface, RAG Dataset, calculator)
– Three depth levels of hierarchy
– Callouts for protocols and data formats (PDF ingestion, JSON requests)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Client
    Client["Web/CLI Client"]:::external

    %% API Layer
    subgraph "API Layer"
        Run["run.py"]:::service
        App["app.py"]:::service
    end

    %% Core Service
    subgraph "Core Service"
        Core["chat_interface.py"]:::service
        subgraph "Iteration1 Modules"
            Factory["factory.py"]:::service
            Part1["part1.py"]:::service
            Part2["part2.py"]:::service
            Part3["part3.py"]:::service
            Prompts["prompts.py"]:::service
        end
    end

    %% Data Store
    subgraph "RAG Dataset"
        RAG["(PDF & Vector Store)"]:::data
        Indexer["Indexer"]:::data
        Retriever["Retriever"]:::data
    end

    %% Tools
    subgraph "Tool Execution Service"
        Calculator["calculator.py"]:::tool
    end

    %% External Services
    LLM["External LLM API"]:::external

    %% Connections
    Client -->|"HTTP/gRPC"| App
    App -->|"Route Request"| Core
    Core -->|"Retrieve Docs"| Indexer
    Core -->|"Retrieve Vectors"| Retriever
    Indexer --> RAG
    Retriever --> RAG
    Core -->|"Invoke LLM"| LLM
    LLM -->|"LLM Response"| Core
    Core -->|"Use Tool"| Calculator
    Core -->|"Return Response"| App
    App -->|"Response JSON"| Client

    %% Click Events
    click Run "https://github.com/hshaikusa/accountintelligence/blob/main/run.py"
    click App "https://github.com/hshaikusa/accountintelligence/blob/main/account_intelligence/account_intelligence_ai/app.py"
    click Core "https://github.com/hshaikusa/accountintelligence/blob/main/account_intelligence/account_intelligence_ai/core/chat_interface.py"
    click RAG "https://github.com/hshaikusa/accountintelligence/tree/main/account_intelligence/RAG Dataset/"
    click Factory "https://github.com/hshaikusa/accountintelligence/blob/main/account_intelligence/account_intelligence_ai/iteration1/factory.py"
    click Part1 "https://github.com/hshaikusa/accountintelligence/blob/main/account_intelligence/account_intelligence_ai/iteration1/part1.py"
    click Part2 "https://github.com/hshaikusa/accountintelligence/blob/main/account_intelligence/account_intelligence_ai/iteration1/part2.py"
    click Part3 "https://github.com/hshaikusa/accountintelligence/blob/main/account_intelligence/account_intelligence_ai/iteration1/part3.py"
    click Prompts "https://github.com/hshaikusa/accountintelligence/blob/main/account_intelligence/account_intelligence_ai/iteration1/prompts.py"
    click Calculator "https://github.com/hshaikusa/accountintelligence/blob/main/account_intelligence/account_intelligence_ai/tools/calculator.py"

    %% Styles
    classDef service fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef data fill:#9ACD32,stroke:#000,stroke-width:1px
    classDef external fill:#FFD700,stroke:#000,stroke-width:1px
    classDef tool fill:#FFA500,stroke:#000,stroke-width:1px
```
