Last Updated: 2026-03-24 Status: Active — Enforced for all new docs
This guide defines the writing standards, structure rules, and visual quality expectations for all markdown documentation in docs/. Every new or updated doc must follow these rules to ensure consistency across the LogicSpike docs application.
1. File Organization
1.1 Folder Structure
Every doc must live in the correct category folder:
| Folder | What goes here |
|---|---|
docs/project/ |
Platform vision, roadmap, high-level strategy |
docs/architecture/ |
System design, schema specs, database strategy |
docs/auth/ |
Authentication, authorization, PBAC, team management |
docs/billing/ |
Payment system, pricing, Razorpay/Stripe |
docs/blog/ |
Blog engine features, editor, workflows |
docs/communication/ |
Email/SMS service, notification specs |
docs/content-engine/ |
Content scheduling, MCP server, social automation |
docs/media/ |
Media service, file storage, R2 integration |
docs/settings/ |
User settings, workspace settings, audit logs |
docs/guides/ |
Engineering standards, workflows, this doc |
docs/learning/ |
Tutorials, cheatsheets, concept explainers |
docs/archive/ |
Deprecated docs (never delete, always archive) |
1.2 File Naming
- Use kebab-case:
auth-login-flow.md, NOTauthLoginFlow.md - Use descriptive names:
razorpay-setup-guide.md, NOTsetup.md - Suffix with doc type when helpful:
*-vision.md,*-spec.md,*-journey.md,*-guide.md
2. Document Header (Required)
Every document must start with this structure:
# Document Title
> **Last Updated:** YYYY-MM-DD
> **Status:** Active | Draft | DeprecatedStatus Values
| Status | Meaning |
|---|---|
Active |
Source of truth, maintained |
Draft |
Work in progress, may change |
Deprecated |
Moved to docs/archive/, replaced by newer doc |
3. Content Structure
3.1 Heading Hierarchy
- H1 (
#): Document title — exactly ONE per file - H2 (
##): Major sections — numbered (## 1. Overview,## 2. Architecture) - H3 (
###): Subsections - H4 (
####): Detail items (API endpoints, config options)
IMPORTANT
Never skip heading levels. Don't jump from H2 to H4.
3.2 Required Sections by Doc Type
Vision Docs (*-vision.md):
- Purpose (The Why)
- Target Audience
- Core Features / Value Props
- Architecture Overview (with diagram)
- Implementation Phases
API Specs (*-spec.md):
- Service Owner
- Base URL
- Endpoints (grouped by domain)
- Error Codes table
- Auth requirements per endpoint
User Journeys (*-journey.md):
- Persona description
- Step-by-step flow (with sequence diagram)
- Edge cases / error paths
- Backend operations per step
Architecture Decision Records (adr-*.md):
- Context / Problem
- Options Considered (comparison table)
- Decision
- Consequences / Trade-offs
Guides (*-guide.md):
- Prerequisites
- Step-by-step instructions
- Code examples
- Verification / testing steps
4. Diagrams (Critical)
4.1 Always Use Mermaid
All architecture diagrams, flows, and sequences must use mermaid code blocks. Never use ASCII art for new diagrams.
```mermaid
flowchart TD
A["Node A"] --> B["Node B"]
```4.2 Mermaid Style Rules
Every mermaid diagram must include explicit style declarations for colorful, professional output:
Color Palette (use consistently across all docs):
| Role | Fill | Stroke | Use for |
|---|---|---|---|
| Gateway / Edge | #2563eb |
#60a5fa |
API Gateway, CDN, edge nodes |
| Manager / Identity | #7c3aed |
#a78bfa |
Auth, users, teams, billing |
| Blog / Content | #0891b2 |
#22d3ee |
Blog service, CMS |
| Media / Storage | #d97706 |
#fbbf24 |
Media service, R2, file storage |
| Communication | #059669 |
#34d399 |
Email, SMS, notifications |
| Content Engine | #db2777 |
#f472b6 |
Social automation, scheduling |
| Database | #0d9488 |
#2dd4bf |
Postgres, any DB |
| Redis / Cache | #dc2626 |
#f87171 |
Redis, caching layers |
| Object Storage | #ea580c |
#fb923c |
R2, S3, blob storage |
| Success / Allow | #16a34a |
#4ade80 |
Success states, approvals |
| Error / Deny | #dc2626 |
#f87171 |
Errors, rejections, failures |
| Neutral / Input | #475569 |
#94a3b8 |
User input, external actors |
Example — Properly styled flowchart:
```mermaid
flowchart TD
Client["🖥️ Client App"]
Gateway["🛡️ API Gateway"]
Service["⚙️ Backend Service"]
DB[("🐘 Database")]
Client --> Gateway --> Service --> DB
style Client fill:#475569,stroke:#94a3b8,stroke-width:2px,color:#fff
style Gateway fill:#2563eb,stroke:#60a5fa,stroke-width:2px,color:#fff
style Service fill:#7c3aed,stroke:#a78bfa,stroke-width:2px,color:#fff
style DB fill:#0d9488,stroke:#2dd4bf,stroke-width:2px,color:#fff
```4.3 Subgraph Styling
Subgraphs (grouped sections) use dark backgrounds:
style SubgraphName fill:#0f172a,stroke:#334155,stroke-width:2px,color:#e2e8f04.4 Sequence Diagrams
Use rect blocks with semi-transparent colors to group phases:
```mermaid
sequenceDiagram
rect rgba(59, 130, 246, 0.08)
Note over A,B: Phase 1 — Authentication
A->>B: Login request
end
rect rgba(139, 92, 246, 0.08)
Note over A,B: Phase 2 — Data Fetch
A->>B: GET /data
end
```4.5 Edge / Link Styling
Use linkStyle for colored connections:
linkStyle 0,1,2 stroke:#3b82f6,stroke-width:3px
linkStyle 3,4 stroke:#a78bfa,stroke-width:2px,stroke-dasharray:5- Solid thick (
stroke-width:3px): Direct service bindings - Dashed (
stroke-dasharray:5): Event-driven / async communication
5. Code Blocks
5.1 Always Specify Language
Every code block must have a language tag for syntax highlighting:
```json
{ "key": "value" }
```
```typescript
const x: string = "hello";
```
```sql
SELECT * FROM users WHERE tenant_id = 'tnt_123';
```Never use bare ``` without a language. Use plaintext if no language applies.
5.2 Keep Code Blocks Focused
- Max 20 lines per code block. Split longer examples.
- Show only the relevant part — don't dump entire files.
- Add comments for non-obvious lines.
6. Tables
Use tables for any comparison, listing, or structured data:
| Column A | Column B | Column C |
|:---|:---|:---|
| Value 1 | Value 2 | Value 3 |Rules:
- Always left-align (
:---) - Use header row with bold intent (column names should be self-explanatory)
- Prefer tables over bullet lists when data has 2+ attributes
7. Callout Blocks
Use GitHub-style callout syntax for important notes:
> [!NOTE]
> Helpful context or background information.
> [!IMPORTANT]
> Critical requirement that must be followed.
> [!WARNING]
> Potential pitfall or dangerous action.For status/metadata headers at the top of docs, use blockquotes:
> **Last Updated:** 2026-03-24
> **Status:** Active
> **Service:** `apps/manager`8. Cross-References
Link to other docs using relative markdown paths:
See [System Architecture](../architecture/system-architecture.md) for the full service map.Rules:
- Always use relative paths from the current file
- Link text should be the document title, not "click here"
- Reference specific sections with anchors when possible
9. Writing Style
- Be direct — Lead with the answer, not the context
- Use active voice — "The Gateway verifies the JWT" not "The JWT is verified by the Gateway"
- Define acronyms on first use — "PBAC (Permission-Based Access Control)"
- No filler — Cut "basically", "essentially", "in order to", "it should be noted that"
- Present tense — "The service returns a 200" not "The service will return a 200"
- Technical precision — Use exact names (
x-tenant-id, not "the tenant header")
10. Quality Checklist
Before merging any doc, verify:
- H1 title + metadata header (Last Updated, Status)
- Numbered H2 sections
- At least one mermaid diagram for architecture/flow docs
- All diagrams have explicit
styledeclarations with the standard color palette - All code blocks have language tags
- Tables used for structured data (not nested bullets)
- Cross-references use relative links
- No orphan docs — linked from at least one other doc
- File is in the correct category folder
- File uses kebab-case naming