# weeehung/nearaihack25 architecture

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

- Interactive diagram: https://gitdiagram.com/weeehung/nearaihack25
- Repository: https://github.com/weeehung/nearaihack25

## Overview

##### Project Type and Purpose
- Project type: A Python-based, modular AI framework for automating company due diligence.
- Purpose: Orchestrate specialized “agents” (small AI services) via a workflow engine (PocketFlow), process heterogeneous inputs, and generate a unified due-diligence report.

##### File Structure
- Root:
– agent.py: entry point (CLI/controller).
– requirements.txt, metadata.json, tests/: self-contained Python package.
- agents/ directory:
– One module per domain-expert agent (Screening, Market_analysis, Competitors, Team_eval, Tech_dd, Due_dillegence_report, Final_decision).
– base_agent.py and format.py: shared abstractions & data formats.
- No persistent database—data flows in memory or files.
- External dependencies: OpenAI (or other LLM providers), JSON/text/URL/PDF parsers.

##### README for Additional Insights
- PocketFlow integration: each agent is a “node” in a Flow graph.
- Data Sharing: agents exchange structured insights.
- Aggregation: final report agent collates all partial analyses, then final decision agent produces recommendations.

##### Main Components and Their Relationships
a. User Interface / Orchestration Layer
– agent.py (CLI): accepts company name and inputs → invokes Flow.
– PocketFlow Engine: coordinates execution order, parallelism, and data routing between agents.

b. Specialized Agents (Processing Nodes)
– ScreeningAgent
– MarketAnalysisAgent
– CompetitorsAgent
– TeamEvaluationAgent
– TechnicalDueDiligenceAgent
– DueDiligenceReportAgent (aggregator)
– FinalDecisionAgent

c. External Services and Data Sources
– LLM Provider (OpenAI API) for natural‐language analysis.
– Websites, documents (PDF/HTML), databases via HTTP/JSON inputs.

d. Outputs
– Final report (Markdown, JSON, PDF).
– Optional integration points (downstream analytics, dashboards).

##### Architectural Patterns and Design Principles
- Workflow/Orchestration Pattern: PocketFlow defines directed acyclic graph (DAG) of agent nodes.
- Modular, Pluggable Agents: each agent encapsulates one domain of expertise.
- Data-Flow Architecture: explicit data tokens pass between nodes.
- Separation of Concerns: CLI, orchestration, processing, and reporting are distinct layers.
- Extensibility: add new agents by implementing BaseAgent and plugging into the Flow.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Ingestion & Orchestration"
        CLI["CLI / Controller"]:::orchestration
        Orchestrator["PocketFlow Orchestrator"]:::orchestration
    end

    subgraph "Shared Abstractions"
        Base["BaseAgent"]:::util
        Fmt["Data Formats / Report Formatting"]:::util
    end

    subgraph "Processing Agents"
        Scr["ScreeningAgent"]:::agent
        MA["MarketAnalysisAgent"]:::agent
        Comp["CompetitorsAgent"]:::agent
        Team["TeamEvaluationAgent"]:::agent
        Tech["TechnicalDueDiligenceAgent"]:::agent
        ReportAgg["DueDiligenceReportAgent"]:::agent
        Final["FinalDecisionAgent"]:::agent
    end

    subgraph "External Services"
        LLM["LLM Provider (OpenAI API)"]:::external
        DataSrc["Data Sources (Web/PDF/JSON)"]:::external
    end

    subgraph "Output & Persistence"
        ReportGen["Report Generator"]:::output
        Storage["Storage / Downstream Systems"]:::output
    end

    CLI --> Orchestrator
    Base -.-> Scr
    Base -.-> MA
    Base -.-> Comp
    Base -.-> Team
    Base -.-> Tech
    Fmt -.-> Scr
    Fmt -.-> MA
    Fmt -.-> Comp
    Fmt -.-> Team
    Fmt -.-> Tech

    Orchestrator --> Scr
    Orchestrator --> MA
    Orchestrator --> Comp
    Orchestrator --> Team
    Orchestrator --> Tech

    DataSrc --> Scr

    LLM --- Scr
    LLM --- MA
    LLM --- Comp
    LLM --- Team
    LLM --- Tech

    Scr -->|"JSON insights"| ReportAgg
    MA -->|"JSON insights"| ReportAgg
    Comp -->|"JSON insights"| ReportAgg
    Team -->|"JSON insights"| ReportAgg
    Tech -->|"JSON insights"| ReportAgg

    ReportAgg -->|"Aggregated report"| Final
    Final -->|"Final report"| ReportGen
    ReportGen -->|"Persisted report"| Storage

    click CLI "https://github.com/weeehung/nearaihack25/blob/main/agent.py"
    click Orchestrator "https://github.com/weeehung/nearaihack25/blob/main/agent.py"
    click Scr "https://github.com/weeehung/nearaihack25/blob/main/agents/Screening_agent.py"
    click MA "https://github.com/weeehung/nearaihack25/blob/main/agents/Market_analysis_agent.py"
    click Comp "https://github.com/weeehung/nearaihack25/blob/main/agents/competitors_agent.py"
    click Team "https://github.com/weeehung/nearaihack25/blob/main/agents/Team_eval_agent.py"
    click Tech "https://github.com/weeehung/nearaihack25/blob/main/agents/Tech_dd_agent.py"
    click ReportAgg "https://github.com/weeehung/nearaihack25/blob/main/agents/Due_dillegence_report_agent.py"
    click Final "https://github.com/weeehung/nearaihack25/blob/main/agents/final_decision_agent.py"
    click Base "https://github.com/weeehung/nearaihack25/blob/main/agents/base_agent.py"
    click Fmt "https://github.com/weeehung/nearaihack25/blob/main/agents/format.py"

    classDef orchestration fill:#EEF5FF,stroke:#3B83BD,color:#0B3C5D
    classDef agent fill:#E8F6E8,stroke:#28A745,color:#1D5E1D
    classDef external fill:#FFF4E5,stroke:#F39C12,color:#7A4B00
    classDef output fill:#F5E8FF,stroke:#8E44AD,color:#4E2A4E
    classDef util fill:#F0F0F0,stroke:#CCCCCC,color:#555555
```
