# louis577-web/chatbot architecture

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

- Interactive diagram: https://gitdiagram.com/louis577-web/chatbot
- Repository: https://github.com/louis577-web/chatbot

## Overview

This Django application provides a French resource-search chatbot: a user submits a question, the service searches FAQ answers and educational resources, and returns a response with sources while recording the conversation. A separate indexing command downloads resource PDFs, extracts and embeds their text, and stores searchable chunks. The sampled code supports those service and indexing links; the views’ request-handling details are not sampled, so their internal routing is shown only at the application boundary.

Main entry points: [`chatbot/services.py`](https://github.com/louis577-web/chatbot/blob/main/chatbot/services.py) (Answer service), [`chatbot/views.py`](https://github.com/louis577-web/chatbot/blob/main/chatbot/views.py) (Chat views), [`chatbot/recherche_contenu.py`](https://github.com/louis577-web/chatbot/blob/main/chatbot/recherche_contenu.py) (PDF text extraction), [`site_principal/models.py`](https://github.com/louis577-web/chatbot/blob/main/site_principal/models.py) (Resource catalog)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web interface"]
  node_urls["Chat routes<br/>[urls.py]"]
  node_views["Chat views<br/>[views.py]"]
  node_templates["Chat pages<br/>[widget.html]"]
end

subgraph group_answer["Question answering"]
  node_services["Answer service<br/>[services.py]"]
  node_faq["FAQ matching<br/>[services.py]"]
  node_docsearch["Document search"]
end

subgraph group_indexing["Document indexing"]
  node_indexcmd["Document indexer"]
  node_extract["PDF text extraction"]
  node_embed["Text embeddings"]
  node_chroma[("Vector index")]
end

subgraph group_data["Persistent data"]
  node_resources[("Resource catalog<br/>[models.py]")]
  node_chatdata[("FAQ and conversations<br/>[models.py]")]
end

node_user(("Chat user"))
node_site_db[("Main-site database")]
node_pdfstore[("PDF object storage")]

node_user -->|"submits question"| node_urls
node_urls -->|"routes request"| node_views
node_views -->|"renders page"| node_templates
node_views -->|"requests answer"| node_services
node_services -->|"matches FAQ"| node_faq
node_faq -->|"reads FAQ"| node_chatdata
node_services -->|"searches documents"| node_docsearch
node_docsearch -->|"queries vectors"| node_chroma
node_services -->|"loads resources"| node_resources
node_resources -->|"reads catalog"| node_site_db
node_services -->|"saves conversation"| node_chatdata
node_services -->|"returns answer"| node_views
node_indexcmd -->|"lists resources"| node_resources
node_indexcmd -->|"indexes resource"| node_extract
node_extract -->|"downloads PDF"| node_pdfstore
node_extract -->|"embeds chunks"| node_embed
node_embed -->|"stores vectors"| node_chroma

click node_urls "https://github.com/louis577-web/chatbot/blob/main/chatbot/urls.py"
click node_views "https://github.com/louis577-web/chatbot/blob/main/chatbot/views.py"
click node_templates "https://github.com/louis577-web/chatbot/blob/main/chatbot/templates/chatbot/widget.html"
click node_services "https://github.com/louis577-web/chatbot/blob/main/chatbot/services.py"
click node_faq "https://github.com/louis577-web/chatbot/blob/main/chatbot/services.py"
click node_docsearch "https://github.com/louis577-web/chatbot/blob/main/chatbot/recherche_contenu.py"
click node_resources "https://github.com/louis577-web/chatbot/blob/main/site_principal/models.py"
click node_chatdata "https://github.com/louis577-web/chatbot/blob/main/chatbot/models.py"
click node_indexcmd "https://github.com/louis577-web/chatbot/blob/main/chatbot/management/commands/indexer_documents.py"
click node_extract "https://github.com/louis577-web/chatbot/blob/main/chatbot/recherche_contenu.py"
click node_embed "https://github.com/louis577-web/chatbot/blob/main/chatbot/recherche_contenu.py"
click node_chroma "https://github.com/louis577-web/chatbot/blob/main/chatbot/recherche_contenu.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_urls,node_views,node_templates,node_user toneBlue
class node_services,node_faq,node_docsearch,node_site_db,node_pdfstore toneAmber
class node_indexcmd,node_extract,node_embed,node_chroma toneMint
class node_resources,node_chatdata toneRose
```

## Components

### Web interface

- [Chat routes](https://github.com/louis577-web/chatbot/blob/main/chatbot/urls.py): `chatbot/urls.py`
- [Chat views](https://github.com/louis577-web/chatbot/blob/main/chatbot/views.py): `chatbot/views.py`
- [Chat pages](https://github.com/louis577-web/chatbot/blob/main/chatbot/templates/chatbot/widget.html): `chatbot/templates/chatbot/widget.html`

### Question answering

- [Answer service](https://github.com/louis577-web/chatbot/blob/main/chatbot/services.py): `chatbot/services.py`
- [FAQ matching](https://github.com/louis577-web/chatbot/blob/main/chatbot/services.py): `chatbot/services.py`
- [Document search](https://github.com/louis577-web/chatbot/blob/main/chatbot/recherche_contenu.py): `chatbot/recherche_contenu.py`

### Document indexing

- [Document indexer](https://github.com/louis577-web/chatbot/blob/main/chatbot/management/commands/indexer_documents.py): `chatbot/management/commands/indexer_documents.py`
- [PDF text extraction](https://github.com/louis577-web/chatbot/blob/main/chatbot/recherche_contenu.py): `chatbot/recherche_contenu.py`
- [Text embeddings](https://github.com/louis577-web/chatbot/blob/main/chatbot/recherche_contenu.py): `chatbot/recherche_contenu.py`
- [Vector index](https://github.com/louis577-web/chatbot/blob/main/chatbot/recherche_contenu.py): `chatbot/recherche_contenu.py`

### Persistent data

- [Resource catalog](https://github.com/louis577-web/chatbot/blob/main/site_principal/models.py): `site_principal/models.py`
- [FAQ and conversations](https://github.com/louis577-web/chatbot/blob/main/chatbot/models.py): `chatbot/models.py`

### Other components

- **Chat user**
- **Main-site database**
- **PDF object storage**

## Connections

- Chat user → Chat routes: submits question
- Chat routes → Chat views: routes request
- Chat views → Chat pages: renders page
- Chat views → Answer service: requests answer
- Answer service → FAQ matching: matches FAQ
- FAQ matching → FAQ and conversations: reads FAQ
- Answer service → Document search: searches documents
- Document search → Vector index: queries vectors
- Answer service → Resource catalog: loads resources
- Resource catalog → Main-site database: reads catalog
- Answer service → FAQ and conversations: saves conversation
- Answer service → Chat views: returns answer
- Document indexer → Resource catalog: lists resources
- Document indexer → PDF text extraction: indexes resource
- PDF text extraction → PDF object storage: downloads PDF
- PDF text extraction → Text embeddings: embeds chunks
- Text embeddings → Vector index: stores vectors
