# millionchau/qualityservice architecture

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

- Interactive diagram: https://gitdiagram.com/millionchau/qualityservice
- Repository: https://github.com/millionchau/qualityservice

## Overview

DevRadar Quality Service accepts article text, cleans and protects content, normalizes Vietnamese/teencode and typos, segments words, classifies IT relevance and toxicity, evaluates quality rules, and returns a score with statistics and issues. The API also supports relabeling and listing stored results. The graph reflects the sampled pipeline and route wiring; documented capabilities such as fuzzy-search fallback are included, while unsampled internal details are represented only at their supported directory boundary.

Main entry points: [`app/pipeline/pipeline.py`](https://github.com/millionchau/qualityservice/blob/development/app/pipeline/pipeline.py) (Analysis pipeline), [`app/api/routes/analyze.py`](https://github.com/millionchau/qualityservice/blob/development/app/api/routes/analyze.py) (Quality routes), [`app/services/quality_service.py`](https://github.com/millionchau/qualityservice/blob/development/app/services/quality_service.py) (Quality service), [`app/clients/mongo_client.py`](https://github.com/millionchau/qualityservice/blob/development/app/clients/mongo_client.py) (MongoDB client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API and service"]
  node_app["FastAPI app<br/>[main.py]"]
  node_routes["Quality routes<br/>[analyze.py]"]
  node_service["Quality service<br/>[quality_service.py]"]
  node_schemas["Quality schemas<br/>[quality.py]"]
end

subgraph group_text["Text processing"]
  node_pipeline["Analysis pipeline<br/>[pipeline.py]"]
  node_cleaner["Content cleaner<br/>[cleaner.py]"]
  node_normalizer["Text normalizer<br/>[normalizer.py]"]
  node_dictionary["Term dictionary<br/>[aho_corasick.py]"]
  node_it_terms["IT keywords<br/>[it_keywords.json]"]
  node_toxic_terms["Toxic keywords"]
  node_tokenizer["Vietnamese tokenizer<br/>[tokenizer.py]"]
end

subgraph group_classification["Classification"]
  node_classifier["Classifier pipeline<br/>[classifier.py]"]
  node_it_model["IT classifier<br/>[it_classifier.py]"]
  node_toxic_model["Toxic classifier"]
  node_models["Saved models"]
end

subgraph group_quality["Quality assessment"]
  node_analyzer["Rule analysis"]
  node_rules["Quality rules"]
  node_scorer["Quality scorer<br/>[scorer.py]"]
end

subgraph group_persistence["Persistence and search"]
  node_mongo_client["MongoDB client<br/>[mongo_client.py]"]
  node_mongo[("MongoDB Atlas")]
  node_es_client["Elasticsearch client"]
  node_elasticsearch[("Elasticsearch")]
end

node_caller(("API caller"))

node_caller -->|"submits article"| node_routes
node_routes -->|"analyzes article"| node_service
node_service -->|"processes text"| node_pipeline
node_pipeline -->|"cleans and protects"| node_cleaner
node_pipeline -->|"normalizes text"| node_normalizer
node_normalizer -->|"replaces terms"| node_dictionary
node_pipeline -->|"segments text"| node_tokenizer
node_pipeline -->|"classifies text"| node_classifier
node_classifier -->|"predicts IT relevance"| node_it_model
node_classifier -->|"predicts toxicity"| node_toxic_model
node_pipeline -->|"evaluates quality"| node_analyzer
node_analyzer -->|"applies rules"| node_rules
node_pipeline -->|"calculates score"| node_scorer
node_pipeline -->|"returns result"| node_schemas
node_service -->|"saves result"| node_mongo_client
node_routes -->|"updates labels or lists"| node_mongo_client
node_mongo_client -->|"reads and writes"| node_mongo
node_normalizer -.->|"fuzzy-search fallback"| node_es_client
node_es_client -.->|"searches terms"| node_elasticsearch
node_it_model -->|"loads keywords"| node_it_terms
node_toxic_model -->|"loads keywords"| node_toxic_terms
node_it_model -->|"loads classifier artifacts"| node_models
node_toxic_model -->|"loads classifier artifacts"| node_models
node_app -->|"registers routers"| node_routes
node_app -->|"initializes service"| node_service
node_app -->|"connects on startup"| node_mongo_client

click node_app "https://github.com/millionchau/qualityservice/blob/development/app/main.py"
click node_routes "https://github.com/millionchau/qualityservice/blob/development/app/api/routes/analyze.py"
click node_service "https://github.com/millionchau/qualityservice/blob/development/app/services/quality_service.py"
click node_schemas "https://github.com/millionchau/qualityservice/blob/development/app/schemas/quality.py"
click node_pipeline "https://github.com/millionchau/qualityservice/blob/development/app/pipeline/pipeline.py"
click node_cleaner "https://github.com/millionchau/qualityservice/blob/development/app/pipeline/cleaner.py"
click node_normalizer "https://github.com/millionchau/qualityservice/blob/development/app/pipeline/normalizer.py"
click node_dictionary "https://github.com/millionchau/qualityservice/blob/development/app/dictionary/aho_corasick.py"
click node_it_terms "https://github.com/millionchau/qualityservice/blob/development/app/dictionaries/it_keywords.json"
click node_toxic_terms "https://github.com/millionchau/qualityservice/blob/development/app/dictionaries/toxic_keywords.json"
click node_tokenizer "https://github.com/millionchau/qualityservice/blob/development/app/pipeline/tokenizer.py"
click node_classifier "https://github.com/millionchau/qualityservice/blob/development/app/pipeline/classifier.py"
click node_it_model "https://github.com/millionchau/qualityservice/blob/development/app/models/it_classifier.py"
click node_toxic_model "https://github.com/millionchau/qualityservice/blob/development/app/models/toxic_classifier.py"
click node_models "https://github.com/millionchau/qualityservice/tree/development/app/models/saved"
click node_analyzer "https://github.com/millionchau/qualityservice/blob/development/app/pipeline/quality_analyzer.py"
click node_rules "https://github.com/millionchau/qualityservice/tree/development/app/rules"
click node_scorer "https://github.com/millionchau/qualityservice/blob/development/app/pipeline/scorer.py"
click node_mongo_client "https://github.com/millionchau/qualityservice/blob/development/app/clients/mongo_client.py"
click node_es_client "https://github.com/millionchau/qualityservice/blob/development/app/clients/elasticsearch_client.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_app,node_routes,node_service,node_schemas toneBlue
class node_pipeline,node_cleaner,node_normalizer,node_dictionary,node_it_terms,node_toxic_terms,node_tokenizer toneAmber
class node_classifier,node_it_model,node_toxic_model,node_models,node_caller toneMint
class node_analyzer,node_rules,node_scorer toneRose
class node_mongo_client,node_mongo,node_es_client,node_elasticsearch toneIndigo
```

## Components

### API and service

- [FastAPI app](https://github.com/millionchau/qualityservice/blob/development/app/main.py): `app/main.py`
- [Quality routes](https://github.com/millionchau/qualityservice/blob/development/app/api/routes/analyze.py): `app/api/routes/analyze.py`
- [Quality service](https://github.com/millionchau/qualityservice/blob/development/app/services/quality_service.py): `app/services/quality_service.py`
- [Quality schemas](https://github.com/millionchau/qualityservice/blob/development/app/schemas/quality.py): `app/schemas/quality.py`

### Text processing

- [Analysis pipeline](https://github.com/millionchau/qualityservice/blob/development/app/pipeline/pipeline.py): `app/pipeline/pipeline.py`
- [Content cleaner](https://github.com/millionchau/qualityservice/blob/development/app/pipeline/cleaner.py): `app/pipeline/cleaner.py`
- [Text normalizer](https://github.com/millionchau/qualityservice/blob/development/app/pipeline/normalizer.py): `app/pipeline/normalizer.py`
- [Term dictionary](https://github.com/millionchau/qualityservice/blob/development/app/dictionary/aho_corasick.py): `app/dictionary/aho_corasick.py`
- [IT keywords](https://github.com/millionchau/qualityservice/blob/development/app/dictionaries/it_keywords.json): `app/dictionaries/it_keywords.json`
- [Toxic keywords](https://github.com/millionchau/qualityservice/blob/development/app/dictionaries/toxic_keywords.json): `app/dictionaries/toxic_keywords.json`
- [Vietnamese tokenizer](https://github.com/millionchau/qualityservice/blob/development/app/pipeline/tokenizer.py): `app/pipeline/tokenizer.py`

### Classification

- [Classifier pipeline](https://github.com/millionchau/qualityservice/blob/development/app/pipeline/classifier.py): `app/pipeline/classifier.py`
- [IT classifier](https://github.com/millionchau/qualityservice/blob/development/app/models/it_classifier.py): `app/models/it_classifier.py`
- [Toxic classifier](https://github.com/millionchau/qualityservice/blob/development/app/models/toxic_classifier.py): `app/models/toxic_classifier.py`
- [Saved models](https://github.com/millionchau/qualityservice/tree/development/app/models/saved): `app/models/saved`

### Quality assessment

- [Rule analysis](https://github.com/millionchau/qualityservice/blob/development/app/pipeline/quality_analyzer.py): `app/pipeline/quality_analyzer.py`
- [Quality rules](https://github.com/millionchau/qualityservice/tree/development/app/rules): `app/rules`
- [Quality scorer](https://github.com/millionchau/qualityservice/blob/development/app/pipeline/scorer.py): `app/pipeline/scorer.py`

### Persistence and search

- [MongoDB client](https://github.com/millionchau/qualityservice/blob/development/app/clients/mongo_client.py): `app/clients/mongo_client.py`
- **MongoDB Atlas**
- [Elasticsearch client](https://github.com/millionchau/qualityservice/blob/development/app/clients/elasticsearch_client.py): `app/clients/elasticsearch_client.py`
- **Elasticsearch**

### Other components

- **API caller**

## Connections

- API caller → Quality routes: submits article
- Quality routes → Quality service: analyzes article
- Quality service → Analysis pipeline: processes text
- Analysis pipeline → Content cleaner: cleans and protects
- Analysis pipeline → Text normalizer: normalizes text
- Text normalizer → Term dictionary: replaces terms
- Analysis pipeline → Vietnamese tokenizer: segments text
- Analysis pipeline → Classifier pipeline: classifies text
- Classifier pipeline → IT classifier: predicts IT relevance
- Classifier pipeline → Toxic classifier: predicts toxicity
- Analysis pipeline → Rule analysis: evaluates quality
- Rule analysis → Quality rules: applies rules
- Analysis pipeline → Quality scorer: calculates score
- Analysis pipeline → Quality schemas: returns result
- Quality service → MongoDB client: saves result
- Quality routes → MongoDB client: updates labels or lists
- MongoDB client → MongoDB Atlas: reads and writes
- Text normalizer → Elasticsearch client: fuzzy-search fallback
- Elasticsearch client → Elasticsearch: searches terms
- IT classifier → IT keywords: loads keywords
- Toxic classifier → Toxic keywords: loads keywords
- IT classifier → Saved models: loads classifier artifacts
- Toxic classifier → Saved models: loads classifier artifacts
- FastAPI app → Quality routes: registers routers
- FastAPI app → Quality service: initializes service
- FastAPI app → MongoDB client: connects on startup
