# simonw/til architecture

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

- Interactive diagram: https://gitdiagram.com/simonw/til
- Repository: https://github.com/simonw/til

## Overview

Today I Learned is a searchable collection of Markdown snippets, published as a Datasette site. Readers browse topics or search the site; the repository builds a SQLite index with rendered HTML, summaries, timestamps, and full-text search. Documented site capabilities include an Atom feed and related-TIL suggestions. Screenshot generation is a separate publishing-support capability that renders pages and stores images in S3. The graph reflects the README and sampled files; runtime routing and deployment wiring were not fully sampled, so those connections are omitted where evidence is absent.

Main entry points: [`build_database.py`](https://github.com/simonw/til/blob/main/build_database.py) (Database builder), [`generate_screenshots.py`](https://github.com/simonw/til/blob/main/generate_screenshots.py) (Screenshot generator), [`README.md`](https://github.com/simonw/til/blob/main/README.md) (Topic index), [`plugins/template_vars.py`](https://github.com/simonw/til/blob/main/plugins/template_vars.py) (Template helpers)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_content["TIL content"]
  node_tils["Topic TILs"]
  node_readme["Topic index<br/>[README.md]"]
end

subgraph group_index["Indexing"]
  node_builder["Database builder<br/>[build_database.py]"]
  node_database[("TIL database")]
end

subgraph group_site["Web experience"]
  node_site_runtime["Datasette site"]
  node_templates["Page templates"]
  node_template_plugin["Template helpers<br/>[template_vars.py]"]
  node_redirect_plugin["Redirect routes<br/>[redirects.py]"]
end

subgraph group_media["Page images"]
  node_image_generator["Screenshot generator"]
  node_s3[("Screenshot bucket")]
end

node_reader(("Reader"))
node_github_markdown["GitHub Markdown API"]

node_reader -->|"browses or searches"| node_site_runtime
node_tils -->|"indexes"| node_builder
node_builder -->|"renders Markdown"| node_github_markdown
node_builder -->|"writes records"| node_database
node_builder -->|"enables full-text search"| node_database
node_site_runtime -.->|"serves indexed content"| node_database
node_site_runtime -.->|"renders pages"| node_templates
node_template_plugin -->|"queries related TILs"| node_database
node_redirect_plugin -.->|"registers redirects"| node_site_runtime
node_image_generator -->|"reads TIL rows"| node_database
node_image_generator -->|"renders page HTML"| node_site_runtime
node_image_generator -->|"stores screenshots"| node_s3
node_readme -->|"links to TILs"| node_reader

click node_readme "https://github.com/simonw/til/blob/main/README.md"
click node_builder "https://github.com/simonw/til/blob/main/build_database.py"
click node_templates "https://github.com/simonw/til/tree/main/templates"
click node_template_plugin "https://github.com/simonw/til/blob/main/plugins/template_vars.py"
click node_redirect_plugin "https://github.com/simonw/til/blob/main/plugins/redirects.py"
click node_image_generator "https://github.com/simonw/til/blob/main/generate_screenshots.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_tils,node_readme toneBlue
class node_builder,node_database toneAmber
class node_site_runtime,node_templates,node_template_plugin,node_redirect_plugin,node_github_markdown toneMint
class node_image_generator,node_s3 toneRose
class node_reader toneIndigo
```

## Components

### TIL content

- **Topic TILs**
- [Topic index](https://github.com/simonw/til/blob/main/README.md): `README.md`

### Indexing

- [Database builder](https://github.com/simonw/til/blob/main/build_database.py): `build_database.py`
- **TIL database**

### Web experience

- **Datasette site**
- [Page templates](https://github.com/simonw/til/tree/main/templates): `templates`
- [Template helpers](https://github.com/simonw/til/blob/main/plugins/template_vars.py): `plugins/template_vars.py`
- [Redirect routes](https://github.com/simonw/til/blob/main/plugins/redirects.py): `plugins/redirects.py`

### Page images

- [Screenshot generator](https://github.com/simonw/til/blob/main/generate_screenshots.py): `generate_screenshots.py`
- **Screenshot bucket**

### Other components

- **Reader**
- **GitHub Markdown API**

## Connections

- Reader → Datasette site: browses or searches (evidence: `README.md`)
- Topic TILs → Database builder: indexes (evidence: `build_database.py`)
- Database builder → GitHub Markdown API: renders Markdown (evidence: `build_database.py`)
- Database builder → TIL database: writes records (evidence: `build_database.py`)
- Database builder → TIL database: enables full-text search (evidence: `build_database.py`)
- Datasette site → TIL database: serves indexed content
- Datasette site → Page templates: renders pages
- Template helpers → TIL database: queries related TILs (evidence: `plugins/template_vars.py`)
- Redirect routes → Datasette site: registers redirects
- Screenshot generator → TIL database: reads TIL rows (evidence: `generate_screenshots.py`)
- Screenshot generator → Datasette site: renders page HTML (evidence: `generate_screenshots.py`)
- Screenshot generator → Screenshot bucket: stores screenshots (evidence: `generate_screenshots.py`)
- Topic index → Reader: links to TILs (evidence: `README.md`)
