# daphnejudith/ai_legal_agent_team architecture

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

- Interactive diagram: https://gitdiagram.com/daphnejudith/ai_legal_agent_team
- Repository: https://github.com/daphnejudith/ai_legal_agent_team

## Overview

##### Main Components Identification

The system consists of these key components:
- Frontend Interface (Streamlit)
- Agent Coordination Layer
- Specialized AI Agents
- External Services Integration
- Document Processing Pipeline
- Storage/Vector Database

##### Component Relationships

Key interactions:
**User Interface**
- ↓↑
**API Gateway (Security/Validation)**
- ↓↑
**Team Lead Agent (Coordinator)**
- ↓↑
**┌─────────┼─────────┐**
**↓         ↓         ↓**
**Legal     Contract   Legal**
**Researcher Analyst   Strategist**
- ↓         ↓         ↓
**External Services Layer**

##### Technical Details

- Embedding generation points (text-embedding-3-small)
- Document processing pipeline stages
- Vector storage points in Qdrant
- Security checkpoints for API keys

##### Implementation Notes

- Use different line styles for control flow vs data flow
- System boundaries and trust zones
- Rate limiting and caching points
- Where configuration settings apply
- Monitoring and logging points

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and Classes
    classDef frontend fill:#e1f5fe,stroke:#01579b
    classDef agent fill:#fff3e0,stroke:#e65100
    classDef service fill:#e8f5e9,stroke:#1b5e20
    classDef storage fill:#fce4ec,stroke:#880e4f
    classDef integration fill:#f3e5f5,stroke:#4a148c
    
    %% User Interface Layer
    subgraph UI["User Interface Layer"]
        FE["Streamlit Web Interface"]
        DC["Document Upload"]
        AS["Analysis Selector"]
        QI["Query Input"]
        RD["Results Display"]
    end
    
    %% Agent Orchestration Layer
    subgraph AO["Agent Orchestration Layer"]
        TLA["Team Lead Agent"]:::agent
        CB["Communication Bus"]:::agent
        TD["Task Distribution"]:::agent
        RA["Response Aggregator"]:::agent
    end
    
    %% Specialized Agents Layer
    subgraph SA["Specialized Agents Layer"]
        LRA["Legal Researcher Agent"]:::agent
        CAA["Contract Analyst Agent"]:::agent
        LSA["Legal Strategist Agent"]:::agent
    end
    
    %% Service Integration Layer
    subgraph SI["Service Integration Layer"]
        OAI["OpenAI Integration"]:::integration
        GPT["GPT-4 Interface"]:::integration
        EMB["Embedding Service"]:::integration
        DP["Document Processing"]:::service
        DDG["DuckDuckGo API"]:::integration
    end
    
    %% Data Storage Layer
    subgraph DS["Data Storage Layer"]
        QDB[(Qdrant Vector DB)]:::storage
    end
    
    %% Connections
    FE --> DC
    DC --> AS
    AS --> QI
    QI --> RD
    
    DC --> |Document Flow| DP
    DP --> |Processed Text| TLA
    
    TLA --> |Tasks| CB
    CB --> |Distribution| TD
    TD --> |Assignments| LRA & CAA & LSA
    
    LRA --> |Research Results| RA
    CAA --> |Analysis Results| RA
    LSA --> |Strategy Results| RA
    
    LRA --> |Search Query| DDG
    DDG --> |Results| LRA
    
    CAA & LSA --> |API Calls| GPT
    GPT --> |Responses| CAA & LSA
    
    DP --> |Text| EMB
    EMB --> |Vectors| QDB
    
    RA --> |Final Results| RD
    
    %% Click Events
    click FE "https://github.com/DaphneJudith/ai_legal_agent_team/blob/main/client/src/App.tsx"
    click TLA "https://github.com/DaphneJudith/ai_legal_agent_team/blob/main/agent/src/index.ts"
    click LRA "https://github.com/DaphneJudith/ai_legal_agent_team/blob/main/client/src/Agent.tsx"
    click CAA "https://github.com/DaphneJudith/ai_legal_agent_team/blob/main/client/src/Agents.tsx"
    click LSA "https://github.com/DaphneJudith/ai_legal_agent_team/blob/main/local_ai_legal_agent_team/local_legal_agent.py"
    click OAI "https://github.com/DaphneJudith/ai_legal_agent_team/tree/main/client/src/api/"
    click GPT "https://github.com/DaphneJudith/ai_legal_agent_team/tree/main/client/src/api/mutations/"
    click EMB "https://github.com/DaphneJudith/ai_legal_agent_team/tree/main/client/src/api/queries/"
    
    %% Legend
    subgraph Legend
        L1[Frontend Components]:::frontend
        L2[Agent Components]:::agent
        L3[Services]:::service
        L4[Storage]:::storage
        L5[External Integration]:::integration
    end
```
