# 1062goodman/welfare architecture

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

- Interactive diagram: https://gitdiagram.com/1062goodman/welfare
- Repository: https://github.com/1062goodman/welfare

## Overview

This repository implements a Korean welfare-policy chatbot, with a React Native client, FastAPI/LangGraph chat backends, and a Neo4j-backed policy-data workflow. The principal flow is user message → chat API → intent/condition handling and policy search → generated response → mobile display. It also contains baseline and GraphRAG search variants, session cleanup, and voice transcription support in the client API. The README documents the ingestion stages; those links are shown as documented flows. Some backend route and ingestion details were not sampled.

Main entry points: [`back/rag/nodes.py`](https://github.com/1062goodman/welfare/blob/master/back/rag/nodes.py) (RAG model and graph), [`front/welfare-chat-app/app/(tabs)/chat/chat.tsx`](https://github.com/1062goodman/welfare/blob/master/front/welfare-chat-app/app/(tabs)/chat/chat.tsx) (Chat screen), [`back/chat/api.py`](https://github.com/1062goodman/welfare/blob/master/back/chat/api.py) (Chat endpoints), [`front/welfare-chat-app/api/chatApi.ts`](https://github.com/1062goodman/welfare/blob/master/front/welfare-chat-app/api/chatApi.ts) (Chat API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Mobile client"]
  node_chatui["Chat screen<br/>[chat.tsx]"]
  node_session["Session manager<br/>[sessionManager.ts]"]
  node_font["Font preferences"]
  node_clientapi["Chat API client<br/>[chatApi.ts]"]
end

subgraph group_service["Chat service"]
  node_server["FastAPI app<br/>[main.py]"]
  node_router["Chat endpoints<br/>[api.py]"]
  node_workflow["Chat workflow<br/>[graph.py]"]
  node_chatnodes["Chat processing nodes<br/>[nodes.py]"]
  node_prompts["Chat prompts and state<br/>[prompts.py]"]
  node_cleanup["Session cleanup<br/>[tasks.py]"]
  node_threeapi["Three-turn API<br/>[api.py]"]
  node_threenodes["Three-turn nodes<br/>[nodes.py]"]
end

subgraph group_search["Policy search"]
  node_rag["GraphRAG search<br/>[nodes.py]"]
  node_baseline["Baseline RAG<br/>[baseline_nodes.py]"]
  node_ragresources["RAG model and graph<br/>[nodes.py]"]
  node_neo4j[("Neo4j policy store<br/>[db.py]")]
end

subgraph group_ingest["Data ingestion"]
  node_extract["Data extraction<br/>[dataExtraction.py]"]
  node_parse["XML parsing<br/>[parsing.py]"]
  node_crawl["Policy detail crawl<br/>[parsing_crawl.py]"]
end

node_person(("Chat user"))
node_publicapi{{"Public data API"}}
node_upstage{{"Upstage models"}}

node_person -->|"sends message"| node_chatui
node_chatui -->|"gets session"| node_session
node_chatui -->|"uses preferences"| node_font
node_chatui -->|"calls"| node_clientapi
node_clientapi -->|"sends chat request"| node_router
node_clientapi -->|"fetches history"| node_router
node_server -->|"mounts routes"| node_router
node_server -->|"runs cleanup"| node_cleanup
node_router -->|"invokes workflow"| node_workflow
node_workflow -->|"registers nodes"| node_chatnodes
node_chatnodes -->|"uses prompts"| node_prompts
node_chatnodes -->|"uses search resources"| node_ragresources
node_workflow -.->|"shares session memory"| node_cleanup
node_threeapi -.->|"runs alternate flow"| node_threenodes
node_rag -->|"queries graph and embeddings"| node_ragresources
node_baseline -->|"uses graph and embeddings"| node_ragresources
node_ragresources -->|"queries policies"| node_neo4j
node_ragresources -->|"calls LLM and embeddings"| node_upstage
node_publicapi -.->|"provides records"| node_extract
node_extract -->|"produces XML"| node_parse
node_parse -->|"produces JSON"| node_crawl
node_crawl -.->|"loads policy data"| node_neo4j
node_neo4j -->|"supplies policy search"| node_rag

click node_chatui "https://github.com/1062goodman/welfare/blob/master/front/welfare-chat-app/app/(tabs)/chat/chat.tsx"
click node_session "https://github.com/1062goodman/welfare/blob/master/front/welfare-chat-app/utils/sessionManager.ts"
click node_font "https://github.com/1062goodman/welfare/blob/master/front/welfare-chat-app/contexts/font-size-context.tsx"
click node_clientapi "https://github.com/1062goodman/welfare/blob/master/front/welfare-chat-app/api/chatApi.ts"
click node_server "https://github.com/1062goodman/welfare/blob/master/back/chat/main.py"
click node_router "https://github.com/1062goodman/welfare/blob/master/back/chat/api.py"
click node_workflow "https://github.com/1062goodman/welfare/blob/master/back/chat/graph.py"
click node_chatnodes "https://github.com/1062goodman/welfare/blob/master/back/chat/nodes.py"
click node_prompts "https://github.com/1062goodman/welfare/blob/master/back/rag/prompts.py"
click node_cleanup "https://github.com/1062goodman/welfare/blob/master/back/chat/tasks.py"
click node_threeapi "https://github.com/1062goodman/welfare/blob/master/back/chat%203turn/api.py"
click node_threenodes "https://github.com/1062goodman/welfare/blob/master/back/chat%203turn/nodes.py"
click node_rag "https://github.com/1062goodman/welfare/blob/master/back/GraphRAG/nodes.py"
click node_baseline "https://github.com/1062goodman/welfare/blob/master/back/rag/baseline_nodes.py"
click node_ragresources "https://github.com/1062goodman/welfare/blob/master/back/rag/nodes.py"
click node_neo4j "https://github.com/1062goodman/welfare/blob/master/back/data_ext/db.py"
click node_extract "https://github.com/1062goodman/welfare/blob/master/back/data_ext/dataExtraction.py"
click node_parse "https://github.com/1062goodman/welfare/blob/master/back/data_ext/parsing.py"
click node_crawl "https://github.com/1062goodman/welfare/blob/master/back/data_ext/parsing_crawl.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_chatui,node_session,node_font,node_clientapi,node_person toneBlue
class node_server,node_router,node_workflow,node_chatnodes,node_prompts,node_cleanup,node_threeapi,node_threenodes toneAmber
class node_rag,node_baseline,node_ragresources,node_neo4j,node_publicapi toneMint
class node_extract,node_parse,node_crawl toneRose
class node_upstage toneIndigo
```

## Components

### Mobile client

- [Chat screen](https://github.com/1062goodman/welfare/blob/master/front/welfare-chat-app/app/(tabs)/chat/chat.tsx): `front/welfare-chat-app/app/(tabs)/chat/chat.tsx`
- [Session manager](https://github.com/1062goodman/welfare/blob/master/front/welfare-chat-app/utils/sessionManager.ts): `front/welfare-chat-app/utils/sessionManager.ts`
- [Font preferences](https://github.com/1062goodman/welfare/blob/master/front/welfare-chat-app/contexts/font-size-context.tsx): `front/welfare-chat-app/contexts/font-size-context.tsx`
- [Chat API client](https://github.com/1062goodman/welfare/blob/master/front/welfare-chat-app/api/chatApi.ts): `front/welfare-chat-app/api/chatApi.ts`

### Chat service

- [FastAPI app](https://github.com/1062goodman/welfare/blob/master/back/chat/main.py): `back/chat/main.py`
- [Chat endpoints](https://github.com/1062goodman/welfare/blob/master/back/chat/api.py): `back/chat/api.py`
- [Chat workflow](https://github.com/1062goodman/welfare/blob/master/back/chat/graph.py): `back/chat/graph.py`
- [Chat processing nodes](https://github.com/1062goodman/welfare/blob/master/back/chat/nodes.py): `back/chat/nodes.py`
- [Chat prompts and state](https://github.com/1062goodman/welfare/blob/master/back/rag/prompts.py): `back/rag/prompts.py`
- [Session cleanup](https://github.com/1062goodman/welfare/blob/master/back/chat/tasks.py): `back/chat/tasks.py`
- [Three-turn API](https://github.com/1062goodman/welfare/blob/master/back/chat%203turn/api.py): `back/chat 3turn/api.py`
- [Three-turn nodes](https://github.com/1062goodman/welfare/blob/master/back/chat%203turn/nodes.py): `back/chat 3turn/nodes.py`

### Policy search

- [GraphRAG search](https://github.com/1062goodman/welfare/blob/master/back/GraphRAG/nodes.py): `back/GraphRAG/nodes.py`
- [Baseline RAG](https://github.com/1062goodman/welfare/blob/master/back/rag/baseline_nodes.py): `back/rag/baseline_nodes.py`
- [RAG model and graph](https://github.com/1062goodman/welfare/blob/master/back/rag/nodes.py): `back/rag/nodes.py`
- [Neo4j policy store](https://github.com/1062goodman/welfare/blob/master/back/data_ext/db.py): `back/data_ext/db.py`

### Data ingestion

- [Data extraction](https://github.com/1062goodman/welfare/blob/master/back/data_ext/dataExtraction.py): `back/data_ext/dataExtraction.py`
- [XML parsing](https://github.com/1062goodman/welfare/blob/master/back/data_ext/parsing.py): `back/data_ext/parsing.py`
- [Policy detail crawl](https://github.com/1062goodman/welfare/blob/master/back/data_ext/parsing_crawl.py): `back/data_ext/parsing_crawl.py`

### Other components

- **Chat user**
- **Public data API**
- **Upstage models**

## Connections

- Chat user → Chat screen: sends message (evidence: `front/welfare-chat-app/app/(tabs)/chat/chat.tsx`)
- Chat screen → Session manager: gets session (evidence: `front/welfare-chat-app/app/(tabs)/chat/chat.tsx`)
- Chat screen → Font preferences: uses preferences (evidence: `front/welfare-chat-app/app/(tabs)/chat/chat.tsx`)
- Chat screen → Chat API client: calls (evidence: `front/welfare-chat-app/app/(tabs)/chat/chat.tsx`)
- Chat API client → Chat endpoints: sends chat request (evidence: `front/welfare-chat-app/api/chatApi.ts`)
- Chat API client → Chat endpoints: fetches history (evidence: `front/welfare-chat-app/api/chatApi.ts`)
- FastAPI app → Chat endpoints: mounts routes (evidence: `back/chat/main.py`)
- FastAPI app → Session cleanup: runs cleanup (evidence: `back/chat/main.py`)
- Chat endpoints → Chat workflow: invokes workflow (evidence: `back/chat/api.py`)
- Chat workflow → Chat processing nodes: registers nodes (evidence: `back/chat/graph.py`)
- Chat processing nodes → Chat prompts and state: uses prompts (evidence: `back/chat/nodes.py`)
- Chat processing nodes → RAG model and graph: uses search resources (evidence: `back/chat/nodes.py`)
- Chat workflow → Session cleanup: shares session memory
- Three-turn API → Three-turn nodes: runs alternate flow
- GraphRAG search → RAG model and graph: queries graph and embeddings (evidence: `back/GraphRAG/nodes.py`)
- Baseline RAG → RAG model and graph: uses graph and embeddings (evidence: `back/rag/baseline_nodes.py`)
- RAG model and graph → Neo4j policy store: queries policies
- RAG model and graph → Upstage models: calls LLM and embeddings
- Public data API → Data extraction: provides records
- Data extraction → XML parsing: produces XML
- XML parsing → Policy detail crawl: produces JSON
- Policy detail crawl → Neo4j policy store: loads policy data
- Neo4j policy store → GraphRAG search: supplies policy search (evidence: `back/GraphRAG/nodes.py`)
