# juhanurmi/ahmia architecture

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

- Interactive diagram: https://gitdiagram.com/juhanurmi/ahmia
- Repository: https://github.com/juhanurmi/ahmia

## Overview

Ahmia is a Tor hidden-service search engine and directory. Users search indexed services or browse and submit service information; Onionbot crawlers collect site content for search, while separate tools gather backlink and Tor2web popularity data. The Django application also exposes service status and popularity information. The excerpts show the search, directory, and popularity paths, but not the crawler pipelines or the implementation of the online tracker, so those connections are intentionally limited.

Main entry points: [`ahmia/views.py`](https://github.com/juhanurmi/ahmia/blob/master/ahmia/views.py) (Directory views), [`ahmia/views_search.py`](https://github.com/juhanurmi/ahmia/blob/master/ahmia/views_search.py) (Search views), [`ahmia/models.py`](https://github.com/juhanurmi/ahmia/blob/master/ahmia/models.py) (Service records), [`ahmia/view_help_functions.py`](https://github.com/juhanurmi/ahmia/blob/master/ahmia/view_help_functions.py) (View helpers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Search application"]
  node_search_views["Search views<br/>[views_search.py]"]
  node_search_index["Search index<br/>[search_indexes.py]"]
  node_solr[("Solr search")]
end

subgraph group_catalog["Service directory"]
  node_directory_views["Directory views<br/>[views.py]"]
  node_view_helpers["View helpers"]
  node_service_data[("Service records<br/>[models.py]")]
  node_admin_views["Admin views<br/>[views_admin.py]"]
  node_status_views["Online tracker<br/>[views_stats.py]"]
end

subgraph group_crawl["Crawling and indexing"]
  node_crawler["Onionbot crawler<br/>[onionspider.py]"]
  node_crawl_items["Crawl records<br/>[items.py]"]
  node_mongo_crawler["Mongo crawler<br/>[onionspider.py]"]
  node_mongo_items["Mongo crawl records<br/>[items.py]"]
  node_finder["Service discovery<br/>[finder_spider.py]"]
end

subgraph group_signals["Popularity signals"]
  node_backlinks["Backlink collection<br/>[backlink_spider.py]"]
  node_tool_items["Tool records<br/>[items.py]"]
  node_access_analysis["Access analysis"]
  node_popularity[("Popularity records<br/>[models.py]")]
end

node_visitor(("Search visitor"))
node_search_client(("Search client"))
node_backlink_source{{"Public web search"}}

node_visitor -->|"submits query"| node_search_views
node_search_views -->|"queries domains"| node_solr
node_search_views -->|"reads popularity"| node_service_data
node_search_index -->|"indexes model"| node_service_data
node_visitor -->|"browses or submits"| node_directory_views
node_directory_views -->|"renders directory"| node_view_helpers
node_view_helpers -->|"reads services"| node_service_data
node_directory_views -->|"updates records"| node_service_data
node_directory_views -->|"updates clicks"| node_popularity
node_crawler -->|"creates items"| node_crawl_items
node_mongo_crawler -->|"creates items"| node_mongo_items
node_finder -->|"submits services"| node_search_views
node_backlink_source -->|"provides results"| node_backlinks
node_backlinks -->|"creates item"| node_tool_items
node_search_client -.->|"generates access logs"| node_access_analysis

click node_search_views "https://github.com/juhanurmi/ahmia/blob/master/ahmia/views_search.py"
click node_search_index "https://github.com/juhanurmi/ahmia/blob/master/ahmia/search_indexes.py"
click node_directory_views "https://github.com/juhanurmi/ahmia/blob/master/ahmia/views.py"
click node_view_helpers "https://github.com/juhanurmi/ahmia/blob/master/ahmia/view_help_functions.py"
click node_service_data "https://github.com/juhanurmi/ahmia/blob/master/ahmia/models.py"
click node_admin_views "https://github.com/juhanurmi/ahmia/blob/master/ahmia/views_admin.py"
click node_status_views "https://github.com/juhanurmi/ahmia/blob/master/ahmia/views_stats.py"
click node_crawler "https://github.com/juhanurmi/ahmia/blob/master/onionbot/dirbot/spiders/onionspider.py"
click node_crawl_items "https://github.com/juhanurmi/ahmia/blob/master/onionbot/dirbot/items.py"
click node_mongo_crawler "https://github.com/juhanurmi/ahmia/blob/master/onionMongoBot/onionMongoBot/spiders/onionspider.py"
click node_mongo_items "https://github.com/juhanurmi/ahmia/blob/master/onionMongoBot/onionMongoBot/items.py"
click node_finder "https://github.com/juhanurmi/ahmia/blob/master/tools/spiders/finder_spider.py"
click node_backlinks "https://github.com/juhanurmi/ahmia/blob/master/tools/spiders/backlink_spider.py"
click node_tool_items "https://github.com/juhanurmi/ahmia/blob/master/tools/items.py"
click node_access_analysis "https://github.com/juhanurmi/ahmia/blob/master/tools/access_log_analyser.py"
click node_popularity "https://github.com/juhanurmi/ahmia/blob/master/ahmia/models.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_search_views,node_search_index,node_solr,node_search_client toneBlue
class node_directory_views,node_view_helpers,node_service_data,node_admin_views,node_status_views toneAmber
class node_crawler,node_crawl_items,node_mongo_crawler,node_mongo_items,node_finder toneMint
class node_backlinks,node_tool_items,node_access_analysis,node_popularity toneRose
class node_visitor,node_backlink_source toneIndigo
```

## Components

### Search application

- [Search views](https://github.com/juhanurmi/ahmia/blob/master/ahmia/views_search.py): `ahmia/views_search.py`
- [Search index](https://github.com/juhanurmi/ahmia/blob/master/ahmia/search_indexes.py): `ahmia/search_indexes.py`
- **Solr search**

### Service directory

- [Directory views](https://github.com/juhanurmi/ahmia/blob/master/ahmia/views.py): `ahmia/views.py`
- [View helpers](https://github.com/juhanurmi/ahmia/blob/master/ahmia/view_help_functions.py): `ahmia/view_help_functions.py`
- [Service records](https://github.com/juhanurmi/ahmia/blob/master/ahmia/models.py): `ahmia/models.py`
- [Admin views](https://github.com/juhanurmi/ahmia/blob/master/ahmia/views_admin.py): `ahmia/views_admin.py`
- [Online tracker](https://github.com/juhanurmi/ahmia/blob/master/ahmia/views_stats.py): `ahmia/views_stats.py`

### Crawling and indexing

- [Onionbot crawler](https://github.com/juhanurmi/ahmia/blob/master/onionbot/dirbot/spiders/onionspider.py): `onionbot/dirbot/spiders/onionspider.py`
- [Crawl records](https://github.com/juhanurmi/ahmia/blob/master/onionbot/dirbot/items.py): `onionbot/dirbot/items.py`
- [Mongo crawler](https://github.com/juhanurmi/ahmia/blob/master/onionMongoBot/onionMongoBot/spiders/onionspider.py): `onionMongoBot/onionMongoBot/spiders/onionspider.py`
- [Mongo crawl records](https://github.com/juhanurmi/ahmia/blob/master/onionMongoBot/onionMongoBot/items.py): `onionMongoBot/onionMongoBot/items.py`
- [Service discovery](https://github.com/juhanurmi/ahmia/blob/master/tools/spiders/finder_spider.py): `tools/spiders/finder_spider.py`

### Popularity signals

- [Backlink collection](https://github.com/juhanurmi/ahmia/blob/master/tools/spiders/backlink_spider.py): `tools/spiders/backlink_spider.py`
- [Tool records](https://github.com/juhanurmi/ahmia/blob/master/tools/items.py): `tools/items.py`
- [Access analysis](https://github.com/juhanurmi/ahmia/blob/master/tools/access_log_analyser.py): `tools/access_log_analyser.py`
- [Popularity records](https://github.com/juhanurmi/ahmia/blob/master/ahmia/models.py): `ahmia/models.py`

### Other components

- **Search visitor**
- **Search client**
- **Public web search**

## Connections

- Search visitor → Search views: submits query
- Search views → Solr search: queries domains (evidence: `ahmia/views_search.py`)
- Search views → Service records: reads popularity (evidence: `ahmia/views_search.py`)
- Search index → Service records: indexes model (evidence: `ahmia/search_indexes.py`)
- Search visitor → Directory views: browses or submits (evidence: `ahmia/views.py`)
- Directory views → View helpers: renders directory (evidence: `ahmia/views.py`)
- View helpers → Service records: reads services (evidence: `ahmia/view_help_functions.py`)
- Directory views → Service records: updates records (evidence: `ahmia/views.py`)
- Directory views → Popularity records: updates clicks (evidence: `ahmia/views.py`)
- Onionbot crawler → Crawl records: creates items (evidence: `onionbot/dirbot/spiders/onionspider.py`)
- Mongo crawler → Mongo crawl records: creates items (evidence: `onionMongoBot/onionMongoBot/spiders/onionspider.py`)
- Service discovery → Search views: submits services (evidence: `tools/spiders/finder_spider.py`)
- Public web search → Backlink collection: provides results (evidence: `tools/spiders/backlink_spider.py`)
- Backlink collection → Tool records: creates item (evidence: `tools/spiders/backlink_spider.py`)
- Search client → Access analysis: generates access logs
