# hamzarezig/search-engine architecture

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

- Interactive diagram: https://gitdiagram.com/hamzarezig/search-engine
- Repository: https://github.com/hamzarezig/search-engine

## Overview

This is a desktop information-retrieval application: users search a corpus of PDF, TXT, HTML, and DOCX documents through a Tkinter interface, then inspect ranked results, excerpts, and index statistics. The runtime workflow loads a cached index or extracts and preprocesses documents, computes TF-IDF, and executes Boolean or scored searches using selectable models. The graph reflects the shown CLI, indexing, search, and interface code; document formats and several UI actions are visible, but unsampled interface code limits some interaction details.

Main entry points: [`index_util.py`](https://github.com/hamzarezig/search-engine/blob/master/index_util.py) (Index manager), [`recherche.py`](https://github.com/hamzarezig/search-engine/blob/master/recherche.py) (Search engine), [`main.py`](https://github.com/hamzarezig/search-engine/blob/master/main.py) (CLI launcher), [`interface.py`](https://github.com/hamzarezig/search-engine/blob/master/interface.py) (Desktop interface)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Application entry"]
  node_cli["CLI launcher<br/>[main.py]"]
  node_corpus["Document corpus"]
end

subgraph group_indexing["Index construction"]
  node_indexer["Index manager<br/>[index_util.py]"]
  node_extract["Text extraction<br/>[etape1_pdf.py]"]
  node_stopwords["Stopword removal"]
  node_stemming["Word stemming<br/>[etape3_stemming.py]"]
  node_tf["TF calculation<br/>[etape4_tf.py]"]
  node_idf["IDF calculation<br/>[etape5_idf.py]"]
  node_tfidf["TF-IDF calculation<br/>[etape6_tfidf.py]"]
  node_cache[("Index cache<br/>[index.pkl]")]
end

subgraph group_retrieval["Search and ranking"]
  node_engine["Search engine<br/>[recherche.py]"]
  node_operators["Boolean operators<br/>[__init__.py]"]
  node_models["Ranking models<br/>[__init__.py]"]
end

subgraph group_experience["User interface"]
  node_gui["Desktop interface<br/>[interface.py]"]
end

node_user(("User"))

node_user -->|"launches"| node_cli
node_cli -->|"loads or builds"| node_indexer
node_cli -->|"opens"| node_gui
node_indexer -->|"scans"| node_corpus
node_indexer -->|"extracts text"| node_extract
node_indexer -->|"filters terms"| node_stopwords
node_indexer -->|"stems terms"| node_stemming
node_indexer -->|"computes TF"| node_tf
node_indexer -->|"computes IDF"| node_idf
node_indexer -->|"computes TF-IDF"| node_tfidf
node_indexer -->|"reads or writes"| node_cache
node_gui -->|"submits queries"| node_engine
node_gui -->|"reindexes or inspects"| node_indexer
node_engine -->|"filters query"| node_stopwords
node_engine -->|"stems query"| node_stemming
node_engine -->|"computes query TF"| node_tf
node_engine -->|"weights query"| node_tfidf
node_engine -->|"evaluates Boolean"| node_operators
node_engine -->|"scores documents"| node_models

click node_cli "https://github.com/hamzarezig/search-engine/blob/master/main.py"
click node_corpus "https://github.com/hamzarezig/search-engine/tree/master/documents"
click node_indexer "https://github.com/hamzarezig/search-engine/blob/master/index_util.py"
click node_extract "https://github.com/hamzarezig/search-engine/blob/master/utils/etape1_pdf.py"
click node_stopwords "https://github.com/hamzarezig/search-engine/blob/master/utils/etape2_stopwords.py"
click node_stemming "https://github.com/hamzarezig/search-engine/blob/master/utils/etape3_stemming.py"
click node_tf "https://github.com/hamzarezig/search-engine/blob/master/utils/etape4_tf.py"
click node_idf "https://github.com/hamzarezig/search-engine/blob/master/utils/etape5_idf.py"
click node_tfidf "https://github.com/hamzarezig/search-engine/blob/master/utils/etape6_tfidf.py"
click node_cache "https://github.com/hamzarezig/search-engine/blob/master/index.pkl"
click node_engine "https://github.com/hamzarezig/search-engine/blob/master/recherche.py"
click node_operators "https://github.com/hamzarezig/search-engine/blob/master/operateurs/__init__.py"
click node_models "https://github.com/hamzarezig/search-engine/blob/master/modeles/__init__.py"
click node_gui "https://github.com/hamzarezig/search-engine/blob/master/interface.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_cli,node_corpus,node_user toneBlue
class node_indexer,node_extract,node_stopwords,node_stemming,node_tf,node_idf,node_tfidf,node_cache toneAmber
class node_engine,node_operators,node_models toneMint
class node_gui toneRose
```

## Components

### Application entry

- [CLI launcher](https://github.com/hamzarezig/search-engine/blob/master/main.py): `main.py`
- [Document corpus](https://github.com/hamzarezig/search-engine/tree/master/documents): `documents`

### Index construction

- [Index manager](https://github.com/hamzarezig/search-engine/blob/master/index_util.py): `index_util.py`
- [Text extraction](https://github.com/hamzarezig/search-engine/blob/master/utils/etape1_pdf.py): `utils/etape1_pdf.py`
- [Stopword removal](https://github.com/hamzarezig/search-engine/blob/master/utils/etape2_stopwords.py): `utils/etape2_stopwords.py`
- [Word stemming](https://github.com/hamzarezig/search-engine/blob/master/utils/etape3_stemming.py): `utils/etape3_stemming.py`
- [TF calculation](https://github.com/hamzarezig/search-engine/blob/master/utils/etape4_tf.py): `utils/etape4_tf.py`
- [IDF calculation](https://github.com/hamzarezig/search-engine/blob/master/utils/etape5_idf.py): `utils/etape5_idf.py`
- [TF-IDF calculation](https://github.com/hamzarezig/search-engine/blob/master/utils/etape6_tfidf.py): `utils/etape6_tfidf.py`
- [Index cache](https://github.com/hamzarezig/search-engine/blob/master/index.pkl): `index.pkl`

### Search and ranking

- [Search engine](https://github.com/hamzarezig/search-engine/blob/master/recherche.py): `recherche.py`
- [Boolean operators](https://github.com/hamzarezig/search-engine/blob/master/operateurs/__init__.py): `operateurs/__init__.py`
- [Ranking models](https://github.com/hamzarezig/search-engine/blob/master/modeles/__init__.py): `modeles/__init__.py`

### User interface

- [Desktop interface](https://github.com/hamzarezig/search-engine/blob/master/interface.py): `interface.py`

### Other components

- **User**

## Connections

- User → CLI launcher: launches (evidence: `main.py`)
- CLI launcher → Index manager: loads or builds (evidence: `main.py`)
- CLI launcher → Desktop interface: opens (evidence: `main.py`)
- Index manager → Document corpus: scans (evidence: `index_util.py`)
- Index manager → Text extraction: extracts text (evidence: `index_util.py`)
- Index manager → Stopword removal: filters terms (evidence: `index_util.py`)
- Index manager → Word stemming: stems terms (evidence: `index_util.py`)
- Index manager → TF calculation: computes TF (evidence: `index_util.py`)
- Index manager → IDF calculation: computes IDF (evidence: `index_util.py`)
- Index manager → TF-IDF calculation: computes TF-IDF (evidence: `index_util.py`)
- Index manager → Index cache: reads or writes (evidence: `index_util.py`)
- Desktop interface → Search engine: submits queries (evidence: `interface.py`)
- Desktop interface → Index manager: reindexes or inspects (evidence: `interface.py`)
- Search engine → Stopword removal: filters query (evidence: `recherche.py`)
- Search engine → Word stemming: stems query (evidence: `recherche.py`)
- Search engine → TF calculation: computes query TF (evidence: `recherche.py`)
- Search engine → TF-IDF calculation: weights query (evidence: `recherche.py`)
- Search engine → Boolean operators: evaluates Boolean (evidence: `recherche.py`)
- Search engine → Ranking models: scores documents (evidence: `recherche.py`)
