# sjacorg/bayanat architecture

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

- Interactive diagram: https://gitdiagram.com/sjacorg/bayanat
- Repository: https://github.com/sjacorg/bayanat

## Overview

Bayanat is a Flask-based human-rights evidence management platform. Users capture and relate bulletins, actors, and incidents; search and analyze records; collaborate through review workflows; and import or export evidence. The graph includes documented capabilities whose detailed implementations are not sampled; those nodes use supported enclosing paths, and uncertain internal wiring is omitted.

Main entry points: [`enferno/admin/views`](https://github.com/sjacorg/bayanat/tree/main/enferno/admin/views) (Evidence workspace), [`enferno/admin/models`](https://github.com/sjacorg/bayanat/tree/main/enferno/admin/models) (Evidence records), [`enferno/utils/background_search.py`](https://github.com/sjacorg/bayanat/blob/main/enferno/utils/background_search.py) (Queued search), [`enferno/tasks`](https://github.com/sjacorg/bayanat/tree/main/enferno/tasks) (Async workers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_evidence["Evidence management"]
  node_admin["Evidence workspace"]
  node_public["Public interface<br/>[views.py]"]
  node_evidence_models[("Evidence records")]
  node_workflow["Review workflow"]
  node_revision["Revision history<br/>[history.py]"]
end

subgraph group_analysis["Search and analysis"]
  node_search["Advanced search<br/>[search_utils.py]"]
  node_saved_search[("Saved searches<br/>[Query.py]")]
  node_background_search["Queued search"]
  node_maps["Geospatial analysis<br/>[flowmap_utils.py]"]
end

subgraph group_operations["Data operations"]
  node_import["Data import<br/>[views.py]"]
  node_export["Data export<br/>[views.py]"]
  node_dedup["Deduplication<br/>[views.py]"]
  node_media["Media processing"]
end

subgraph group_platform["Platform services"]
  node_web["Bayanat web app<br/>[app.py]"]
  node_tasks["Async workers"]
  node_notifications["Notifications<br/>[notifications.py]"]
  node_postgres[("PostgreSQL/PostGIS")]
  node_redis[("Redis")]
end

node_user(("Analyst"))
node_external_ocr["OCR provider"]

node_user -->|"uses"| node_web
node_web -->|"routes to"| node_admin
node_web -->|"routes to"| node_public
node_admin -->|"reads and writes"| node_evidence_models
node_public -->|"serves records"| node_evidence_models
node_admin -->|"manages review"| node_workflow
node_admin -->|"tracks changes"| node_revision
node_admin -->|"searches records"| node_search
node_search -->|"queries"| node_evidence_models
node_admin -->|"stores queries"| node_saved_search
node_admin -->|"queues timeout"| node_background_search
node_background_search -->|"dispatches"| node_tasks
node_tasks -->|"runs search"| node_background_search
node_background_search -->|"queries"| node_evidence_models
node_background_search -->|"stores results"| node_redis
node_background_search -->|"sends status"| node_notifications
node_admin -->|"requests analysis"| node_maps
node_maps -->|"spatial queries"| node_postgres
node_import -->|"dispatches jobs"| node_tasks
node_tasks -->|"runs import"| node_import
node_import -->|"writes records"| node_evidence_models
node_export -->|"reads records"| node_evidence_models
node_admin -->|"manages matches"| node_dedup
node_dedup -->|"compares records"| node_evidence_models
node_admin -->|"processes evidence"| node_media
node_media -.->|"extracts text"| node_external_ocr

click node_web "https://github.com/sjacorg/bayanat/blob/main/enferno/app.py"
click node_admin "https://github.com/sjacorg/bayanat/tree/main/enferno/admin/views"
click node_public "https://github.com/sjacorg/bayanat/blob/main/enferno/public/views.py"
click node_evidence_models "https://github.com/sjacorg/bayanat/tree/main/enferno/admin/models"
click node_workflow "https://github.com/sjacorg/bayanat/tree/main/enferno/admin/views"
click node_revision "https://github.com/sjacorg/bayanat/blob/main/enferno/admin/views/history.py"
click node_search "https://github.com/sjacorg/bayanat/blob/main/enferno/utils/search_utils.py"
click node_saved_search "https://github.com/sjacorg/bayanat/blob/main/enferno/admin/models/Query.py"
click node_background_search "https://github.com/sjacorg/bayanat/blob/main/enferno/utils/background_search.py"
click node_maps "https://github.com/sjacorg/bayanat/blob/main/enferno/utils/flowmap_utils.py"
click node_import "https://github.com/sjacorg/bayanat/blob/main/enferno/data_import/views.py"
click node_export "https://github.com/sjacorg/bayanat/blob/main/enferno/export/views.py"
click node_dedup "https://github.com/sjacorg/bayanat/blob/main/enferno/deduplication/views.py"
click node_media "https://github.com/sjacorg/bayanat/tree/main/enferno/utils/ocr"
click node_tasks "https://github.com/sjacorg/bayanat/tree/main/enferno/tasks"
click node_notifications "https://github.com/sjacorg/bayanat/blob/main/enferno/tasks/notifications.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_admin,node_public,node_evidence_models,node_workflow,node_revision toneBlue
class node_search,node_saved_search,node_background_search,node_maps toneAmber
class node_import,node_export,node_dedup,node_media toneMint
class node_web,node_tasks,node_notifications,node_postgres,node_redis toneRose
class node_user,node_external_ocr toneIndigo
```

## Components

### Evidence management

- [Evidence workspace](https://github.com/sjacorg/bayanat/tree/main/enferno/admin/views): `enferno/admin/views`
- [Public interface](https://github.com/sjacorg/bayanat/blob/main/enferno/public/views.py): `enferno/public/views.py`
- [Evidence records](https://github.com/sjacorg/bayanat/tree/main/enferno/admin/models): `enferno/admin/models`
- [Review workflow](https://github.com/sjacorg/bayanat/tree/main/enferno/admin/views): `enferno/admin/views`
- [Revision history](https://github.com/sjacorg/bayanat/blob/main/enferno/admin/views/history.py): `enferno/admin/views/history.py`

### Search and analysis

- [Advanced search](https://github.com/sjacorg/bayanat/blob/main/enferno/utils/search_utils.py): `enferno/utils/search_utils.py`
- [Saved searches](https://github.com/sjacorg/bayanat/blob/main/enferno/admin/models/Query.py): `enferno/admin/models/Query.py`
- [Queued search](https://github.com/sjacorg/bayanat/blob/main/enferno/utils/background_search.py): `enferno/utils/background_search.py`
- [Geospatial analysis](https://github.com/sjacorg/bayanat/blob/main/enferno/utils/flowmap_utils.py): `enferno/utils/flowmap_utils.py`

### Data operations

- [Data import](https://github.com/sjacorg/bayanat/blob/main/enferno/data_import/views.py): `enferno/data_import/views.py`
- [Data export](https://github.com/sjacorg/bayanat/blob/main/enferno/export/views.py): `enferno/export/views.py`
- [Deduplication](https://github.com/sjacorg/bayanat/blob/main/enferno/deduplication/views.py): `enferno/deduplication/views.py`
- [Media processing](https://github.com/sjacorg/bayanat/tree/main/enferno/utils/ocr): `enferno/utils/ocr`

### Platform services

- [Bayanat web app](https://github.com/sjacorg/bayanat/blob/main/enferno/app.py): `enferno/app.py`
- [Async workers](https://github.com/sjacorg/bayanat/tree/main/enferno/tasks): `enferno/tasks`
- [Notifications](https://github.com/sjacorg/bayanat/blob/main/enferno/tasks/notifications.py): `enferno/tasks/notifications.py`
- **PostgreSQL/PostGIS**
- **Redis**

### Other components

- **Analyst**
- **OCR provider**

## Connections

- Analyst → Bayanat web app: uses
- Bayanat web app → Evidence workspace: routes to
- Bayanat web app → Public interface: routes to
- Evidence workspace → Evidence records: reads and writes
- Public interface → Evidence records: serves records
- Evidence workspace → Review workflow: manages review
- Evidence workspace → Revision history: tracks changes
- Evidence workspace → Advanced search: searches records
- Advanced search → Evidence records: queries
- Evidence workspace → Saved searches: stores queries
- Evidence workspace → Queued search: queues timeout
- Queued search → Async workers: dispatches
- Async workers → Queued search: runs search
- Queued search → Evidence records: queries
- Queued search → Redis: stores results
- Queued search → Notifications: sends status
- Evidence workspace → Geospatial analysis: requests analysis
- Geospatial analysis → PostgreSQL/PostGIS: spatial queries
- Data import → Async workers: dispatches jobs
- Async workers → Data import: runs import
- Data import → Evidence records: writes records
- Data export → Evidence records: reads records
- Evidence workspace → Deduplication: manages matches
- Deduplication → Evidence records: compares records
- Evidence workspace → Media processing: processes evidence
- Media processing → OCR provider: extracts text
