# waraton/backend architecture

> Architecture diagram of the GitHub repository waraton/backend, 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/waraton/backend
- Repository: https://github.com/waraton/backend
- Video tour (about a minute): https://gitdiagram.com/waraton/backend/video

## Overview

This is an Express application for account-based blogging, with public post browsing, Markdown post authoring, and a logged-in color-conversion feature. The main workflow runs through server.js: users register or log in, create and manage posts, and view rendered post pages. SQLite stores users and posts; EJS templates present the pages. The README documents Markdown, images, and links in post bodies. Source excerpts are partial, so the graph omits uncertain middleware and route wiring beyond the documented and visible behavior.

Main entry points: [`server.js`](https://github.com/waraton/backend/blob/main/server.js) (Express app), [`views/home.ejs`](https://github.com/waraton/backend/blob/main/views/home.ejs) (Home page), [`views/dashboard.ejs`](https://github.com/waraton/backend/blob/main/views/dashboard.ejs) (Dashboard), [`views/create-post.ejs`](https://github.com/waraton/backend/blob/main/views/create-post.ejs) (Post forms)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Post workflows"]
  node_app["Express app<br/>[server.js]"]
  node_post_ops["Post routes<br/>[server.js]"]
  node_public_browse["Post browsing<br/>[server.js]"]
  node_color_convert["Color conversion<br/>[server.js]"]
  node_sqlite[("SQLite database<br/>[server.js]")]
end

subgraph group_identity["Account access"]
  node_auth["Account routes<br/>[server.js]"]
  node_credentials["Password checks<br/>[server.js]"]
  node_session["JWT cookie<br/>[server.js]"]
end

subgraph group_content["Content processing"]
  node_markdown["Markdown rendering<br/>[server.js]"]
  node_html_safety["HTML sanitizing<br/>[server.js]"]
end

subgraph group_presentation["Web presentation"]
  node_home_page["Home page<br/>[home.ejs]"]
  node_dashboard_page["Dashboard<br/>[dashboard.ejs]"]
  node_post_forms["Post forms<br/>[create-post.ejs]"]
  node_edit_page["Edit post<br/>[edit-post.ejs]"]
  node_single_page["Single post<br/>[single-post.ejs]"]
  node_all_posts_page["All posts<br/>[allposts.ejs]"]
  node_login_page["Login page<br/>[login.ejs]"]
  node_color_page["Color results<br/>[color.ejs]"]
  node_form_script["Form popups<br/>[form.js]"]
end

node_visitor(("Visitor"))

node_visitor -->|"sends requests"| node_app
node_app -->|"dispatches routes"| node_post_ops
node_app -->|"dispatches routes"| node_public_browse
node_app -->|"dispatches routes"| node_auth
node_app -->|"dispatches route"| node_color_convert
node_post_ops -->|"reads and writes"| node_sqlite
node_post_ops -->|"renders form"| node_post_forms
node_post_ops -->|"renders page"| node_edit_page
node_post_ops -->|"renders page"| node_single_page
node_public_browse -->|"reads posts"| node_sqlite
node_public_browse -->|"renders dashboard"| node_dashboard_page
node_public_browse -->|"renders home"| node_home_page
node_public_browse -->|"renders list"| node_all_posts_page
node_auth -->|"checks passwords"| node_credentials
node_auth -->|"reads and writes"| node_sqlite
node_auth -->|"issues session"| node_session
node_auth -->|"renders login"| node_login_page
node_auth -->|"renders home"| node_home_page
node_color_convert -->|"renders results"| node_color_page
node_app -->|"parses Markdown"| node_markdown
node_app -->|"sanitizes HTML"| node_html_safety
node_visitor -->|"opens forms"| node_form_script

click node_app "https://github.com/waraton/backend/blob/main/server.js"
click node_post_ops "https://github.com/waraton/backend/blob/main/server.js"
click node_public_browse "https://github.com/waraton/backend/blob/main/server.js"
click node_color_convert "https://github.com/waraton/backend/blob/main/server.js"
click node_sqlite "https://github.com/waraton/backend/blob/main/server.js"
click node_auth "https://github.com/waraton/backend/blob/main/server.js"
click node_credentials "https://github.com/waraton/backend/blob/main/server.js"
click node_session "https://github.com/waraton/backend/blob/main/server.js"
click node_markdown "https://github.com/waraton/backend/blob/main/server.js"
click node_html_safety "https://github.com/waraton/backend/blob/main/server.js"
click node_home_page "https://github.com/waraton/backend/blob/main/views/home.ejs"
click node_dashboard_page "https://github.com/waraton/backend/blob/main/views/dashboard.ejs"
click node_post_forms "https://github.com/waraton/backend/blob/main/views/create-post.ejs"
click node_edit_page "https://github.com/waraton/backend/blob/main/views/edit-post.ejs"
click node_single_page "https://github.com/waraton/backend/blob/main/views/single-post.ejs"
click node_all_posts_page "https://github.com/waraton/backend/blob/main/views/allposts.ejs"
click node_login_page "https://github.com/waraton/backend/blob/main/views/login.ejs"
click node_color_page "https://github.com/waraton/backend/blob/main/views/color.ejs"
click node_form_script "https://github.com/waraton/backend/blob/main/public/form.js"

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_post_ops,node_public_browse,node_color_convert,node_sqlite toneBlue
class node_auth,node_credentials,node_session toneAmber
class node_markdown,node_html_safety toneMint
class node_home_page,node_dashboard_page,node_post_forms,node_edit_page,node_single_page,node_all_posts_page,node_login_page,node_color_page,node_form_script toneRose
class node_visitor toneIndigo
```

## Components

### Post workflows

- [Express app](https://github.com/waraton/backend/blob/main/server.js): `server.js`
- [Post routes](https://github.com/waraton/backend/blob/main/server.js): `server.js`
- [Post browsing](https://github.com/waraton/backend/blob/main/server.js): `server.js`
- [Color conversion](https://github.com/waraton/backend/blob/main/server.js): `server.js`
- [SQLite database](https://github.com/waraton/backend/blob/main/server.js): `server.js`

### Account access

- [Account routes](https://github.com/waraton/backend/blob/main/server.js): `server.js`
- [Password checks](https://github.com/waraton/backend/blob/main/server.js): `server.js`
- [JWT cookie](https://github.com/waraton/backend/blob/main/server.js): `server.js`

### Content processing

- [Markdown rendering](https://github.com/waraton/backend/blob/main/server.js): `server.js`
- [HTML sanitizing](https://github.com/waraton/backend/blob/main/server.js): `server.js`

### Web presentation

- [Home page](https://github.com/waraton/backend/blob/main/views/home.ejs): `views/home.ejs`
- [Dashboard](https://github.com/waraton/backend/blob/main/views/dashboard.ejs): `views/dashboard.ejs`
- [Post forms](https://github.com/waraton/backend/blob/main/views/create-post.ejs): `views/create-post.ejs`
- [Edit post](https://github.com/waraton/backend/blob/main/views/edit-post.ejs): `views/edit-post.ejs`
- [Single post](https://github.com/waraton/backend/blob/main/views/single-post.ejs): `views/single-post.ejs`
- [All posts](https://github.com/waraton/backend/blob/main/views/allposts.ejs): `views/allposts.ejs`
- [Login page](https://github.com/waraton/backend/blob/main/views/login.ejs): `views/login.ejs`
- [Color results](https://github.com/waraton/backend/blob/main/views/color.ejs): `views/color.ejs`
- [Form popups](https://github.com/waraton/backend/blob/main/public/form.js): `public/form.js`

### Other components

- **Visitor**

## Connections

- Visitor → Express app: sends requests
- Express app → Post routes: dispatches routes
- Express app → Post browsing: dispatches routes
- Express app → Account routes: dispatches routes
- Express app → Color conversion: dispatches route
- Post routes → SQLite database: reads and writes
- Post routes → Post forms: renders form
- Post routes → Edit post: renders page
- Post routes → Single post: renders page
- Post browsing → SQLite database: reads posts
- Post browsing → Dashboard: renders dashboard
- Post browsing → Home page: renders home
- Post browsing → All posts: renders list
- Account routes → Password checks: checks passwords
- Account routes → SQLite database: reads and writes
- Account routes → JWT cookie: issues session
- Account routes → Login page: renders login
- Account routes → Home page: renders home
- Color conversion → Color results: renders results
- Express app → Markdown rendering: parses Markdown
- Express app → HTML sanitizing: sanitizes HTML
- Visitor → Form popups: opens forms
