# miguelgrinberg/microblog architecture

> Architecture diagram of the GitHub repository miguelgrinberg/microblog, 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/miguelgrinberg/microblog
- Repository: https://github.com/miguelgrinberg/microblog

## Overview

Microblog is a Flask social blogging application. A signed-in user creates posts, follows people, browses feeds, searches, exchanges messages, and can request a background post export; visitors can register, sign in, or reset passwords. The web route modules coordinate forms, models, and persistence, while separate API routes expose user operations with token authentication. Other documented-by-code capabilities include translation, notifications, email, and optional Elasticsearch search. The graph follows sampled route and worker calls; model internals and unsampled integrations are represented conservatively.

Main entry points: [`app/main/routes.py`](https://github.com/miguelgrinberg/microblog/blob/main/app/main/routes.py) (Social routes), [`app/models.py`](https://github.com/miguelgrinberg/microblog/blob/main/app/models.py) (Domain models), [`app/__init__.py`](https://github.com/miguelgrinberg/microblog/blob/main/app/__init__.py) (Flask app setup), [`app/auth/routes.py`](https://github.com/miguelgrinberg/microblog/blob/main/app/auth/routes.py) (Account routes)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_web_routes["Social routes<br/>[routes.py]"]
  node_web_forms["Social forms<br/>[forms.py]"]
  node_web_views["Page templates"]
end

subgraph group_identity["Accounts and API"]
  node_auth_routes["Account routes<br/>[routes.py]"]
  node_auth_forms["Account forms<br/>[forms.py]"]
  node_api_users["User API<br/>[users.py]"]
  node_api_auth["API authentication<br/>[auth.py]"]
  node_api_errors["API errors<br/>[errors.py]"]
end

subgraph group_domain["Social domain"]
  node_models["Domain models<br/>[models.py]"]
  node_search["Search integration<br/>[search.py]"]
  node_translation["Text translation<br/>[translate.py]"]
end

subgraph group_background["Background work"]
  node_worker["Export worker<br/>[tasks.py]"]
end

subgraph group_platform["Persistence and services"]
  node_task_queue["Task queue"]
  node_database[("Relational database")]
  node_elastic[("Elasticsearch")]
  node_redis[("Redis")]
  node_mail["Email service"]
  node_app_factory["Flask app setup<br/>[__init__.py]"]
end

node_user(("Browser user"))

node_user -->|"requests pages"| node_web_routes
node_web_routes -->|"validates input"| node_web_forms
node_web_routes -->|"renders pages"| node_web_views
node_web_routes -->|"reads and writes"| node_models
node_web_routes -->|"translates text"| node_translation
node_web_routes -->|"searches posts"| node_search
node_auth_routes -->|"validates input"| node_auth_forms
node_auth_routes -->|"reads and writes"| node_models
node_auth_routes -->|"requests reset email"| node_mail
node_api_users -->|"checks tokens"| node_api_auth
node_api_users -->|"returns errors"| node_api_errors
node_api_users -->|"reads and writes"| node_models
node_web_routes -->|"launches export"| node_task_queue
node_worker -->|"loads export data"| node_models
node_worker -->|"updates progress"| node_task_queue
node_worker -->|"sends export"| node_mail
node_models -->|"persists domain data"| node_database
node_search -.->|"indexes and queries"| node_elastic
node_app_factory -->|"initializes ORM"| node_database
node_app_factory -.->|"configures client"| node_elastic
node_app_factory -->|"connects"| node_redis
node_app_factory -->|"creates queue"| node_task_queue

click node_web_routes "https://github.com/miguelgrinberg/microblog/blob/main/app/main/routes.py"
click node_web_forms "https://github.com/miguelgrinberg/microblog/blob/main/app/main/forms.py"
click node_web_views "https://github.com/miguelgrinberg/microblog/tree/main/app/templates"
click node_auth_routes "https://github.com/miguelgrinberg/microblog/blob/main/app/auth/routes.py"
click node_auth_forms "https://github.com/miguelgrinberg/microblog/blob/main/app/auth/forms.py"
click node_api_users "https://github.com/miguelgrinberg/microblog/blob/main/app/api/users.py"
click node_api_auth "https://github.com/miguelgrinberg/microblog/blob/main/app/api/auth.py"
click node_api_errors "https://github.com/miguelgrinberg/microblog/blob/main/app/api/errors.py"
click node_models "https://github.com/miguelgrinberg/microblog/blob/main/app/models.py"
click node_search "https://github.com/miguelgrinberg/microblog/blob/main/app/search.py"
click node_translation "https://github.com/miguelgrinberg/microblog/blob/main/app/translate.py"
click node_worker "https://github.com/miguelgrinberg/microblog/blob/main/app/tasks.py"
click node_app_factory "https://github.com/miguelgrinberg/microblog/blob/main/app/__init__.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_web_routes,node_web_forms,node_web_views,node_user toneBlue
class node_auth_routes,node_auth_forms,node_api_users,node_api_auth,node_api_errors toneAmber
class node_models,node_search,node_translation toneMint
class node_worker toneRose
class node_task_queue,node_database,node_elastic,node_redis,node_mail,node_app_factory toneIndigo
```

## Components

### Web experience

- [Social routes](https://github.com/miguelgrinberg/microblog/blob/main/app/main/routes.py): `app/main/routes.py`
- [Social forms](https://github.com/miguelgrinberg/microblog/blob/main/app/main/forms.py): `app/main/forms.py`
- [Page templates](https://github.com/miguelgrinberg/microblog/tree/main/app/templates): `app/templates`

### Accounts and API

- [Account routes](https://github.com/miguelgrinberg/microblog/blob/main/app/auth/routes.py): `app/auth/routes.py`
- [Account forms](https://github.com/miguelgrinberg/microblog/blob/main/app/auth/forms.py): `app/auth/forms.py`
- [User API](https://github.com/miguelgrinberg/microblog/blob/main/app/api/users.py): `app/api/users.py`
- [API authentication](https://github.com/miguelgrinberg/microblog/blob/main/app/api/auth.py): `app/api/auth.py`
- [API errors](https://github.com/miguelgrinberg/microblog/blob/main/app/api/errors.py): `app/api/errors.py`

### Social domain

- [Domain models](https://github.com/miguelgrinberg/microblog/blob/main/app/models.py): `app/models.py`
- [Search integration](https://github.com/miguelgrinberg/microblog/blob/main/app/search.py): `app/search.py`
- [Text translation](https://github.com/miguelgrinberg/microblog/blob/main/app/translate.py): `app/translate.py`

### Background work

- [Export worker](https://github.com/miguelgrinberg/microblog/blob/main/app/tasks.py): `app/tasks.py`

### Persistence and services

- **Task queue**
- **Relational database**
- **Elasticsearch**
- **Redis**
- **Email service**
- [Flask app setup](https://github.com/miguelgrinberg/microblog/blob/main/app/__init__.py): `app/__init__.py`

### Other components

- **Browser user**

## Connections

- Browser user → Social routes: requests pages
- Social routes → Social forms: validates input
- Social routes → Page templates: renders pages
- Social routes → Domain models: reads and writes
- Social routes → Text translation: translates text
- Social routes → Search integration: searches posts
- Account routes → Account forms: validates input
- Account routes → Domain models: reads and writes
- Account routes → Email service: requests reset email
- User API → API authentication: checks tokens
- User API → API errors: returns errors
- User API → Domain models: reads and writes
- Social routes → Task queue: launches export
- Export worker → Domain models: loads export data
- Export worker → Task queue: updates progress
- Export worker → Email service: sends export
- Domain models → Relational database: persists domain data
- Search integration → Elasticsearch: indexes and queries
- Flask app setup → Relational database: initializes ORM
- Flask app setup → Elasticsearch: configures client
- Flask app setup → Redis: connects
- Flask app setup → Task queue: creates queue
