# jerelintusalo/blog architecture

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

- Interactive diagram: https://gitdiagram.com/jerelintusalo/blog
- Repository: https://github.com/jerelintusalo/blog

## Overview

This is a server-rendered blog application. A visitor registers or logs in through the authentication routes; successful login stores a session identifier in SQLite and sets a cookie. On later requests, the app looks up that session, then serves the post list, accepts new posts, or renders the admin page for the admin user. Pug views provide the login, registration, post, and admin screens. The graph reflects the sampled app and auth code; the README is empty, and the separate index and users routers are not mounted in the sampled app.

Main entry points: [`app.js`](https://github.com/jerelintusalo/blog/blob/main/app.js) (Express app), [`routes/auth.js`](https://github.com/jerelintusalo/blog/blob/main/routes/auth.js) (Auth routes), [`blog.db`](https://github.com/jerelintusalo/blog/blob/main/blog.db) (Blog database), [`database.js`](https://github.com/jerelintusalo/blog/blob/main/database.js) (Database setup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["Express app<br/>[app.js]"]
  node_home_view["Post list view<br/>[index.pug]"]
  node_new_post_view["New post view<br/>[new-post.pug]"]
  node_admin_view["Admin view<br/>[admin.pug]"]
end

subgraph group_auth["Authentication"]
  node_auth_routes["Auth routes<br/>[auth.js]"]
  node_login_view["Login view<br/>[login.pug]"]
  node_register_view["Register view<br/>[register.pug]"]
end

subgraph group_storage["Persistence"]
  node_database_module["Database setup<br/>[database.js]"]
  node_blog_db[("Blog database<br/>[blog.db]")]
end

node_visitor(("Visitor"))

node_visitor -->|"sends requests"| node_app
node_app -->|"dispatches auth"| node_auth_routes
node_app -->|"checks session"| node_database_module
node_database_module -->|"initializes tables"| node_blog_db
node_app -->|"reads posts"| node_blog_db
node_app -->|"inserts posts"| node_blog_db
node_auth_routes -->|"queries users"| node_database_module
node_auth_routes -->|"updates users"| node_blog_db
node_auth_routes -->|"creates users"| node_blog_db
node_app -->|"renders posts"| node_home_view
node_app -->|"renders form"| node_new_post_view
node_app -->|"renders admin"| node_admin_view
node_auth_routes -->|"renders login"| node_login_view
node_auth_routes -->|"renders registration"| node_register_view
node_app -->|"responds"| node_visitor
node_auth_routes -->|"sets cookie"| node_visitor

click node_app "https://github.com/jerelintusalo/blog/blob/main/app.js"
click node_auth_routes "https://github.com/jerelintusalo/blog/blob/main/routes/auth.js"
click node_database_module "https://github.com/jerelintusalo/blog/blob/main/database.js"
click node_blog_db "https://github.com/jerelintusalo/blog/blob/main/blog.db"
click node_home_view "https://github.com/jerelintusalo/blog/blob/main/views/index.pug"
click node_new_post_view "https://github.com/jerelintusalo/blog/blob/main/views/new-post.pug"
click node_login_view "https://github.com/jerelintusalo/blog/blob/main/views/login.pug"
click node_register_view "https://github.com/jerelintusalo/blog/blob/main/views/register.pug"
click node_admin_view "https://github.com/jerelintusalo/blog/blob/main/views/admin.pug"

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_app,node_home_view,node_new_post_view,node_admin_view toneBlue
class node_auth_routes,node_login_view,node_register_view toneAmber
class node_database_module,node_blog_db toneMint
class node_visitor toneIndigo
```

## Components

### Web application

- [Express app](https://github.com/jerelintusalo/blog/blob/main/app.js): `app.js`
- [Post list view](https://github.com/jerelintusalo/blog/blob/main/views/index.pug): `views/index.pug`
- [New post view](https://github.com/jerelintusalo/blog/blob/main/views/new-post.pug): `views/new-post.pug`
- [Admin view](https://github.com/jerelintusalo/blog/blob/main/views/admin.pug): `views/admin.pug`

### Authentication

- [Auth routes](https://github.com/jerelintusalo/blog/blob/main/routes/auth.js): `routes/auth.js`
- [Login view](https://github.com/jerelintusalo/blog/blob/main/views/login.pug): `views/login.pug`
- [Register view](https://github.com/jerelintusalo/blog/blob/main/views/register.pug): `views/register.pug`

### Persistence

- [Database setup](https://github.com/jerelintusalo/blog/blob/main/database.js): `database.js`
- [Blog database](https://github.com/jerelintusalo/blog/blob/main/blog.db): `blog.db`

### Other components

- **Visitor**

## Connections

- Visitor → Express app: sends requests
- Express app → Auth routes: dispatches auth
- Express app → Database setup: checks session
- Database setup → Blog database: initializes tables
- Express app → Blog database: reads posts
- Express app → Blog database: inserts posts
- Auth routes → Database setup: queries users
- Auth routes → Blog database: updates users
- Auth routes → Blog database: creates users
- Express app → Post list view: renders posts
- Express app → New post view: renders form
- Express app → Admin view: renders admin
- Auth routes → Login view: renders login
- Auth routes → Register view: renders registration
- Express app → Visitor: responds
- Auth routes → Visitor: sets cookie
