How vochant/leinumoes works
Purpose and Runtime
Leinumoes is a self-hosted Node.js community platform combining forums, blogs, activity feeds, messaging, file storage, tickets, administration, OAuth, and static documents. Express is the HTTP/server-rendering boundary; SQLite is the persistent store. Application startup and server composition begin at index.js, with runtime configuration in src/config.js.
Request Routing and Presentation Split
The server routes requests to domain handlers, API endpoints, page-model endpoints, static content, and WebSocket messaging. Route definitions are centralized in src/constants/routes.js; response/page adaptation is shared through src/util/page_response.js. Two independently built frontends consume the same backend:
• Primary V2 React SPA: frontend/v2/src/main.tsx, frontend/v2/src/routes.ts, frontend/v2/src/api.ts.
• Compatibility V1 server-rendered EJS pages: frontend/v1/layouts/layout.html, frontend/v1/pages/.
Mount roots are runtime-configurable (/ and /v1/ by default).
Domain Handler Layer
Handlers implement request-level authorization, validation, orchestration, and page/API responses for major product areas. Representative boundaries are forum content in src/handlers/article_handler.js, social activity in src/handlers/activity_handler.js, messaging in src/handlers/message_handler.js, blogs in src/handlers/blog_handler.js, and identity/settings in src/handlers/login_handler.js and src/handlers/settings_handler.js. Administrative, ticket, drive/image, document, and OAuth concerns have separate handlers under src/handlers/.
Persistence and State
The database layer encapsulates SQLite access and domain storage operations. src/db/database.js provides the database foundation; entity modules model stored state and queries, including src/db/user.js, src/db/article.js, src/db/message.js, src/db/drive.js, src/db/oauth.js, and src/db/ticket.js. SQLite is accessed through the native better-sqlite3 dependency. Account relationships, permissions, content, attachments, audits, tokens, and notifications cross this boundary rather than being owned by either frontend.
Identity, Authorization, and Operations
Authentication/session behavior, capability checks, and security controls are concentrated in src/util/auth.js and src/util/security.js; configuration supplies session secrets, secure-cookie/proxy policy, invitation mode, guest access, CORS, limits, and quota policy. Admin workflows include permissions, invitations, audit history, operator notifications, and controlled user impersonation via src/handlers/admin_handler.js and src/db/admin_audit.js. Operator console commands are a distinct operational interface in src/util/commands/index.js.
Content, Files, and Messaging Pipelines
User-authored forum/blog/activity content moves through shared format and Markdown rendering/sanitization boundaries in src/util/content_formats.js, src/util/markdown.js, and src/util/super_markdown.js. Images and user drive files are handled separately by src/handlers/image_handler.js, src/handlers/drive_handler.js, and src/util/drive_quota.js, enforcing configured quotas and upload constraints. Direct/group messages use HTTP handlers plus a real-time WebSocket channel at src/ws/message.js; attachment processing and forwarding are shared utilities.
Build and External Boundaries
npm start builds frontend artifacts into build/ and starts the Node server. Build orchestration resides in scripts/build-web.js and scripts/build-blog-themes.js; V2 uses Vite (frontend/v2/vite.config.js). External/browser-facing integrations include OAuth 2.0 authorization-code and refresh-token provider flows (src/handlers/oauth_handler.js, src/db/oauth.js), credentialed CORS, reverse-proxy deployment, and configured static-document publication from static/ through src/static_documents.js.
Main entry points: routes.js Route registry · user.js Domain storage · index.js Node server entry · article_handler.js Content handlers
Components 22
Server Runtime
- Node server entry · Composes the HTTP server and startup runtime.
index.js - Runtime config
src/config.js - Route registry
src/constants/routes.js - Page response adapter · Shares page and API response adaptation.
src/util/page_response.js - Auth & security · Sessions, capabilities, and security policy.
src/util/auth.js
Frontend & Published Content
- V2 React SPA
frontend/v2/src/main.tsx - V1 EJS pages
frontend/v1/layouts/layout.html - Static documents
src/static_documents.js
Application Domains
- Content handlers · Forum, blog, and activity request orchestration.
src/handlers/article_handler.js - Messaging handler
src/handlers/message_handler.js - Message WebSocket
src/ws/message.js - File handlers · Image and drive upload access boundary.
src/handlers/drive_handler.js - Admin workflows
src/handlers/admin_handler.js - OAuth provider · Authorization-code and refresh-token flows.
src/handlers/oauth_handler.js - Content rendering · Formats, renders, and sanitizes authored Markdown.
src/util/markdown.js
Persistence & Operations
- Database foundation · Encapsulates native better-sqlite3 access.
src/db/database.js - Domain storage · Users, content, messages, files, OAuth, and tickets.
src/db/user.js - Admin audit log
src/db/admin_audit.js - Operator commands
src/util/commands/index.js
Build Pipeline
- Web build orchestrator · Builds frontend artifacts before server startup.
scripts/build-web.js - Vite build
frontend/v2/vite.config.js - Built assets
Connections 30
- Runtime config → Node server entry: configures
- Node server entry → Route registry: uses
- Route registry → Content handlers: routes content requests
- Route registry → Messaging handler: routes message HTTP
- Route registry → File handlers: routes uploads
- Route registry → Admin workflows: routes admin
- Route registry → OAuth provider: routes OAuth
- Node server entry → Message WebSocket: hosts
- Node server entry → Static documents: publishes
- Content handlers → Auth & security: authorizes
- Messaging handler → Auth & security: authorizes
- File handlers → Auth & security: authorizes
- Admin workflows → Auth & security: enforces permissions
- Content handlers → Content rendering: formats content
- Content handlers → Domain storage: stores content
- Messaging handler → Domain storage: stores messages
- Message WebSocket → Domain storage: delivers messages
- File handlers → Domain storage: stores file metadata
- OAuth provider → Domain storage: stores tokens
- Admin workflows → Admin audit log: records actions
- Domain storage → Database foundation: uses
- Admin audit log → Database foundation: uses
- Operator commands → Database foundation: operates on
- V2 React SPA → Route registry: API requests
- V1 EJS pages → Page response adapter: renders through
- Page response adapter → Content handlers: adapts responses
- Web build orchestrator → Vite build: invokes
- Vite build → V2 React SPA: builds
- Web build orchestrator → Built assets: emits
- Node server entry → Built assets: serves