# limyire52/aio4_second_project architecture

> Architecture diagram of the GitHub repository limyire52/aio4_second_project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/limyire52/aio4_second_project
- Repository: https://github.com/limyire52/aio4_second_project

## Overview

This repository is a Korean labor-rights analysis API scaffold, with a thin frontend API client. The main workflow is client request → FastAPI route → agent → registered tools → law search → response contract. Separate available capabilities include document fact extraction and masking, wage calculations, law text retrieval, and precedent search; most are currently stubs and are not wired into the main agent flow. The excerpts support the shown calls; no README content was provided.

Main entry points: [`1_agent_backend/api/router.py`](https://github.com/limyire52/aio4_second_project/blob/main/1_agent_backend/api/router.py) (API routes), [`1_agent_backend/agent/tools.py`](https://github.com/limyire52/aio4_second_project/blob/main/1_agent_backend/agent/tools.py) (Tool registry), [`1_agent_backend/agent/graph.py`](https://github.com/limyire52/aio4_second_project/blob/main/1_agent_backend/agent/graph.py) (Agent runner), [`2_data_search/search.py`](https://github.com/limyire52/aio4_second_project/blob/main/2_data_search/search.py) (Law article search)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and client"]
  node_client["Labor API client<br/>[api_client.py]"]
  node_app["FastAPI app<br/>[app.py]"]
  node_router["API routes<br/>[router.py]"]
end

subgraph group_agent["Agent orchestration"]
  node_agent["Agent runner<br/>[graph.py]"]
  node_state["Agent state<br/>[state.py]"]
  node_tools["Tool registry<br/>[tools.py]"]
end

subgraph group_search["Legal information"]
  node_law_search["Law article search<br/>[search.py]"]
  node_law_fetch["Law text retrieval<br/>[fetch.py]"]
  node_precedents["Precedent search<br/>[fetch.py]"]
end

subgraph group_analytics["Document and calculations"]
  node_extract["Document fact extraction<br/>[extract.py]"]
  node_calc["Labor calculations<br/>[calc.py]"]
end

subgraph group_contracts["Response contracts"]
  node_contracts["API contracts<br/>[contracts.py]"]
end

node_developer(("API consumer"))
node_law_service(("Law information service"))

node_developer -->|"submits request"| node_client
node_client -->|"HTTP requests"| node_app
node_app -->|"loads router"| node_router
node_router -->|"runs analysis"| node_agent
node_router -->|"validates requests"| node_contracts
node_agent -->|"gets tools"| node_tools
node_tools -->|"registers search"| node_law_search
node_tools -->|"registers retrieval"| node_law_fetch
node_tools -->|"registers search"| node_precedents
node_tools -->|"registers extraction"| node_extract
node_tools -->|"registers calculation"| node_calc
node_agent -->|"searches laws"| node_law_search
node_router -->|"searches laws"| node_law_search
node_router -->|"searches cases"| node_precedents
node_law_search -.->|"intended lookup"| node_law_service
node_law_fetch -.->|"intended lookup"| node_law_service
node_agent -.->|"state shape"| node_state
node_router -->|"returns responses"| node_client

click node_client "https://github.com/limyire52/aio4_second_project/blob/main/4_frontend/api_client.py"
click node_app "https://github.com/limyire52/aio4_second_project/blob/main/dev/app.py"
click node_router "https://github.com/limyire52/aio4_second_project/blob/main/1_agent_backend/api/router.py"
click node_agent "https://github.com/limyire52/aio4_second_project/blob/main/1_agent_backend/agent/graph.py"
click node_state "https://github.com/limyire52/aio4_second_project/blob/main/1_agent_backend/agent/state.py"
click node_tools "https://github.com/limyire52/aio4_second_project/blob/main/1_agent_backend/agent/tools.py"
click node_contracts "https://github.com/limyire52/aio4_second_project/blob/main/1_agent_backend/schemas/contracts.py"
click node_law_search "https://github.com/limyire52/aio4_second_project/blob/main/2_data_search/search.py"
click node_law_fetch "https://github.com/limyire52/aio4_second_project/blob/main/2_data_search/fetch.py"
click node_precedents "https://github.com/limyire52/aio4_second_project/blob/main/2_data_search/fetch.py"
click node_extract "https://github.com/limyire52/aio4_second_project/blob/main/3_analytics/extract.py"
click node_calc "https://github.com/limyire52/aio4_second_project/blob/main/3_analytics/calc.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_client,node_app,node_router toneBlue
class node_agent,node_state,node_tools toneAmber
class node_law_search,node_law_fetch,node_precedents,node_developer toneMint
class node_extract,node_calc toneRose
class node_contracts,node_law_service toneIndigo
```

## Components

### API and client

- [Labor API client](https://github.com/limyire52/aio4_second_project/blob/main/4_frontend/api_client.py): `4_frontend/api_client.py`
- [FastAPI app](https://github.com/limyire52/aio4_second_project/blob/main/dev/app.py): `dev/app.py`
- [API routes](https://github.com/limyire52/aio4_second_project/blob/main/1_agent_backend/api/router.py): `1_agent_backend/api/router.py`

### Agent orchestration

- [Agent runner](https://github.com/limyire52/aio4_second_project/blob/main/1_agent_backend/agent/graph.py): `1_agent_backend/agent/graph.py`
- [Agent state](https://github.com/limyire52/aio4_second_project/blob/main/1_agent_backend/agent/state.py): `1_agent_backend/agent/state.py`
- [Tool registry](https://github.com/limyire52/aio4_second_project/blob/main/1_agent_backend/agent/tools.py): `1_agent_backend/agent/tools.py`

### Legal information

- [Law article search](https://github.com/limyire52/aio4_second_project/blob/main/2_data_search/search.py): `2_data_search/search.py`
- [Law text retrieval](https://github.com/limyire52/aio4_second_project/blob/main/2_data_search/fetch.py): `2_data_search/fetch.py`
- [Precedent search](https://github.com/limyire52/aio4_second_project/blob/main/2_data_search/fetch.py): `2_data_search/fetch.py`

### Document and calculations

- [Document fact extraction](https://github.com/limyire52/aio4_second_project/blob/main/3_analytics/extract.py): `3_analytics/extract.py`
- [Labor calculations](https://github.com/limyire52/aio4_second_project/blob/main/3_analytics/calc.py): `3_analytics/calc.py`

### Response contracts

- [API contracts](https://github.com/limyire52/aio4_second_project/blob/main/1_agent_backend/schemas/contracts.py): `1_agent_backend/schemas/contracts.py`

### Other components

- **API consumer**
- **Law information service**

## Connections

- API consumer → Labor API client: submits request (evidence: `4_frontend/api_client.py`)
- Labor API client → FastAPI app: HTTP requests (evidence: `4_frontend/api_client.py`)
- FastAPI app → API routes: loads router (evidence: `dev/app.py`)
- API routes → Agent runner: runs analysis (evidence: `1_agent_backend/api/router.py`)
- API routes → API contracts: validates requests (evidence: `1_agent_backend/api/router.py`)
- Agent runner → Tool registry: gets tools (evidence: `1_agent_backend/agent/graph.py`)
- Tool registry → Law article search: registers search (evidence: `1_agent_backend/agent/tools.py`)
- Tool registry → Law text retrieval: registers retrieval (evidence: `1_agent_backend/agent/tools.py`)
- Tool registry → Precedent search: registers search (evidence: `1_agent_backend/agent/tools.py`)
- Tool registry → Document fact extraction: registers extraction (evidence: `1_agent_backend/agent/tools.py`)
- Tool registry → Labor calculations: registers calculation (evidence: `1_agent_backend/agent/tools.py`)
- Agent runner → Law article search: searches laws (evidence: `1_agent_backend/agent/graph.py`)
- API routes → Law article search: searches laws (evidence: `1_agent_backend/api/router.py`)
- API routes → Precedent search: searches cases (evidence: `1_agent_backend/api/router.py`)
- Law article search → Law information service: intended lookup
- Law text retrieval → Law information service: intended lookup
- Agent runner → Agent state: state shape
- API routes → Labor API client: returns responses (evidence: `4_frontend/api_client.py`)
