# gopal092003/dictionary-api architecture

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

- Interactive diagram: https://gitdiagram.com/gopal092003/dictionary-api
- Repository: https://github.com/gopal092003/dictionary-api

## Overview

Dictionary API is a local-first English dictionary service, Python client, and CLI. Users submit lookups or lexical queries through HTTP or the CLI; the service combines dictionary and relationship providers, optional offline dictionary data, caching, and local corpus or morphology features to return structured results. Separate capabilities include relationship graphs, search, random and daily words, and persistent personal vocabulary lists with import/export and flashcards. The excerpts show the HTTP routing and selected service behavior; some provider, cache, and library links rely on the source index or README rather than inspected implementation.

Main entry points: [`app/services/dictionary_service.py`](https://github.com/gopal092003/dictionary-api/blob/main/app/services/dictionary_service.py) (Dictionary service), [`app/routes/dictionary.py`](https://github.com/gopal092003/dictionary-api/blob/main/app/routes/dictionary.py) (HTTP API), [`app/cli.py`](https://github.com/gopal092003/dictionary-api/blob/main/app/cli.py) (Command-line interface), [`app/providers/dictionary_api.py`](https://github.com/gopal092003/dictionary-api/blob/main/app/providers/dictionary_api.py) (DictionaryAPI adapter)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["User interfaces"]
  node_http["HTTP API<br/>[dictionary.py]"]
  node_cli["Command-line interface<br/>[cli.py]"]
  node_client["Python client<br/>[library.py]"]
  node_app["Application setup<br/>[main.py]"]
end

subgraph group_core["Lookup orchestration"]
  node_service["Dictionary service"]
  node_models["Response models<br/>[dictionary.py]"]
  node_settings["Runtime settings<br/>[settings.py]"]
  node_cache[("Result cache<br/>[cache.py]")]
end

subgraph group_providers["Language sources"]
  node_dictionary["DictionaryAPI adapter<br/>[dictionary_api.py]"]
  node_datamuse["Datamuse adapter<br/>[datamuse.py]"]
  node_offline["Offline dictionary"]
  node_httpclient["Provider HTTP transport<br/>[http.py]"]
end

subgraph group_local["Local word tools"]
  node_corpus[("Word corpus<br/>[local_data.py]")]
  node_morphology["Rule-based morphology<br/>[morphology.py]"]
end

subgraph group_personal["Personal vocabulary"]
  node_vocabulary[("Vocabulary lists<br/>[vocabulary.py]")]
end

node_user(("User"))
node_dictionaryapi["DictionaryAPI.dev"]
node_datamuseapi["Datamuse API"]

node_user -->|"queries"| node_http
node_user -->|"runs"| node_cli
node_app -->|"mounts routes"| node_http
node_http -->|"dispatches queries"| node_service
node_cli -->|"invokes"| node_client
node_cli -->|"manages lists"| node_vocabulary
node_client -.->|"uses"| node_service
node_http -->|"validates responses"| node_models
node_service -->|"configures providers"| node_settings
node_service -->|"reads and writes"| node_cache
node_service -->|"looks up entries"| node_dictionary
node_service -->|"fetches relations"| node_datamuse
node_service -->|"uses fallback"| node_offline
node_service -->|"queries local words"| node_corpus
node_service -->|"derives forms"| node_morphology
node_dictionary -.->|"uses transport"| node_httpclient
node_datamuse -.->|"uses transport"| node_httpclient
node_offline -.->|"uses local data"| node_corpus
node_dictionary -.->|"requests definitions"| node_dictionaryapi
node_datamuse -.->|"requests word relations"| node_datamuseapi
node_vocabulary -->|"fetches missing entries"| node_client

click node_http "https://github.com/gopal092003/dictionary-api/blob/main/app/routes/dictionary.py"
click node_cli "https://github.com/gopal092003/dictionary-api/blob/main/app/cli.py"
click node_client "https://github.com/gopal092003/dictionary-api/blob/main/app/library.py"
click node_app "https://github.com/gopal092003/dictionary-api/blob/main/app/main.py"
click node_service "https://github.com/gopal092003/dictionary-api/blob/main/app/services/dictionary_service.py"
click node_models "https://github.com/gopal092003/dictionary-api/blob/main/app/models/dictionary.py"
click node_settings "https://github.com/gopal092003/dictionary-api/blob/main/app/config/settings.py"
click node_cache "https://github.com/gopal092003/dictionary-api/blob/main/app/cache.py"
click node_dictionary "https://github.com/gopal092003/dictionary-api/blob/main/app/providers/dictionary_api.py"
click node_datamuse "https://github.com/gopal092003/dictionary-api/blob/main/app/providers/datamuse.py"
click node_offline "https://github.com/gopal092003/dictionary-api/blob/main/app/providers/offline_dictionary.py"
click node_httpclient "https://github.com/gopal092003/dictionary-api/blob/main/app/providers/http.py"
click node_corpus "https://github.com/gopal092003/dictionary-api/blob/main/app/local_data.py"
click node_morphology "https://github.com/gopal092003/dictionary-api/blob/main/app/morphology.py"
click node_vocabulary "https://github.com/gopal092003/dictionary-api/blob/main/app/vocabulary.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_http,node_cli,node_client,node_app,node_user toneBlue
class node_service,node_models,node_settings,node_cache toneAmber
class node_dictionary,node_datamuse,node_offline,node_httpclient,node_dictionaryapi,node_datamuseapi toneMint
class node_corpus,node_morphology toneRose
class node_vocabulary toneIndigo
```

## Components

### User interfaces

- [HTTP API](https://github.com/gopal092003/dictionary-api/blob/main/app/routes/dictionary.py): `app/routes/dictionary.py`
- [Command-line interface](https://github.com/gopal092003/dictionary-api/blob/main/app/cli.py): `app/cli.py`
- [Python client](https://github.com/gopal092003/dictionary-api/blob/main/app/library.py): `app/library.py`
- [Application setup](https://github.com/gopal092003/dictionary-api/blob/main/app/main.py): `app/main.py`

### Lookup orchestration

- [Dictionary service](https://github.com/gopal092003/dictionary-api/blob/main/app/services/dictionary_service.py): `app/services/dictionary_service.py`
- [Response models](https://github.com/gopal092003/dictionary-api/blob/main/app/models/dictionary.py): `app/models/dictionary.py`
- [Runtime settings](https://github.com/gopal092003/dictionary-api/blob/main/app/config/settings.py): `app/config/settings.py`
- [Result cache](https://github.com/gopal092003/dictionary-api/blob/main/app/cache.py): `app/cache.py`

### Language sources

- [DictionaryAPI adapter](https://github.com/gopal092003/dictionary-api/blob/main/app/providers/dictionary_api.py): `app/providers/dictionary_api.py`
- [Datamuse adapter](https://github.com/gopal092003/dictionary-api/blob/main/app/providers/datamuse.py): `app/providers/datamuse.py`
- [Offline dictionary](https://github.com/gopal092003/dictionary-api/blob/main/app/providers/offline_dictionary.py): `app/providers/offline_dictionary.py`
- [Provider HTTP transport](https://github.com/gopal092003/dictionary-api/blob/main/app/providers/http.py): `app/providers/http.py`

### Local word tools

- [Word corpus](https://github.com/gopal092003/dictionary-api/blob/main/app/local_data.py): `app/local_data.py`
- [Rule-based morphology](https://github.com/gopal092003/dictionary-api/blob/main/app/morphology.py): `app/morphology.py`

### Personal vocabulary

- [Vocabulary lists](https://github.com/gopal092003/dictionary-api/blob/main/app/vocabulary.py): `app/vocabulary.py`

### Other components

- **User**
- **DictionaryAPI.dev**
- **Datamuse API**

## Connections

- User → HTTP API: queries
- User → Command-line interface: runs
- Application setup → HTTP API: mounts routes (evidence: `app/main.py`)
- HTTP API → Dictionary service: dispatches queries (evidence: `app/routes/dictionary.py`)
- Command-line interface → Python client: invokes (evidence: `app/cli.py`)
- Command-line interface → Vocabulary lists: manages lists (evidence: `app/cli.py`)
- Python client → Dictionary service: uses
- HTTP API → Response models: validates responses (evidence: `app/routes/dictionary.py`)
- Dictionary service → Runtime settings: configures providers (evidence: `app/services/dictionary_service.py`)
- Dictionary service → Result cache: reads and writes (evidence: `app/services/dictionary_service.py`)
- Dictionary service → DictionaryAPI adapter: looks up entries (evidence: `app/services/dictionary_service.py`)
- Dictionary service → Datamuse adapter: fetches relations (evidence: `app/services/dictionary_service.py`)
- Dictionary service → Offline dictionary: uses fallback (evidence: `app/services/dictionary_service.py`)
- Dictionary service → Word corpus: queries local words (evidence: `app/services/dictionary_service.py`)
- Dictionary service → Rule-based morphology: derives forms (evidence: `app/services/dictionary_service.py`)
- DictionaryAPI adapter → Provider HTTP transport: uses transport
- Datamuse adapter → Provider HTTP transport: uses transport
- Offline dictionary → Word corpus: uses local data
- DictionaryAPI adapter → DictionaryAPI.dev: requests definitions (evidence: `README.md`)
- Datamuse adapter → Datamuse API: requests word relations (evidence: `README.md`)
- Vocabulary lists → Python client: fetches missing entries (evidence: `app/vocabulary.py`)
