# kerb0y/authenkixx-gen-ai architecture

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

- Interactive diagram: https://gitdiagram.com/kerb0y/authenkixx-gen-ai
- Repository: https://github.com/kerb0y/authenkixx-gen-ai

## Overview

This is a prototype Indonesian shop-assistant API. Its main workflow accepts a message from the Full-Stack backend, preprocesses it, classifies intent, retrieves dummy FAQ/product context, applies out-of-context refusal checks, and returns a RAG/template answer or an intent-specific manual-order/owner response. Optional generative AI can replace the RAG answer when configured. The README documents the broader routing and dummy-data capabilities; the graph omits unsampled implementation details and does not imply real order or complaint processing.

Main entry points: [`app/main.py`](https://github.com/kerb0y/authenkixx-gen-ai/blob/main/app/main.py) (Chat API), [`app/rag.py`](https://github.com/kerb0y/authenkixx-gen-ai/blob/main/app/rag.py) (TF-IDF retriever), [`app/classifier.py`](https://github.com/kerb0y/authenkixx-gen-ai/blob/main/app/classifier.py) (Intent classifier), [`app/refusal.py`](https://github.com/kerb0y/authenkixx-gen-ai/blob/main/app/refusal.py) (Refusal checker)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["API workflow"]
  node_api["Chat API<br/>[main.py]"]
end

subgraph group_understanding["Intent and guardrails"]
  node_preprocess["Text preprocessing<br/>[preprocessing.py]"]
  node_classifier["Intent classifier<br/>[classifier.py]"]
  node_refusal["Refusal checker<br/>[refusal.py]"]
  node_keyword_guard["Keyword guardrail<br/>[main.py]"]
end

subgraph group_knowledge["Dummy knowledge"]
  node_retriever["TF-IDF retriever<br/>[rag.py]"]
  node_intent_data["Intent examples<br/>[dummy_intents.csv]"]
  node_faq_data["FAQ examples<br/>[dummy_faq.csv]"]
  node_product_data["Product catalogue<br/>[dummy_products.csv]"]
end

subgraph group_responses["Answer routing"]
  node_prompt_builder["Prompt and route rules<br/>[prompts.py]"]
  node_manual_order["Manual-order reply<br/>[prompts.py]"]
  node_owner_route["Owner complaint reply<br/>[prompts.py]"]
end

subgraph group_integrations["External services"]
  node_genai["Generative client<br/>[generative.py]"]
  node_model_service(("Generative model service"))
end

node_backend(("Full-Stack backend"))

node_backend -->|"sends request"| node_api
node_api -->|"returns response"| node_backend
node_api -->|"cleans message"| node_preprocess
node_api -->|"checks topics"| node_keyword_guard
node_api -->|"classifies intent"| node_classifier
node_api -->|"retrieves context"| node_retriever
node_api -->|"checks refusal"| node_refusal
node_classifier -->|"trains from"| node_intent_data
node_retriever -->|"loads documents"| node_faq_data
node_retriever -->|"loads documents"| node_product_data
node_api -->|"builds prompt"| node_prompt_builder
node_api -->|"returns order guidance"| node_manual_order
node_api -->|"returns complaint guidance"| node_owner_route
node_api -->|"requests generation"| node_genai
node_genai -->|"sends prompt"| node_model_service
node_refusal -->|"loads examples"| node_intent_data

click node_api "https://github.com/kerb0y/authenkixx-gen-ai/blob/main/app/main.py"
click node_preprocess "https://github.com/kerb0y/authenkixx-gen-ai/blob/main/app/preprocessing.py"
click node_classifier "https://github.com/kerb0y/authenkixx-gen-ai/blob/main/app/classifier.py"
click node_refusal "https://github.com/kerb0y/authenkixx-gen-ai/blob/main/app/refusal.py"
click node_keyword_guard "https://github.com/kerb0y/authenkixx-gen-ai/blob/main/app/main.py"
click node_retriever "https://github.com/kerb0y/authenkixx-gen-ai/blob/main/app/rag.py"
click node_intent_data "https://github.com/kerb0y/authenkixx-gen-ai/blob/main/data/dummy_intents.csv"
click node_faq_data "https://github.com/kerb0y/authenkixx-gen-ai/blob/main/data/dummy_faq.csv"
click node_product_data "https://github.com/kerb0y/authenkixx-gen-ai/blob/main/data/dummy_products.csv"
click node_prompt_builder "https://github.com/kerb0y/authenkixx-gen-ai/blob/main/app/prompts.py"
click node_manual_order "https://github.com/kerb0y/authenkixx-gen-ai/blob/main/app/prompts.py"
click node_owner_route "https://github.com/kerb0y/authenkixx-gen-ai/blob/main/app/prompts.py"
click node_genai "https://github.com/kerb0y/authenkixx-gen-ai/blob/main/app/generative.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_api toneBlue
class node_preprocess,node_classifier,node_refusal,node_keyword_guard toneAmber
class node_retriever,node_intent_data,node_faq_data,node_product_data toneMint
class node_prompt_builder,node_manual_order,node_owner_route toneRose
class node_genai,node_model_service,node_backend toneIndigo
```

## Components

### API workflow

- [Chat API](https://github.com/kerb0y/authenkixx-gen-ai/blob/main/app/main.py): `app/main.py`

### Intent and guardrails

- [Text preprocessing](https://github.com/kerb0y/authenkixx-gen-ai/blob/main/app/preprocessing.py): `app/preprocessing.py`
- [Intent classifier](https://github.com/kerb0y/authenkixx-gen-ai/blob/main/app/classifier.py): `app/classifier.py`
- [Refusal checker](https://github.com/kerb0y/authenkixx-gen-ai/blob/main/app/refusal.py): `app/refusal.py`
- [Keyword guardrail](https://github.com/kerb0y/authenkixx-gen-ai/blob/main/app/main.py): `app/main.py`

### Dummy knowledge

- [TF-IDF retriever](https://github.com/kerb0y/authenkixx-gen-ai/blob/main/app/rag.py): `app/rag.py`
- [Intent examples](https://github.com/kerb0y/authenkixx-gen-ai/blob/main/data/dummy_intents.csv): `data/dummy_intents.csv`
- [FAQ examples](https://github.com/kerb0y/authenkixx-gen-ai/blob/main/data/dummy_faq.csv): `data/dummy_faq.csv`
- [Product catalogue](https://github.com/kerb0y/authenkixx-gen-ai/blob/main/data/dummy_products.csv): `data/dummy_products.csv`

### Answer routing

- [Prompt and route rules](https://github.com/kerb0y/authenkixx-gen-ai/blob/main/app/prompts.py): `app/prompts.py`
- [Manual-order reply](https://github.com/kerb0y/authenkixx-gen-ai/blob/main/app/prompts.py): `app/prompts.py`
- [Owner complaint reply](https://github.com/kerb0y/authenkixx-gen-ai/blob/main/app/prompts.py): `app/prompts.py`

### External services

- [Generative client](https://github.com/kerb0y/authenkixx-gen-ai/blob/main/app/generative.py): `app/generative.py`
- **Generative model service**

### Other components

- **Full-Stack backend**

## Connections

- Full-Stack backend → Chat API: sends request (evidence: `README.md`)
- Chat API → Full-Stack backend: returns response (evidence: `app/main.py`)
- Chat API → Text preprocessing: cleans message (evidence: `app/main.py`)
- Chat API → Keyword guardrail: checks topics (evidence: `app/main.py`)
- Chat API → Intent classifier: classifies intent (evidence: `app/main.py`)
- Chat API → TF-IDF retriever: retrieves context (evidence: `app/main.py`)
- Chat API → Refusal checker: checks refusal (evidence: `app/main.py`)
- Intent classifier → Intent examples: trains from (evidence: `app/classifier.py`)
- TF-IDF retriever → FAQ examples: loads documents (evidence: `app/rag.py`)
- TF-IDF retriever → Product catalogue: loads documents (evidence: `app/rag.py`)
- Chat API → Prompt and route rules: builds prompt (evidence: `app/main.py`)
- Chat API → Manual-order reply: returns order guidance (evidence: `app/main.py`)
- Chat API → Owner complaint reply: returns complaint guidance (evidence: `app/main.py`)
- Chat API → Generative client: requests generation (evidence: `app/main.py`)
- Generative client → Generative model service: sends prompt (evidence: `app/generative.py`)
- Refusal checker → Intent examples: loads examples (evidence: `app/refusal.py`)
