# nguyenthien079/kltn_new architecture

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

- Interactive diagram: https://gitdiagram.com/nguyenthien079/kltn_new
- Repository: https://github.com/nguyenthien079/kltn_new

## Overview

This is a Vietnamese medical named-entity recognition application with a React interface and FastAPI backend. The primary workflow accepts text or a URL, requests NER analysis, and displays detected entities and confidence scores. Separate workflows crawl medical content, process stored articles into normalized and deduplicated sentences, and support expert labeling, review, and administration. The README documents the model ensemble and training capabilities; source excerpts specifically confirm the API setup, asynchronous article-processing jobs, and inference wrapper. Several router and UI internals were not sampled, so those links are shown at subsystem level.

Main entry points: [`medical-ner/backend/app/database.py`](https://github.com/nguyenthien079/kltn_new/blob/main/medical-ner/backend/app/database.py) (Async database access), [`medical-ner/backend/app/routers`](https://github.com/nguyenthien079/kltn_new/tree/main/medical-ner/backend/app/routers) (API routers), [`medical-ner/backend/app/pipeline/pipeline.py`](https://github.com/nguyenthien079/kltn_new/blob/main/medical-ner/backend/app/pipeline/pipeline.py) (Article text pipeline), [`medical-ner/frontend/src/services/api.js`](https://github.com/nguyenthien079/kltn_new/blob/main/medical-ner/frontend/src/services/api.js) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["User interface"]
  node_app["Application UI<br/>[App.jsx]"]
  node_api_client["API client<br/>[api.js]"]
  node_label_ui["Label and review UI"]
end

subgraph group_api["API and access"]
  node_api_app["FastAPI app<br/>[main.py]"]
  node_routers["API routers"]
  node_auth["Authentication<br/>[auth.py]"]
end

subgraph group_content["Content workflows"]
  node_crawler["Medical site crawler<br/>[crawler.py]"]
  node_site_adapters["Site adapters"]
  node_text_pipeline["Article text pipeline<br/>[pipeline.py]"]
  node_segmenter["Sentence segmenter<br/>[segmenter.py]"]
  node_normalizer["Sentence normalizer<br/>[normalizer.py]"]
  node_deduplicator["Sentence deduplicator<br/>[deduplicator.py]"]
  node_labeling["Labeling and review"]
end

subgraph group_recognition["NER and training"]
  node_ner_router["NER endpoints<br/>[ner.py]"]
  node_inference["Inference wrapper<br/>[inference.py]"]
  node_ensemble["Extractor ensemble<br/>[ensemble.py]"]
  node_extractors["NER extractors"]
  node_ner_pipeline["Rule and dictionary NER<br/>[pipeline.py]"]
  node_trainer["Model training<br/>[trainer.py]"]
end

subgraph group_persistence["Persistence"]
  node_database["Async database access<br/>[database.py]"]
  node_records["Application records"]
  node_db[("Relational database")]
end

node_user(("User"))
node_medical_sites(("Medical websites"))

node_user -->|"uses"| node_app
node_app -->|"requests analysis"| node_api_client
node_api_client -->|"HTTP requests"| node_api_app
node_api_app -->|"dispatches routes"| node_routers
node_routers -->|"checks access"| node_auth
node_routers -->|"routes NER"| node_ner_router
node_ner_router -->|"requests predictions"| node_inference
node_inference -->|"extracts entities"| node_ensemble
node_ensemble -->|"combines predictions"| node_extractors
node_ner_router -.->|"uses rule pipeline"| node_ner_pipeline
node_api_client -->|"labeling requests"| node_labeling
node_labeling -->|"serves labeling data"| node_label_ui
node_routers -->|"starts crawling"| node_crawler
node_crawler -->|"selects site parser"| node_site_adapters
node_site_adapters -->|"fetches content"| node_medical_sites
node_routers -->|"starts processing"| node_text_pipeline
node_text_pipeline -->|"segments text"| node_segmenter
node_text_pipeline -->|"normalizes sentences"| node_normalizer
node_text_pipeline -->|"finds duplicates"| node_deduplicator
node_text_pipeline -->|"reads and writes"| node_database
node_crawler -->|"stores articles"| node_database
node_database -->|"queries and commits"| node_db
node_database -->|"maps records"| node_records
node_labeling -->|"reads and updates"| node_database
node_trainer -.->|"uses training data"| node_database

click node_app "https://github.com/nguyenthien079/kltn_new/blob/main/medical-ner/frontend/src/App.jsx"
click node_api_client "https://github.com/nguyenthien079/kltn_new/blob/main/medical-ner/frontend/src/services/api.js"
click node_label_ui "https://github.com/nguyenthien079/kltn_new/tree/main/medical-ner/frontend/src/components"
click node_api_app "https://github.com/nguyenthien079/kltn_new/blob/main/medical-ner/backend/app/main.py"
click node_routers "https://github.com/nguyenthien079/kltn_new/tree/main/medical-ner/backend/app/routers"
click node_auth "https://github.com/nguyenthien079/kltn_new/blob/main/medical-ner/backend/app/auth.py"
click node_crawler "https://github.com/nguyenthien079/kltn_new/blob/main/medical-ner/backend/app/crawler/crawler.py"
click node_site_adapters "https://github.com/nguyenthien079/kltn_new/tree/main/medical-ner/backend/app/crawler/sites"
click node_text_pipeline "https://github.com/nguyenthien079/kltn_new/blob/main/medical-ner/backend/app/pipeline/pipeline.py"
click node_segmenter "https://github.com/nguyenthien079/kltn_new/blob/main/medical-ner/backend/app/pipeline/segmenter.py"
click node_normalizer "https://github.com/nguyenthien079/kltn_new/blob/main/medical-ner/backend/app/pipeline/normalizer.py"
click node_deduplicator "https://github.com/nguyenthien079/kltn_new/blob/main/medical-ner/backend/app/pipeline/deduplicator.py"
click node_labeling "https://github.com/nguyenthien079/kltn_new/tree/main/medical-ner/backend/app/routers"
click node_ner_router "https://github.com/nguyenthien079/kltn_new/blob/main/medical-ner/backend/app/routers/ner.py"
click node_inference "https://github.com/nguyenthien079/kltn_new/blob/main/medical-ner/backend/app/ml/inference.py"
click node_ensemble "https://github.com/nguyenthien079/kltn_new/blob/main/medical-ner/backend/app/ml/ensemble.py"
click node_extractors "https://github.com/nguyenthien079/kltn_new/tree/main/medical-ner/backend/app/ml/extractors"
click node_ner_pipeline "https://github.com/nguyenthien079/kltn_new/blob/main/medical-ner/backend/app/ner/pipeline.py"
click node_trainer "https://github.com/nguyenthien079/kltn_new/blob/main/medical-ner/backend/app/ml/trainer.py"
click node_database "https://github.com/nguyenthien079/kltn_new/blob/main/medical-ner/backend/app/database.py"
click node_records "https://github.com/nguyenthien079/kltn_new/tree/main/medical-ner/backend/app/models"

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_app,node_api_client,node_label_ui,node_user toneBlue
class node_api_app,node_routers,node_auth toneAmber
class node_crawler,node_site_adapters,node_text_pipeline,node_segmenter,node_normalizer,node_deduplicator,node_labeling toneMint
class node_ner_router,node_inference,node_ensemble,node_extractors,node_ner_pipeline,node_trainer toneRose
class node_database,node_records,node_db,node_medical_sites toneIndigo
```

## Components

### User interface

- [Application UI](https://github.com/nguyenthien079/kltn_new/blob/main/medical-ner/frontend/src/App.jsx): `medical-ner/frontend/src/App.jsx`
- [API client](https://github.com/nguyenthien079/kltn_new/blob/main/medical-ner/frontend/src/services/api.js): `medical-ner/frontend/src/services/api.js`
- [Label and review UI](https://github.com/nguyenthien079/kltn_new/tree/main/medical-ner/frontend/src/components): `medical-ner/frontend/src/components`

### API and access

- [FastAPI app](https://github.com/nguyenthien079/kltn_new/blob/main/medical-ner/backend/app/main.py): `medical-ner/backend/app/main.py`
- [API routers](https://github.com/nguyenthien079/kltn_new/tree/main/medical-ner/backend/app/routers): `medical-ner/backend/app/routers`
- [Authentication](https://github.com/nguyenthien079/kltn_new/blob/main/medical-ner/backend/app/auth.py): `medical-ner/backend/app/auth.py`

### Content workflows

- [Medical site crawler](https://github.com/nguyenthien079/kltn_new/blob/main/medical-ner/backend/app/crawler/crawler.py): `medical-ner/backend/app/crawler/crawler.py`
- [Site adapters](https://github.com/nguyenthien079/kltn_new/tree/main/medical-ner/backend/app/crawler/sites): `medical-ner/backend/app/crawler/sites`
- [Article text pipeline](https://github.com/nguyenthien079/kltn_new/blob/main/medical-ner/backend/app/pipeline/pipeline.py): `medical-ner/backend/app/pipeline/pipeline.py`
- [Sentence segmenter](https://github.com/nguyenthien079/kltn_new/blob/main/medical-ner/backend/app/pipeline/segmenter.py): `medical-ner/backend/app/pipeline/segmenter.py`
- [Sentence normalizer](https://github.com/nguyenthien079/kltn_new/blob/main/medical-ner/backend/app/pipeline/normalizer.py): `medical-ner/backend/app/pipeline/normalizer.py`
- [Sentence deduplicator](https://github.com/nguyenthien079/kltn_new/blob/main/medical-ner/backend/app/pipeline/deduplicator.py): `medical-ner/backend/app/pipeline/deduplicator.py`
- [Labeling and review](https://github.com/nguyenthien079/kltn_new/tree/main/medical-ner/backend/app/routers): `medical-ner/backend/app/routers`

### NER and training

- [NER endpoints](https://github.com/nguyenthien079/kltn_new/blob/main/medical-ner/backend/app/routers/ner.py): `medical-ner/backend/app/routers/ner.py`
- [Inference wrapper](https://github.com/nguyenthien079/kltn_new/blob/main/medical-ner/backend/app/ml/inference.py): `medical-ner/backend/app/ml/inference.py`
- [Extractor ensemble](https://github.com/nguyenthien079/kltn_new/blob/main/medical-ner/backend/app/ml/ensemble.py): `medical-ner/backend/app/ml/ensemble.py`
- [NER extractors](https://github.com/nguyenthien079/kltn_new/tree/main/medical-ner/backend/app/ml/extractors): `medical-ner/backend/app/ml/extractors`
- [Rule and dictionary NER](https://github.com/nguyenthien079/kltn_new/blob/main/medical-ner/backend/app/ner/pipeline.py): `medical-ner/backend/app/ner/pipeline.py`
- [Model training](https://github.com/nguyenthien079/kltn_new/blob/main/medical-ner/backend/app/ml/trainer.py): `medical-ner/backend/app/ml/trainer.py`

### Persistence

- [Async database access](https://github.com/nguyenthien079/kltn_new/blob/main/medical-ner/backend/app/database.py): `medical-ner/backend/app/database.py`
- [Application records](https://github.com/nguyenthien079/kltn_new/tree/main/medical-ner/backend/app/models): `medical-ner/backend/app/models`
- **Relational database**

### Other components

- **User**
- **Medical websites**

## Connections

- User → Application UI: uses
- Application UI → API client: requests analysis
- API client → FastAPI app: HTTP requests
- FastAPI app → API routers: dispatches routes
- API routers → Authentication: checks access
- API routers → NER endpoints: routes NER
- NER endpoints → Inference wrapper: requests predictions
- Inference wrapper → Extractor ensemble: extracts entities
- Extractor ensemble → NER extractors: combines predictions
- NER endpoints → Rule and dictionary NER: uses rule pipeline
- API client → Labeling and review: labeling requests
- Labeling and review → Label and review UI: serves labeling data
- API routers → Medical site crawler: starts crawling
- Medical site crawler → Site adapters: selects site parser
- Site adapters → Medical websites: fetches content
- API routers → Article text pipeline: starts processing
- Article text pipeline → Sentence segmenter: segments text
- Article text pipeline → Sentence normalizer: normalizes sentences
- Article text pipeline → Sentence deduplicator: finds duplicates
- Article text pipeline → Async database access: reads and writes
- Medical site crawler → Async database access: stores articles
- Async database access → Relational database: queries and commits
- Async database access → Application records: maps records
- Labeling and review → Async database access: reads and updates
- Model training → Async database access: uses training data
