# dansalviano/vanilla-js-spa architecture

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

- Interactive diagram: https://gitdiagram.com/dansalviano/vanilla-js-spa
- Repository: https://github.com/dansalviano/vanilla-js-spa

## Overview

This is a small vanilla-JavaScript single-page application served by Express. The browser loads the SPA shell, the client router maps URLs to views, and each view renders HTML into the app container; post-list data is held in memory and reused for detail pages. The README documents serving the app on port 3001. Source excerpts do not establish any backend data API or persistence, so none is shown.

Main entry points: [`frontend/static/js/index.js`](https://github.com/dansalviano/vanilla-js-spa/blob/main/frontend/static/js/index.js) (Client router), [`frontend/static/js/views/AbstractView.js`](https://github.com/dansalviano/vanilla-js-spa/blob/main/frontend/static/js/views/AbstractView.js) (View base), [`server.js`](https://github.com/dansalviano/vanilla-js-spa/blob/main/server.js) (Express server), [`frontend/static/js/views/Posts.js`](https://github.com/dansalviano/vanilla-js-spa/blob/main/frontend/static/js/views/Posts.js) (Posts list)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_serving["Static serving"]
  node_express["Express server<br/>[server.js]"]
  node_spa_shell["SPA shell<br/>[index.html]"]
  node_static_assets["Static assets"]
end

subgraph group_routing["Client routing"]
  node_router["Client router<br/>[index.js]"]
  node_view_base["View base<br/>[AbstractView.js]"]
end

subgraph group_views["Page views"]
  node_dashboard["Dashboard<br/>[Dashboard.js]"]
  node_posts_list["Posts list<br/>[Posts.js]"]
  node_post_detail["Post detail<br/>[PostView.js]"]
  node_settings["Settings<br/>[Settings.js]"]
  node_not_found["404 view<br/>[404.js]"]
  node_snow_effect["Snow animation<br/>[NotFound.js]"]
end

subgraph group_content["Post content"]
  node_posts_data["In-memory posts<br/>[Posts.js]"]
end

node_browser(("Browser user"))

node_browser -->|"requests app"| node_express
node_express -->|"serves fallback"| node_spa_shell
node_express -->|"serves /static"| node_static_assets
node_browser -.->|"loads client"| node_router
node_router -->|"selects route"| node_dashboard
node_router -->|"selects route"| node_posts_list
node_router -->|"selects route"| node_post_detail
node_router -->|"selects route"| node_settings
node_router -->|"selects fallback"| node_not_found
node_router -->|"renders via"| node_view_base
node_dashboard -->|"extends"| node_view_base
node_posts_list -->|"extends"| node_view_base
node_post_detail -->|"extends"| node_view_base
node_settings -->|"extends"| node_view_base
node_not_found -->|"extends"| node_view_base
node_not_found -->|"registers script"| node_snow_effect
node_posts_list -->|"renders"| node_posts_data
node_post_detail -->|"looks up post"| node_posts_data

click node_express "https://github.com/dansalviano/vanilla-js-spa/blob/main/server.js"
click node_spa_shell "https://github.com/dansalviano/vanilla-js-spa/blob/main/frontend/index.html"
click node_static_assets "https://github.com/dansalviano/vanilla-js-spa/tree/main/frontend/static"
click node_router "https://github.com/dansalviano/vanilla-js-spa/blob/main/frontend/static/js/index.js"
click node_view_base "https://github.com/dansalviano/vanilla-js-spa/blob/main/frontend/static/js/views/AbstractView.js"
click node_dashboard "https://github.com/dansalviano/vanilla-js-spa/blob/main/frontend/static/js/views/Dashboard.js"
click node_posts_list "https://github.com/dansalviano/vanilla-js-spa/blob/main/frontend/static/js/views/Posts.js"
click node_post_detail "https://github.com/dansalviano/vanilla-js-spa/blob/main/frontend/static/js/views/PostView.js"
click node_settings "https://github.com/dansalviano/vanilla-js-spa/blob/main/frontend/static/js/views/Settings.js"
click node_not_found "https://github.com/dansalviano/vanilla-js-spa/blob/main/frontend/static/js/views/404.js"
click node_snow_effect "https://github.com/dansalviano/vanilla-js-spa/blob/main/frontend/static/js/NotFound.js"
click node_posts_data "https://github.com/dansalviano/vanilla-js-spa/blob/main/frontend/static/js/views/Posts.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_express,node_spa_shell,node_static_assets,node_browser toneBlue
class node_router,node_view_base toneAmber
class node_dashboard,node_posts_list,node_post_detail,node_settings,node_not_found,node_snow_effect toneMint
class node_posts_data toneRose
```

## Components

### Static serving

- [Express server](https://github.com/dansalviano/vanilla-js-spa/blob/main/server.js): `server.js`
- [SPA shell](https://github.com/dansalviano/vanilla-js-spa/blob/main/frontend/index.html): `frontend/index.html`
- [Static assets](https://github.com/dansalviano/vanilla-js-spa/tree/main/frontend/static): `frontend/static`

### Client routing

- [Client router](https://github.com/dansalviano/vanilla-js-spa/blob/main/frontend/static/js/index.js): `frontend/static/js/index.js`
- [View base](https://github.com/dansalviano/vanilla-js-spa/blob/main/frontend/static/js/views/AbstractView.js): `frontend/static/js/views/AbstractView.js`

### Page views

- [Dashboard](https://github.com/dansalviano/vanilla-js-spa/blob/main/frontend/static/js/views/Dashboard.js): `frontend/static/js/views/Dashboard.js`
- [Posts list](https://github.com/dansalviano/vanilla-js-spa/blob/main/frontend/static/js/views/Posts.js): `frontend/static/js/views/Posts.js`
- [Post detail](https://github.com/dansalviano/vanilla-js-spa/blob/main/frontend/static/js/views/PostView.js): `frontend/static/js/views/PostView.js`
- [Settings](https://github.com/dansalviano/vanilla-js-spa/blob/main/frontend/static/js/views/Settings.js): `frontend/static/js/views/Settings.js`
- [404 view](https://github.com/dansalviano/vanilla-js-spa/blob/main/frontend/static/js/views/404.js): `frontend/static/js/views/404.js`
- [Snow animation](https://github.com/dansalviano/vanilla-js-spa/blob/main/frontend/static/js/NotFound.js): `frontend/static/js/NotFound.js`

### Post content

- [In-memory posts](https://github.com/dansalviano/vanilla-js-spa/blob/main/frontend/static/js/views/Posts.js): `frontend/static/js/views/Posts.js`

### Other components

- **Browser user**

## Connections

- Browser user → Express server: requests app (evidence: `README.md`)
- Express server → SPA shell: serves fallback (evidence: `server.js`)
- Express server → Static assets: serves /static (evidence: `server.js`)
- Browser user → Client router: loads client
- Client router → Dashboard: selects route (evidence: `frontend/static/js/index.js`)
- Client router → Posts list: selects route (evidence: `frontend/static/js/index.js`)
- Client router → Post detail: selects route (evidence: `frontend/static/js/index.js`)
- Client router → Settings: selects route (evidence: `frontend/static/js/index.js`)
- Client router → 404 view: selects fallback (evidence: `frontend/static/js/index.js`)
- Client router → View base: renders via (evidence: `frontend/static/js/index.js`)
- Dashboard → View base: extends (evidence: `frontend/static/js/views/Dashboard.js`)
- Posts list → View base: extends (evidence: `frontend/static/js/views/Posts.js`)
- Post detail → View base: extends (evidence: `frontend/static/js/views/PostView.js`)
- Settings → View base: extends (evidence: `frontend/static/js/views/Settings.js`)
- 404 view → View base: extends (evidence: `frontend/static/js/views/404.js`)
- 404 view → Snow animation: registers script (evidence: `frontend/static/js/views/404.js`)
- Posts list → In-memory posts: renders (evidence: `frontend/static/js/views/Posts.js`)
- Post detail → In-memory posts: looks up post (evidence: `frontend/static/js/views/PostView.js`)
