How chiragsingla014/orbital works
1. Overall shape
- Orbital is a two-app monorepo: a React/Vite frontend and a Node/Express backend, each with its own TypeScript build and dependency tree.
- Runtime flow is simple: browser → HTTP API → MongoDB. The frontend owns presentation/state; the backend owns auth, validation, and persistence.
2. Frontend shell
- The frontend is organized around App.tsx, routed pages, and reusable UI primitives.
- Pages are split into signin, signup, dashboard, and contentView, which suggests a clear separation between authentication and the main content workspace.
3. Frontend state and data access
- hooks/useContent.tsx and hooks/useContentEditor.tsx appear to centralize content fetching, selection, and editing behavior rather than pushing that logic into components.
- useDarkMode.tsx is isolated as a client-side UI concern, separate from domain logic.
4. Content rendering layer
- The components/content/ folder is the key polymorphic UI layer: it contains specialized renderers and editors for different content kinds such as notes, todos, streams/embeds, and networks.
- Components like Card, ContentMeta, and ContentActions provide shared chrome, while TodoList, Stream, and NetworkNodes handle type-specific rendering.
5. Navigation and layout
- Sidebar and SidebarItem indicate a persistent navigation shell around the main workspace.
- The layout is designed for browsing and drilling into content graphs, not just viewing isolated records.
6. Backend entrypoint and route boundary
- backend/src/index.ts is the server bootstrap, and backend/src/routes/index.ts is the routing composition point.
- The backend is split by domain into user, content, and share routes, which is the main architectural boundary for API behavior.
7. Authentication boundary
- backend/src/middlewares/auth.ts is the protection layer for private API access.
- The backend uses JWT-based auth, so most content operations are likely authenticated, while public share access is handled separately.
8. Domain model and persistence
- MongoDB + Mongoose are the persistence core.
- The readme and model files indicate a polymorphic content model: one shared base schema with specialized variants for different kinds of content.
- This is the main data architecture choice: heterogeneous items live together, which keeps querying and population simpler than separate collections.
9. Recursive network structure
- The network content type is special: it can reference other content items via nodes.
- Because nodes can include other networks, the system supports recursive, nested knowledge graphs without copying data, making content relationships first-class.
10. Validation and typing
- backend/src/valid/ contains Zod validators for the main domains, giving the API a request-validation boundary before data reaches Mongoose.
- backend/src/types/ mirrors the domain shapes in TypeScript, so the backend keeps request, model, and response shapes aligned.
11. Public sharing path
- backend/src/routes/share.ts is a separate access path for public, unauthenticated viewing of shared content.
- This is an important architectural split: normal content is user-scoped and protected, while shared content is intentionally readable without login.
12. Configuration and environment
- backend/src/config/config.ts centralizes environment-driven settings like MongoDB connection details, JWT secret, and server port.
- This keeps deployment concerns out of feature code and makes the backend portable across local and hosted environments.
13. Technology boundaries that matter
- Frontend: React + TypeScript + Tailwind + React Router for the interactive client.
- Backend: Node.js + Express + TypeScript for the API.
- Storage: MongoDB/Mongoose for polymorphic document persistence.
- Security/validation: JWT + Zod at the API boundary.
14. How to diagram it
- A good architecture diagram would show:
- a client UI layer with routed pages, shared components, and content-type renderers;
- an API layer with auth, content CRUD, and share routes;
- a domain/persistence layer with users, polymorphic content, tags/links, and recursive network references;
- and MongoDB as the system of record.
Main entry points: content.ts Content · pages Pages · index.ts Routes · user.ts Users
Components 18
Frontend
React/Vite client
- App shell · Top-level client composition and routing
frontend/src/App.tsx - Pages · Signin, signup, dashboard, and content view screens
frontend/src/pages - Sidebar · Persistent navigation shell for browsing content
frontend/src/components/Sidebar.tsx - Content UI · Shared cards, actions, and specialized renderers for notes, todos, streams, and networks
frontend/src/components/content - Content hooks · Centralized content fetch, selection, editing, and theme state
frontend/src/hooks - Client entry · Frontend bootstrap and mount point
frontend/src/main.tsx
Backend
Node/Express API
- API entry · Server startup and middleware wiring
backend/src/index.ts - Routes · Main API routing boundary
backend/src/routes/index.ts - Users · Signup, signin, and user-scoped API endpoints
backend/src/routes/user.ts - Content · Authenticated content CRUD and graph operations
backend/src/routes/content.ts - Share · Unauthenticated public content access
backend/src/routes/share.ts - Auth guard · JWT protection for private API access
backend/src/middlewares/auth.ts - Validators · Request validation for users, content, links, and tags
backend/src/valid - Types · Shared domain shapes for request and model alignment
backend/src/types - Config · Server, database, and JWT settings
backend/src/config/config.ts
Data
Persistence and shared domain
- Models · Polymorphic content, links, tags, and user persistence models
backend/src/models - MongoDB · System of record for users and polymorphic content
Other components
- Browser · User-facing app entrypoint
Connections 23
- Browser → Client entry: loads · Client runtime starts here
- Client entry → App shell: mounts · Bootstraps the React application
- App shell → Pages: routes to · Switches between auth and workspace views
- App shell → Sidebar: frames · Provides persistent navigation
- Pages → Content UI: renders · Dashboard and content view use specialized content components
- Pages → Content hooks: uses · Pages delegate content and UI state to hooks
- Content UI → Content hooks: reads state · Renderers consume fetched and selected content
- Content hooks → API entry: requests API · Client fetches data from the backend
- API entry → Config: loads · Reads environment-driven settings
- API entry → Routes: mounts · Wires routing into the Express app
- Routes → Users: delegates · Authentication and user endpoints
- Routes → Content: delegates · Private content endpoints
- Routes → Share: delegates · Public sharing endpoints
- Content → Auth guard: protects · Private content operations require JWT auth
- Content → Validators: validates · Checks content and link payloads before persistence
- Users → Validators: validates · Checks user credentials and signup input
- Share → Models: reads · Public reads resolve shared content
- Content → Models: writes · Content CRUD persists polymorphic documents
- Users → Models: writes · User records are stored in MongoDB
- Models → MongoDB: persists to · Mongoose stores data in MongoDB
- Validators → Types: aligns with · Validation mirrors TypeScript domain contracts
- Content UI → Content: interacts with · Content views and editors operate on API-backed content
- Pages → Users: authenticates via · Signin and signup pages talk to user endpoints