How joseserpacode/forge-os works
Purpose and runtime
Forge OS is a self-hosted, multi-tenant team workspace combining Kanban/sprints, dynamic tables, a Notion-style knowledge base, files, and social profiles. Astro SSR runs as one Node process; SQLite is embedded and synchronous through better-sqlite3. Realtime behavior uses Socket.IO. Primary runtime entry/configuration: astro.config.mjs, server.mjs, src/lib/sockets.mjs.
Request entry and shared boundary enforcement
Astro pages provide server-rendered screens and src/pages/api/** provides the application API. Middleware is the cross-cutting request boundary for sessions, authorization, tenant context, and security policy; endpoint code must preserve server-side RBAC and workspace scoping rather than trust UI state. Relevant paths: src/middleware.ts, src/lib/guard.ts, src/pages/api/sys/state.ts.
Persistence and tenant isolation
SQLite schema and database access are centralized under the DB library. The core architectural invariant is workspace isolation: operational records are scoped by workspace_id, and API handlers must validate membership/role before reads or mutations. The repository has both core and social schema layers. Paths: src/lib/db.ts, src/lib/db/schema.ts, src/lib/db/social_schema.ts.
Identity, sessions, guests, and OAuth
Authentication supports local registration/login, guest sessions that can be promoted, account lifecycle actions, and optional Google/GitHub redirect OAuth. Rate limits, CAPTCHA, account validation, and signed secrets belong at this external-input boundary. Paths: src/pages/api/auth/login.ts, src/pages/api/auth/oauth/[provider]/callback.ts, src/lib/guest.ts.
Workspace and work-management domain
Workspaces organize membership, requests/invites, roles, resources, labels, issue types, issues, sprints, worklogs, and metrics. Issue/sprint changes drive board state, time tracking, notifications, automations, and derived reporting; services concentrate key domain behavior outside route handlers. Paths: src/lib/IssueService.ts, src/lib/WorkspaceService.ts, src/pages/api/w/[sys_tag]/issues.ts.
Main product surfaces
Server-rendered workspace routes compose Astro components with browser-side vanilla JS interactions. The board operates over issue ordering/status and sprint data; the knowledge base maintains page trees and issue/page links; dynamic databases expose user-defined structures and entries. Paths: src/pages/w/[sys_tag]/board.astro, src/components/jira/KanbanBoard.astro, src/components/notion/EditorClient.astro.
Files, deployment, and external boundaries
Uploads/storage are local filesystem concerns, separated from metadata endpoints and guarded against MIME/path traversal risks. Deployment assumes a persistent disk, Caddy reverse proxy, and systemd; backups must use SQLite’s backup mechanism because WAL is enabled. No required third-party SaaS exists; OAuth providers are conditional external integrations. Paths: src/lib/storage.ts, src/pages/api/w/[sys_tag]/files/upload.ts, deploy/forge-os.service.
Main entry points: server.mjs Astro SSR & API · db.ts SQLite access · login.ts Auth endpoints · upload.ts File upload API
Components 23
Runtime & edge
- Astro SSR & API · Serves pages and application endpoints in one Node process.
server.mjs - Request boundary · Applies sessions, authorization, tenant context, and security policy.
src/middleware.ts - RBAC & workspace guard · Enforces server-side membership, role, and workspace scoping.
src/lib/guard.ts - Socket.IO · Publishes realtime workspace changes.
src/lib/sockets.mjs - Google / GitHub
- Persistent host · systemd service behind Caddy with persistent disk.
deploy/forge-os.service
Application surfaces
- Workspace browser · SSR screens with vanilla JS interactions.
- Auth endpoints · Handles local login, lifecycle actions, and external-input protections.
src/pages/api/auth/login.ts - OAuth callback · Completes optional Google or GitHub redirect authentication.
src/pages/api/auth/oauth/[provider]/callback.ts - Workspace issue API · Workspace-scoped issue reads and mutations.
src/pages/api/w/[sys_tag]/issues.ts - Kanban board · Renders issue ordering, status, and sprint state.
src/pages/w/[sys_tag]/board.astro - Board component
src/components/jira/KanbanBoard.astro - Knowledge editor · Supports page trees and issue/page links.
src/components/notion/EditorClient.astro - System state API
src/pages/api/sys/state.ts - File upload API · Validates upload input before storing workspace files.
src/pages/api/w/[sys_tag]/files/upload.ts
Domain services
- Guest identity · Creates guest sessions and promotes them to accounts.
src/lib/guest.ts - Workspace service · Manages memberships, roles, requests, invites, and workspace resources.
src/lib/WorkspaceService.ts - Issue service · Coordinates issue and sprint behavior, worklogs, notifications, automations, and reporting.
src/lib/IssueService.ts
Persistence & storage
- Local file storage · Keeps file bytes separate from metadata and protects MIME/path boundaries.
src/lib/storage.ts - SQLite access · Central synchronous better-sqlite3 access layer.
src/lib/db.ts - Core workspace schema · Operational records are isolated by workspace_id.
src/lib/db/schema.ts - Social schema
src/lib/db/social_schema.ts - SQLite database · WAL-backed persistent database requiring SQLite-aware backups.
Connections 26
- Workspace browser → Astro SSR & API: HTTP / SSR
- Astro SSR & API → Request boundary: all requests
- Request boundary → RBAC & workspace guard: tenant and RBAC checks
- Astro SSR & API → Auth endpoints: routes to
- Auth endpoints → Guest identity: guest sessions
- Auth endpoints → SQLite access: accounts and sessions
- Auth endpoints → OAuth callback: OAuth flow
- OAuth callback → Google / GitHub: redirect exchange
- Astro SSR & API → Workspace issue API: routes to
- Workspace issue API → RBAC & workspace guard: enforces scope
- Workspace issue API → Issue service: issue mutations
- Issue service → Workspace service: membership and roles
- Issue service → SQLite access: issues, sprints, worklogs
- Issue service → Socket.IO: realtime changes
- Kanban board → Board component: composes
- Workspace browser → Kanban board: workspace view
- Workspace browser → Knowledge editor: knowledge view
- Astro SSR & API → File upload API: routes to
- File upload API → RBAC & workspace guard: workspace access
- File upload API → Local file storage: stores bytes
- File upload API → SQLite access: file metadata
- SQLite access → Core workspace schema: uses
- SQLite access → Social schema: uses
- SQLite access → SQLite database: reads and writes
- Persistent host → Astro SSR & API: runs
- Persistent host → SQLite database: persistent disk