How kilencje/tori works
This is a server-rendered Node.js/Express web application (monolith) that serves:
• HTML pages rendered with EJS (views/*.ejs, views/partials/navbar.ejs)
• Static assets (CSS, images, and a public data.json) from public/
• Content/data from local JSON files (data.json, quiz.json, technology.json)
• A client-side embedded external experience via NUKEMAP iframe (in the Technology page)
• A data maintenance/sync pipeline via utils/update-data.js (CSV <-> JSON, “Google Sheets integration” likely via axios or CSV export URLs)
Runtime request/response (Browser ↔ Express ↔ EJS ↔ JSON/static)
2) Offline/admin data update flow (Developer/Admin ↔ update-data.js ↔ CSV/Sheets ↔ JSON files)
Read the file tree as architecture hints (what to reflect as components)
From the tree:
Runtime (web app)
• app.js → single Express entrypoint: routes, middleware (compression, caching), view engine setup
• views/ → EJS server-side rendering (SSR)
• public/ → static hosting (style.css, pictures, and public/data.json)
• Root JSON files: data.json, quiz.json, technology.json → local content store
• data.js (present) → likely a data access/helper module; include it as an internal “Data Loader/Repository” component if it’s used by app.js.
Offline / tooling
• utils/update-data.js → CLI tool for CSV import/export + sync
• package.json dependencies: express, ejs, compression, axios → include:
• compression = response gzip
• axios = outbound HTTP requests (likely Sheets/CSV download, or remote sync)
External
• NUKEMAP (iframe) → external site loaded in client browser (not server-to-server)
• Google Sheets / CSV source → external data origin for the sync tool
Client (Browser)
• loads HTML
• loads CSS/images from /public
• sends navigation requests with language query param
Node.js Process (Express Server)
• Middleware: compression (gzip), caching headers
• Router/controller layer for each route
• View rendering via EJS
• Reads JSON from filesystem
File Storage (Local filesystem)
• data.json, quiz.json, technology.json
• public/style.css, public/pictures/*, public/data.json
(Optional but recommended) Reverse Proxy / Hosting Edge
• If deployed behind Nginx/Apache/Cloud proxy, show it as a separate container (even if not in repo). If unknown, annotate as “optional”.
Key flows
• Browser ⇄ Express:
• Requests pages → Express chooses route → loads data → renders EJS → returns HTML
• Browser → Express (static):
• Requests /style.css, /pictures/* → Express static middleware returns files with long cache headers
• Express → filesystem:
• Reads JSON content (battles/weapons/quiz/tech)
• Browser → NUKEMAP:
• iframe loads nukemap directly
• Express → Browser: “gzip compression”
• Express → Browser: “Cache-Control (HTML 1h, CSS/JS 7d, images 30d, API data 30m)” (from README)
Purpose: show the major modules inside the Node process. This is where you “separate into as many components as possible”.
Within the Express App boundary, split into:
Middleware Layer
• compression (gzip)
• “Static Assets Middleware” serving public/
• “Cache Policy Middleware” (per content type)
• “Error Handling / 404” rendering views/error_404.ejs
Routing / Controllers (group by feature)
• Home Controller: GET / → renders views/index.ejs
• Battles Controller:
• GET /battles → views/battles.ejs list
• GET /battle/:id → views/battle.ejs details
• Weapons Controller:
• GET /weapons → views/weapons.ejs
• GET /weapon/:id → views/weapon.ejs
• Quiz Controller:
• GET /quiz → views/quiz.ejs (difficulty, scoring logic)
• Technology Controller:
• GET /technology → views/technology.ejs (includes nukemap iframe)
• About Controller:
• GET /about → views/about.ejs
Localization / i18n Resolver
Even if it’s simple, model it:
• “Language Resolver” reads ?lang= and selects fields like name_en/name_hu/name_ro, description_*, question_*, etc.
• Passes resolved strings into EJS templates
Data Access Layer (filesystem JSON)
As:
• “Battles & Weapons Repository” reading from data.json
• “Quiz Repository” reading from quiz.json
• “Technology Repository” reading from technology.json
• (If data.js exists as a helper, show it as the module implementing these reads/parses/caches.)
View Layer (EJS)
• EJS templates per page + shared partial: views/partials/navbar.ejs
• Static theme: public/style.css
• Images: public/pictures/*
• Controllers → Repositories (read data)
• Controllers → i18n Resolver (select language-specific fields)
• Controllers → EJS Views (render)
• EJS Views → Partials (navbar include)
• Views → Static assets (referenced by URL; browser fetches them)
Don’t forget the “data sync” architecture (it’s part of the system)
Components
• Admin/Developer (human)
• utils/update-data.js (Node CLI tool)
• CSV files in repo root (input/output)
• Google Sheets / Google Drive export endpoints (external)
• JSON stores: data.json, quiz.json, technology.json (outputs consumed by runtime server)
• update-data.js ↔ Google Sheets: HTTP fetch/upload (use axios)
• update-data.js ↔ CSV files: read/write
• update-data.js → JSON files: generate/update
• Express runtime → JSON files: read at runtime
Container: Browser / Node(Express) / Local FS / External systems
3) Component (Express): middleware, controllers per route, i18n resolver, repositories, EJS views/partials
Data Pipeline: update-data.js ↔ Sheets/CSV → JSON → consumed by runtime
That set is detailed, accurate to the tree/README, and separates “serving the site” from “maintaining the content,” which is the key architectural reality of this project.