| title | Architecture |
|---|---|
| description | Deep dive into ObjectDocs architecture, directory structure, and data flow. |
import { Layers, FileJson, Code, FileText } from 'lucide-react';
ObjectDocs is built on a strict Separation of Concerns philosophy, completely separating the presentation, configuration, and content layers.
Unlike traditional documentation sites where structure is hardcoded in React components, ObjectDocs treats documentation organization as data.
} title="Metadata-Driven"> Navigation, sidebar, and page order are all defined by JSON files, not React code. } title="Logic Agnostic"> Content creators don't need to care about routing logic or UI component implementation details.Each documentation directory is self-contained. If you want to add a new section, just create files in that directory and update the sibling meta.json. This makes multi-person collaboration in large teams less prone to conflicts.
A standard ObjectDocs project structure after initialization:
.
├── content/ # [Data Layer] All documentation files
│ ├── package.json # Scripts: dev, build, start (created by init)
│ ├── .objectdocs/ # Site engine (copied from @objectdocs/site, gitignored)
│ │ ├── node_modules/ # Dependencies (installed during init)
│ │ ├── .next/ # Next.js build cache (development)
│ │ └── out/ # Static build output (production)
│ ├── docs.site.json # Global config (Nav, Logo, Branding, i18n)
│ ├── public/ # Static assets (copied to site during build/dev)
│ └── docs/
│ ├── meta.json # Directory structure & page order
│ └── index.mdx # Documentation content
├── out/ # Final build output (copied from content/.objectdocs/out)
├── .gitignore # Auto-updated to exclude content/.objectdocs
├── package.json # (Optional) Root project package.json
└── ...
Key Components:
content/.objectdocs/: Contains the complete Next.js site engine from@objectdocs/sitepackagecontent/package.json: Created by init command with dev/build/start scripts- Build Flow:
content/.objectdocs/out→out/(root directory) - Environment: Commands run inside
content/.objectdocswithDOCS_DIRenv variable pointing to docs
- Init Command:
npx @objectdocs/cli init - Package Copy: Entire
@objectdocs/sitepackage →content/.objectdocs - Script Creation:
content/package.jsonwith dev/build/start scripts - Dependency Install:
npm installincontent/.objectdocs - Gitignore Update: Add exclusions for generated files
- Start: Run
cd content && npm run dev - Config Sync: Copy
docs.site.jsonandpublic/tocontent/.objectdocs - Environment: Set
DOCS_DIRenv variable to point tocontent/docs - Watch: Monitor
docs.site.jsonfor changes and auto-restart - Server: Next.js dev server runs on port 7777 (default)
- Build Time: Run
cd content && npm run build - Config Sync: Copy
docs.site.jsonandpublic/tocontent/.objectdocs - Environment: Set
DOCS_DIRenv variable - MDX Parsing: Fumadocs reads all
.mdxfiles fromDOCS_DIR - Metadata: Parse
meta.jsonfiles to build navigation tree - Rendering: Next.js App Router renders as React Server Components
- Output:
- Static mode:
content/.objectdocs/out→out/(root) - Dynamic mode:
content/.objectdocs/.next→.next/(root)
- Static mode:
- Serve: Production build served from
out/directory - Assets: Static HTML, CSS, JS, and images
- CDN: Can be deployed to Vercel, Netlify, or any static host
- Start: Run
cd content && npm run start - Server: Next.js production server with ISR/SSR capabilities
- Interaction: Client components (like
<Cards>,<Steps>) hydrate in browser
This architecture allows us to:
- Clean Separation: Keep the documentation content completely separate from the site engine
- Project Agnostic: Add docs to any existing project without polluting the root directory
- Version Control: The entire site engine is gitignored, only content is tracked
- Multi-Product Support: By switching different
contentdirectories, multiple product documentations can be supported - Low-Code Integration: Since content is separated from UI, we can more easily inject dynamic low-code component demos
- Easy Updates: Update the site engine by re-running init or updating the CLI version