# realpython/flask-boilerplate architecture

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

- Interactive diagram: https://gitdiagram.com/realpython/flask-boilerplate
- Repository: https://github.com/realpython/flask-boilerplate

## Overview

This repository is a Flask starter application, with a root-level app and a second, factory/blueprint-based version under `_updated/`. The main user workflow is visiting a page or account-form route and receiving a rendered template; the forms define input fields and validation but do not implement account persistence or authentication. The README also advertises Flask-SQLAlchemy and Bootstrap scaffolding. Source excerpts show SQLAlchemy commented out in the root app; detailed storage behavior and template-to-asset wiring are not established here.

Main entry points: [`app.py`](https://github.com/realpython/flask-boilerplate/blob/master/app.py) (Flask routes), [`_updated/app/controllers/pages.py`](https://github.com/realpython/flask-boilerplate/blob/master/_updated/app/controllers/pages.py) (Page routes), [`_updated/app/__init__.py`](https://github.com/realpython/flask-boilerplate/blob/master/_updated/app/__init__.py) (App factory), [`_updated/run.py`](https://github.com/realpython/flask-boilerplate/blob/master/_updated/run.py) (Run entry point)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_root_runtime["Root Flask app"]
  node_root_app["Flask routes<br/>[app.py]"]
  node_root_config["App configuration<br/>[config.py]"]
end

subgraph group_updated_runtime["Updated Flask app"]
  node_updated_entry["Run entry point<br/>[run.py]"]
  node_updated_factory["App factory<br/>[__init__.py]"]
  node_updated_pages["Page routes<br/>[pages.py]"]
  node_updated_config["Development config"]
end

subgraph group_presentation["Forms and presentation"]
  node_root_forms["Account forms<br/>[forms.py]"]
  node_root_templates["Page templates"]
  node_root_assets["Bootstrap assets"]
  node_updated_forms["Account forms<br/>[forms.py]"]
  node_updated_templates["Page templates"]
  node_updated_assets["Bootstrap assets"]
end

node_visitor(("Browser visitor"))

node_visitor -->|"requests pages"| node_root_app
node_root_app -->|"loads config"| node_root_config
node_root_app -->|"imports forms"| node_root_forms
node_root_app -->|"renders pages"| node_root_templates
node_root_app -->|"renders errors"| node_root_templates
node_updated_entry -->|"creates app"| node_updated_factory
node_updated_entry -->|"selects config"| node_updated_config
node_updated_factory -->|"loads config"| node_updated_config
node_updated_factory -->|"registers blueprint"| node_updated_pages
node_visitor -.->|"requests pages"| node_updated_pages
node_updated_pages -->|"imports forms"| node_updated_forms
node_updated_pages -->|"renders pages"| node_updated_templates

click node_root_app "https://github.com/realpython/flask-boilerplate/blob/master/app.py"
click node_root_config "https://github.com/realpython/flask-boilerplate/blob/master/config.py"
click node_root_forms "https://github.com/realpython/flask-boilerplate/blob/master/forms.py"
click node_root_templates "https://github.com/realpython/flask-boilerplate/tree/master/templates"
click node_root_assets "https://github.com/realpython/flask-boilerplate/tree/master/static"
click node_updated_entry "https://github.com/realpython/flask-boilerplate/blob/master/_updated/run.py"
click node_updated_factory "https://github.com/realpython/flask-boilerplate/blob/master/_updated/app/__init__.py"
click node_updated_pages "https://github.com/realpython/flask-boilerplate/blob/master/_updated/app/controllers/pages.py"
click node_updated_config "https://github.com/realpython/flask-boilerplate/tree/master/_updated/config/development"
click node_updated_forms "https://github.com/realpython/flask-boilerplate/blob/master/_updated/app/forms.py"
click node_updated_templates "https://github.com/realpython/flask-boilerplate/tree/master/_updated/app/templates"
click node_updated_assets "https://github.com/realpython/flask-boilerplate/tree/master/_updated/app/static"

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_root_app,node_root_config,node_visitor toneBlue
class node_updated_entry,node_updated_factory,node_updated_pages,node_updated_config toneAmber
class node_root_forms,node_root_templates,node_root_assets,node_updated_forms,node_updated_templates,node_updated_assets toneMint
```

## Components

### Root Flask app

- [Flask routes](https://github.com/realpython/flask-boilerplate/blob/master/app.py): `app.py`
- [App configuration](https://github.com/realpython/flask-boilerplate/blob/master/config.py): `config.py`

### Updated Flask app

- [Run entry point](https://github.com/realpython/flask-boilerplate/blob/master/_updated/run.py): `_updated/run.py`
- [App factory](https://github.com/realpython/flask-boilerplate/blob/master/_updated/app/__init__.py): `_updated/app/__init__.py`
- [Page routes](https://github.com/realpython/flask-boilerplate/blob/master/_updated/app/controllers/pages.py): `_updated/app/controllers/pages.py`
- [Development config](https://github.com/realpython/flask-boilerplate/tree/master/_updated/config/development): `_updated/config/development`

### Forms and presentation

- [Account forms](https://github.com/realpython/flask-boilerplate/blob/master/forms.py): `forms.py`
- [Page templates](https://github.com/realpython/flask-boilerplate/tree/master/templates): `templates`
- [Bootstrap assets](https://github.com/realpython/flask-boilerplate/tree/master/static): `static`
- [Account forms](https://github.com/realpython/flask-boilerplate/blob/master/_updated/app/forms.py): `_updated/app/forms.py`
- [Page templates](https://github.com/realpython/flask-boilerplate/tree/master/_updated/app/templates): `_updated/app/templates`
- [Bootstrap assets](https://github.com/realpython/flask-boilerplate/tree/master/_updated/app/static): `_updated/app/static`

### Other components

- **Browser visitor**

## Connections

- Browser visitor → Flask routes: requests pages (evidence: `README.md`)
- Flask routes → App configuration: loads config (evidence: `app.py`)
- Flask routes → Account forms: imports forms (evidence: `app.py`)
- Flask routes → Page templates: renders pages (evidence: `app.py`)
- Flask routes → Page templates: renders errors (evidence: `app.py`)
- Run entry point → App factory: creates app (evidence: `_updated/run.py`)
- Run entry point → Development config: selects config (evidence: `_updated/run.py`)
- App factory → Development config: loads config (evidence: `_updated/app/__init__.py`)
- App factory → Page routes: registers blueprint (evidence: `_updated/app/__init__.py`)
- Browser visitor → Page routes: requests pages
- Page routes → Account forms: imports forms (evidence: `_updated/app/controllers/pages.py`)
- Page routes → Page templates: renders pages (evidence: `_updated/app/controllers/pages.py`)
