How prajjwal2051/builditup works
1. Overall shape
- This is a Next.js 16 App Router monorepo-style app with two main runtime surfaces: the web app at the repo root and a separate CollabServer Node service for realtime collaboration. The browser app owns routing, UI, server actions, and most API routes; the collaboration server handles OT-style sync and presence.
2. Primary user-facing areas
- The app is split into clear route groups: public landing (app/(root)), auth (app/(auth)), dashboard (app/dashboard), playground IDE (app/playground/[id]), and public share pages (app/s/[token]). This separation is important for diagramming because the IDE path is the core product surface, while dashboard and share pages are supporting flows.
3. Core IDE runtime
- The playground page composes the browser IDE: Monaco editor, file explorer, tabs/split view, terminal, preview pane, and AI sidebar. The runtime is browser-first: code is edited in the client, then synced into a WebContainer so users can preview and run commands without a traditional backend dev server.
4. WebContainer boundary
- modules/webContainers encapsulates booting and managing the in-browser runtime, while modules/playground owns the editor/file model and sync logic. The important flow is: file edits in the UI → debounced write into WebContainer → live preview/terminal reflect the change. This is a key boundary because preview execution does not happen on the Next.js server.
5. Playground state and file model
- The playground uses feature-scoped hooks and client state for file-tree operations, open tabs, selection, dirty state, and AI toggles. File hierarchy is stored as a structured JSON tree and converted through modules/playground/lib/path-to-json.ts. That JSON tree is persisted per playground, making the file system a first-class data model rather than an ephemeral editor state.
6. Persistence layer
- Persistence is centered on Prisma + MongoDB via lib/db.ts and prisma/schema.prisma. The main entities are User, Account, Playground, TemplateFile, and StarMark. In architecture terms: users and OAuth accounts handle identity, playgrounds represent projects, template files store the project’s file tree, and star marks model bookmarks/favorites.
7. Authentication and session flow
- Auth is handled with NextAuth v5 (auth.ts, auth.config.ts) using OAuth providers and a JWT session strategy. The sign-in flow creates or links User and Account records, then exposes user identity/role data to the client. This means the system avoids a DB session table and relies on token-backed session propagation.
8. Sharing and public access
- Shared playgrounds have their own API and page flow under app/api/share/* and app/s/[token]. The share subsystem supports create, metadata/content retrieval, save, and revoke actions, so it forms a distinct boundary between private playground state and public/token-based access. The share token logic is centralized in lib/share-token.ts.
9. Realtime collaboration
- Collaboration is split from the main app into CollabServer/, which contains OT engine, sessions, presence, persistence, and a connection manager. The Next.js app exposes collab-related status/stop endpoints and client hooks for websocket and presence behavior. For an architecture diagram, treat this as a separate realtime service that synchronizes concurrent editing and online user state.
10. AI subsystem
- AI is integrated through dedicated API routes (app/api/ai-chat, app/api/ai-test, app/api/code-completion) and client hooks/components in modules/playground. There are two main AI paths: inline code completion inside Monaco and a chat sidebar for context-aware assistance. AI behavior is also configurable per session, so it acts as an optional augmentation to the IDE rather than a hard dependency.
11. Dashboard and project orchestration
- The dashboard is the project-management layer: it creates playgrounds, lists them, supports search, and allows starring. The dashboard modules are the main bridge between authenticated user identity and stored playground records. This is where users choose a template and enter the IDE flow.
12. Starter templates and generated project seeds
- OrbitCode-starters/ contains framework-specific starter trees for React, Next.js, Express, Vue, Hono, and Angular. These are not just docs; they are the seed content that becomes the initial playground filesystem. In a diagram, this is the “project template source” feeding the persisted playground file tree.
13. Shared UI and front-end foundation
- The UI is built from Tailwind CSS, shadcn/ui, and Radix-based components in components/ui. Feature modules in modules/* keep domain logic separated from generic UI primitives. This modular layout matters because most product behavior lives in feature-scoped client/server code rather than in a single monolithic component tree.
14. Runtime and deployment constraints
- next.config.ts sets COOP/COEP headers, which are required for WebContainer support and browser SharedArrayBuffer usage. That means the app is architecturally constrained to a cross-origin isolated browser context. Environment configuration also reflects the stack: MongoDB, Auth secrets, OAuth provider keys, and optional Prisma Accelerate.
15. High-level data flow
- The main end-to-end flow is: OAuth sign-in → dashboard → playground creation from a starter template → file-tree persistence in MongoDB → browser editing and WebContainer sync → optional realtime collaboration via CollabServer → optional AI assistance → share/public link generation. That is the core system sequence an architecture diagram should emphasize.
Main entry points: lib/index.ts Playground module · db.ts Prisma DB · layout.tsx App shell · CollabServer/index.ts CollabServer
Components 22
Web App
Next.js App Router surfaces and UI composition
- App shell · Root layout and global app composition
app/layout.tsx - Landing · Public marketing home experience
app/page.tsx - Sign in · Authentication entry surface
app/(auth)/auth/sign-in/page.tsx - Dashboard · Project list, search, create, and star management
app/dashboard/page.tsx - Playground · Core browser IDE surface for a project
app/playground/[id]/page.tsx - Shared view · Token-based public playground access
app/s/[token]/page.tsx
API Layer
Server routes for auth, AI, playground, sharing, and collaboration control
- Auth API · OAuth and session handling endpoints
app/api/auth/[...nextauth]/route.ts - Playground API · Create, load, and update playground records
app/api/playground/[id]/route.ts - Share API · Create, fetch, save, and revoke public shares
app/api/share/create/route.tsx - AI API · Chat, test, and code completion endpoints
app/api/ai-chat/route.ts - Collab API · Collaboration status and stop control endpoints
app/api/collab/playground/[playgroundId]/status/route.ts
Feature Modules
Domain logic and client-side feature systems
- Dashboard module · Dashboard actions and components for project orchestration
modules/dashboard/actions/index.ts - Auth module · Auth actions and client session helpers
modules/auth/actions/index.ts - Playground module · Editor state, file model, dialogs, and collaboration UI
modules/playground/lib/index.ts
Runtime Layer
Browser execution and collaboration runtime boundaries
- WebContainer · In-browser project runtime and preview management
modules/webContainers/hooks/useWebContainer.ts
Data Layer
Persistence and schema-driven models
- Prisma DB · Database access layer for MongoDB-backed records
lib/db.ts - Schema · Users, accounts, playgrounds, templates, and stars
prisma/schema.prisma - Share token · Central token generation and validation logic
lib/share-token.ts
Collab Service
Separate realtime synchronization service
- CollabServer · Separate Node service for OT sync and presence
CollabServer/index.ts - OT engine · Operational transform logic and session handling
CollabServer/ot/engine.ts - Presence · Online-user and cursor/presence state handling
CollabServer/presence.ts
Starter Trees
Seed project files used to initialize playgrounds
- Starter trees · Framework-specific seed projects for new playgrounds
OrbitCode-starters/nextjs/app/page.tsx
Connections 27
- App shell → Landing: renders · App shell composes the public landing experience
- App shell → Sign in: routes · App shell supports the auth surface
- App shell → Dashboard: routes · Authenticated project dashboard surface
- App shell → Playground: routes · Primary IDE surface
- App shell → Shared view: routes · Public shared playground surface
- Sign in → Auth API: signs in via · Client auth flows use the NextAuth route
- Dashboard → Dashboard module: uses · Dashboard UI is driven by feature actions and components
- Dashboard module → Prisma DB: persists · Project orchestration reads and writes stored records
- Dashboard module → Starter trees: seeds from · New playgrounds begin from starter templates
- Playground → Playground module: composes · IDE page is built from playground feature modules
- Playground module → WebContainer: syncs to · File edits are written into the browser runtime
- Playground module → AI API: calls · Chat and completion features use AI endpoints
- Playground module → Share API: shares via · Share link creation and management flow through API routes
- Playground module → Collab API: collab control · Client collaboration state connects to collaboration control APIs
- Playground module → Prisma DB: loads/saves · Playground state and file tree are persisted
- Playground module → Share token: tags with · Shared playground access is token-based
- Playground API → Prisma DB: reads/writes · Playground API is backed by Prisma persistence
- Share API → Share token: issues · Share endpoints rely on central token logic
- Share API → Prisma DB: reads/writes · Share metadata and content are persisted
- AI API → Prisma DB: config/state · AI behavior can be session- or project-aware
- Collab API → CollabServer: controls · Next.js exposes status and stop controls for the separate service
- CollabServer → OT engine: runs · Server hosts OT synchronization engine
- CollabServer → Presence: tracks · Server maintains presence state
- CollabServer → Prisma DB: optional persistence · Collaboration state can be stored or restored
- WebContainer → Playground module: receives edits from · Browser runtime is driven by playground file changes
- Starter trees → Prisma DB: becomes · Starter trees are turned into persisted playground file trees
- Schema → Prisma DB: defines · Prisma schema shapes the persistence layer