Architecture
Deep dive into ObjectDocs architecture, directory structure, and data flow.
Architecture
ObjectDocs is built on a strict Separation of Concerns philosophy, completely separating the presentation, configuration, and content layers.
Core Principles
1. Configuration as Code
Unlike traditional documentation sites where structure is hardcoded in React components, ObjectDocs treats documentation organization as data.
Metadata-Driven
Navigation, sidebar, and page order are all defined by JSON files, not React code.
Logic Agnostic
Content creators don't need to care about routing logic or UI component implementation details.
2. Localized Content Management
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.
Directory Structure
A standard ObjectDocs project structure after initialization:
.
├── content/ # [Data Layer] All documentation files
│ ├── package.json # Scripts: dev, build, start (created by init)
│ ├── .fumadocs/ # 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/.fumadocs/out)
├── .gitignore # Auto-updated to exclude content/.fumadocs
├── package.json # (Optional) Root project package.json
└── ...Key Components:
content/.fumadocs/: Contains the complete Next.js site engine from@objectdocs/sitepackagecontent/package.json: Created by init command with dev/build/start scripts- Build Flow:
content/.fumadocs/out→out/(root directory) - Environment: Commands run inside
content/.fumadocswithDOCS_DIRenv variable pointing to docs
Data Flow
Initialization Flow
- Init Command:
npx @objectdocs/cli init - Package Copy: Entire
@objectdocs/sitepackage →content/.fumadocs - Script Creation:
content/package.jsonwith dev/build/start scripts - Dependency Install:
npm installincontent/.fumadocs - Gitignore Update: Add exclusions for generated files
Development Flow
- Start: Run
cd content && npm run dev - Config Sync: Copy
docs.site.jsonandpublic/tocontent/.fumadocs - 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 Flow
- Build Time: Run
cd content && npm run build - Config Sync: Copy
docs.site.jsonandpublic/tocontent/.fumadocs - 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/.fumadocs/out→out/(root) - Dynamic mode:
content/.fumadocs/.next→.next/(root)
- Static mode:
Runtime Flow (Static)
- 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
Runtime Flow (Dynamic)
- 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
Why Design It This Way?
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