# chiragsingla014/orbital architecture

> Architecture diagram of the GitHub repository chiragsingla014/orbital, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-06-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/chiragsingla014/orbital
- Repository: https://github.com/chiragsingla014/orbital

## Overview

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: [`backend/src/routes/content.ts`](https://github.com/chiragsingla014/orbital/blob/main/backend/src/routes/content.ts) (Content), [`frontend/src/pages`](https://github.com/chiragsingla014/orbital/tree/main/frontend/src/pages) (Pages), [`backend/src/routes/index.ts`](https://github.com/chiragsingla014/orbital/blob/main/backend/src/routes/index.ts) (Routes), [`backend/src/routes/user.ts`](https://github.com/chiragsingla014/orbital/blob/main/backend/src/routes/user.ts) (Users)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Frontend"]
  node_frontend_app["App shell<br/>React root<br/>[App.tsx]"]
  node_frontend_pages["Pages<br/>routed views"]
  node_frontend_sidebar["Sidebar<br/>navigation UI<br/>[Sidebar.tsx]"]
  node_frontend_content_ui["Content UI<br/>polymorphic renderers"]
  node_frontend_hooks["Content hooks<br/>client state"]
  node_frontend_main["Client entry<br/>bootstrap<br/>[main.tsx]"]
end

subgraph group_backend["Backend"]
  node_api_entry["API entry<br/>Express bootstrap<br/>[index.ts]"]
  node_api_routes["Routes<br/>route composition<br/>[index.ts]"]
  node_user_routes["Users<br/>auth routes<br/>[user.ts]"]
  node_content_routes["Content<br/>[content.ts]"]
  node_share_routes["Share<br/>public routes<br/>[share.ts]"]
  node_auth_mw["Auth guard<br/>middleware<br/>[auth.ts]"]
  node_validators["Validators<br/>zod schemas"]
  node_types["Types<br/>ts contracts"]
  node_config["Config<br/>[config.ts]"]
end

subgraph group_data["Data"]
  node_domain_models[("Models<br/>mongoose schemas")]
  node_mongodb[("MongoDB<br/>document store")]
end

node_browser(("Browser<br/>runtime client"))

node_browser -->|"loads"| node_frontend_main
node_frontend_main -->|"mounts"| node_frontend_app
node_frontend_app -->|"routes to"| node_frontend_pages
node_frontend_app -->|"frames"| node_frontend_sidebar
node_frontend_pages -->|"renders"| node_frontend_content_ui
node_frontend_pages -->|"uses"| node_frontend_hooks
node_frontend_content_ui -->|"reads state"| node_frontend_hooks
node_frontend_hooks -->|"requests API"| node_api_entry
node_api_entry -->|"loads"| node_config
node_api_entry -->|"mounts"| node_api_routes
node_api_routes -->|"delegates"| node_user_routes
node_api_routes -->|"delegates"| node_content_routes
node_api_routes -->|"delegates"| node_share_routes
node_content_routes -->|"protects"| node_auth_mw
node_content_routes -->|"validates"| node_validators
node_user_routes -->|"validates"| node_validators
node_share_routes -->|"reads"| node_domain_models
node_content_routes -->|"writes"| node_domain_models
node_user_routes -->|"writes"| node_domain_models
node_domain_models -->|"persists to"| node_mongodb
node_validators -->|"aligns with"| node_types
node_frontend_content_ui -->|"interacts with"| node_content_routes
node_frontend_pages -->|"authenticates via"| node_user_routes

click node_frontend_app "https://github.com/chiragsingla014/orbital/blob/main/frontend/src/App.tsx"
click node_frontend_pages "https://github.com/chiragsingla014/orbital/tree/main/frontend/src/pages"
click node_frontend_sidebar "https://github.com/chiragsingla014/orbital/blob/main/frontend/src/components/Sidebar.tsx"
click node_frontend_content_ui "https://github.com/chiragsingla014/orbital/tree/main/frontend/src/components/content"
click node_frontend_hooks "https://github.com/chiragsingla014/orbital/tree/main/frontend/src/hooks"
click node_frontend_main "https://github.com/chiragsingla014/orbital/blob/main/frontend/src/main.tsx"
click node_api_entry "https://github.com/chiragsingla014/orbital/blob/main/backend/src/index.ts"
click node_api_routes "https://github.com/chiragsingla014/orbital/blob/main/backend/src/routes/index.ts"
click node_user_routes "https://github.com/chiragsingla014/orbital/blob/main/backend/src/routes/user.ts"
click node_content_routes "https://github.com/chiragsingla014/orbital/blob/main/backend/src/routes/content.ts"
click node_share_routes "https://github.com/chiragsingla014/orbital/blob/main/backend/src/routes/share.ts"
click node_auth_mw "https://github.com/chiragsingla014/orbital/blob/main/backend/src/middlewares/auth.ts"
click node_validators "https://github.com/chiragsingla014/orbital/tree/main/backend/src/valid"
click node_domain_models "https://github.com/chiragsingla014/orbital/tree/main/backend/src/models"
click node_types "https://github.com/chiragsingla014/orbital/tree/main/backend/src/types"
click node_config "https://github.com/chiragsingla014/orbital/blob/main/backend/src/config/config.ts"

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_frontend_app,node_frontend_pages,node_frontend_sidebar,node_frontend_content_ui,node_frontend_hooks,node_frontend_main toneBlue
class node_api_entry,node_api_routes,node_user_routes,node_content_routes,node_share_routes,node_auth_mw,node_validators,node_types,node_config toneAmber
class node_domain_models,node_mongodb toneMint
class node_browser toneNeutral
```

## Components

### Frontend

React/Vite client

- [App shell](https://github.com/chiragsingla014/orbital/blob/main/frontend/src/App.tsx): React root · Top-level client composition and routing · `frontend/src/App.tsx`
- [Pages](https://github.com/chiragsingla014/orbital/tree/main/frontend/src/pages): routed views · Signin, signup, dashboard, and content view screens · `frontend/src/pages`
- [Sidebar](https://github.com/chiragsingla014/orbital/blob/main/frontend/src/components/Sidebar.tsx): navigation UI · Persistent navigation shell for browsing content · `frontend/src/components/Sidebar.tsx`
- [Content UI](https://github.com/chiragsingla014/orbital/tree/main/frontend/src/components/content): polymorphic renderers · Shared cards, actions, and specialized renderers for notes, todos, streams, and networks · `frontend/src/components/content`
- [Content hooks](https://github.com/chiragsingla014/orbital/tree/main/frontend/src/hooks): client state · Centralized content fetch, selection, editing, and theme state · `frontend/src/hooks`
- [Client entry](https://github.com/chiragsingla014/orbital/blob/main/frontend/src/main.tsx): bootstrap · Frontend bootstrap and mount point · `frontend/src/main.tsx`

### Backend

Node/Express API

- [API entry](https://github.com/chiragsingla014/orbital/blob/main/backend/src/index.ts): Express bootstrap · Server startup and middleware wiring · `backend/src/index.ts`
- [Routes](https://github.com/chiragsingla014/orbital/blob/main/backend/src/routes/index.ts): route composition · Main API routing boundary · `backend/src/routes/index.ts`
- [Users](https://github.com/chiragsingla014/orbital/blob/main/backend/src/routes/user.ts): auth routes · Signup, signin, and user-scoped API endpoints · `backend/src/routes/user.ts`
- [Content](https://github.com/chiragsingla014/orbital/blob/main/backend/src/routes/content.ts): content routes · Authenticated content CRUD and graph operations · `backend/src/routes/content.ts`
- [Share](https://github.com/chiragsingla014/orbital/blob/main/backend/src/routes/share.ts): public routes · Unauthenticated public content access · `backend/src/routes/share.ts`
- [Auth guard](https://github.com/chiragsingla014/orbital/blob/main/backend/src/middlewares/auth.ts): middleware · JWT protection for private API access · `backend/src/middlewares/auth.ts`
- [Validators](https://github.com/chiragsingla014/orbital/tree/main/backend/src/valid): zod schemas · Request validation for users, content, links, and tags · `backend/src/valid`
- [Types](https://github.com/chiragsingla014/orbital/tree/main/backend/src/types): ts contracts · Shared domain shapes for request and model alignment · `backend/src/types`
- [Config](https://github.com/chiragsingla014/orbital/blob/main/backend/src/config/config.ts): env config · Server, database, and JWT settings · `backend/src/config/config.ts`

### Data

Persistence and shared domain

- [Models](https://github.com/chiragsingla014/orbital/tree/main/backend/src/models): mongoose schemas · Polymorphic content, links, tags, and user persistence models · `backend/src/models`
- **MongoDB**: document store · System of record for users and polymorphic content

### Other components

- **Browser**: runtime client · User-facing app entrypoint

## Connections

- 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
