update
This commit is contained in:
@@ -1,295 +1,402 @@
|
||||
# SDD + GitOps Documentation Framework
|
||||
|
||||
## Overview
|
||||
|
||||
The **SDD (Software Design Documentation) + GitOps Documentation Framework** is a comprehensive, structured approach to software development documentation that aligns technical work with business outcomes through clear separation of concerns.
|
||||
|
||||
This framework ensures that every piece of documentation serves a specific purpose, reaches the right audience, and is measurable through clear KPIs and SLOs.
|
||||
This document defines the documentation framework for the NATSBridge project. It establishes a structured approach to creating, maintaining, and evolving technical documentation in alignment with GitOps principles—ensuring that documentation is versioned, auditable, and continuously validated alongside the codebase.
|
||||
|
||||
---
|
||||
|
||||
## The Documentation Matrix
|
||||
## The SDD Framework: Seven Pillars of Documentation
|
||||
|
||||
| Document | Purpose & Rationale (The "Why") | Audience | Format / Content | Measurement (KPI/SLO) | Example (SaaS Context) |
|
||||
|----------|---------------------------------|----------|------------------|----------------------|------------------------|
|
||||
| **Requirements** | The Business North Star. Defines exactly what problem the user has and what success looks like. It prevents "feature creep" by setting hard boundaries on what we will NOT build. | Founder, Team, PM | Format: Shared Wiki (Notion/GitHub Wiki). Content: User stories, business constraints, competitive context, and success metrics. | KPI: Business Outcomes. Measured by User Retention, Conversion Rates, and Monthly Recurring Revenue (MRR). | "The system must process high-volume math so clients see reports instantly. Goal: 15% increase in daily active users." |
|
||||
| **Spec** | The Technical Contract. A machine-readable, strictly typed definition of all data interfaces. It is the "Single Source of Truth" that prevents bugs caused by communication gaps between services. | Developers, QA, Automation | Format: OpenAPI/YAML or Protobuf. Content: API endpoints, snake_case key naming, data validation rules, and error response codes. | SLA/SLO: System Performance. Measured by API Uptime (99.9%), Response Latency (<100ms), and Error Rates. | A `contract.yaml` defining exactly how Julia sends Arrow data to Node.js. It forces `user_id` to be a UUID. |
|
||||
| **Architecture** | The Structural Blueprint. A visual map of how the components (services, DBs, networks) fit together. It shows how the data flows through the 6-node cluster and where bottlenecks live. | Senior Devs, DevOps | Format: Diagrams-as-code (Mermaid.js). Content: System Context diagrams, Database ERDs, Network Security Policies, and Infrastructure maps. | Efficiency Metrics: Resource utilization. Measured by CPU Load (<70%), RAM per pod, and internal network throughput. | A diagram showing the data path: Caddy (Proxy) → Node.js (API) → NATS (Queue) → Julia (Math Engine). |
|
||||
| **Walkthrough** | The Intuition & Logic. A narrative guide that explains the "steps" and "rationale" behind end-to-end flows. It's about building a mental model so devs understand why the sequence matters. | The Team, New Hires | Format: TOUR.md file or Loom Video. Content: Step-by-step traces of core features, explanation of architectural trade-offs, and "The Big Picture" flow. | Quality: Developer Velocity. Measured by "Time-to-First-Commit" for new hires and reduction in conceptual bugs. | "End-to-End Trace:" 1. UI sends JSON. 2. API wraps it in Claim-Check. 3. Julia pulls it. Rationale: To avoid NATS memory spikes. |
|
||||
| **Implementation** | The Functional Reality. The actual code that does the work. In SDD, the "boring" parts (types/routes) are auto-generated from the Spec to ensure the code never lies. | Developers, Reviewers | Format: Git Repository. Content: Business logic, internal helper functions, Unit Tests, and a README.md for local environment setup. | Code Health: Internal Quality. Measured by Test Coverage (90%+), Linting compliance, and Cyclomatic Complexity. | The SvelteKit frontend components and the specific Julia math-processing functions. |
|
||||
| **Validation** | The Enforcement Layer. Automated gates that prove the Implementation matches the Spec. It prevents human error (like changing a key name) from reaching production. | CI/CD Pipeline, QA | Format: GitHub Actions / Tests. Content: Contract tests (Dredd/Prism), Integration tests, and Security scans that run on every pull request. | Compliance: Safety Metrics. Measured by Build Success Rate and 0 "Contract Violations" in the production logs. | A CI job that blocks a Pull Request because a developer used camelCase in a database field instead of snake_case. |
|
||||
| **Maintenance** | The Health & Evolution. Defines how to upgrade dependencies, manage technical debt, and rotate secrets. It's the guide for "future-proofing" the software over time. | The Team, DevOps | Format: MAINTENANCE.md. Content: Dependency update schedules, Secret rotation steps, DB Migration logs, and Tech Debt "Graveyard" tracking. | Sustainability: System Longevity. Measured by "Package Age," "Security Vulnerabilities Found," and "Migration Success Rate." | "Steps to upgrade the Julia version across all 6 nodes without downtime using a Blue-Green deployment strategy." |
|
||||
| **Runbook** | The Operational Life-Support. The instructions for when the system is alive (or dying). In GitOps, this is the "Desired State" of the infrastructure. | DevOps, SRE, On-call Devs | Format: K8s Manifests (Flux/Argo). Content: Deployment steps, Scaling triggers, Backup/Restore procedures, and "3:00 AM" troubleshooting guides. | Reliability: Operational Health. Measured by MTTR (Mean Time to Recovery) and Error-Free Deployments. | A Flux manifest that ensures 6 replicas of the Julia service are always healthy and restarts them if they hit 80% RAM. |
|
||||
| Document | Purpose (Rationale) | Primary Audience | Format / Content | Example (SaaS Context) | Measurement (KPI) |
|
||||
|----------|---------------------|-----------------|------------------|------------------------|-------------------|
|
||||
| **Requirements** | Capture the **business intent** — why we're building this and what success looks like. Defines boundaries and user-visible outcomes. | Stakeholders, Product Owners, Lead Developers | User stories, PRDs, acceptance criteria, non-functional constraints. | "System must process tabular data from Julia to SvelteKit UI with <200ms latency for 5-member teams." | 95% of requests complete <200ms (synthetic monitoring). |
|
||||
| **Specification** | The **technical contract** — precise rules for inputs, outputs, and data shape. Ensures consistency across dev and test. | Developers, QA Engineers, CI/CD pipelines | OpenAPI, Protobuf, AsyncAPI. Endpoint definitions, schemas, error codes. | `contract.yaml` defining a NATS subject that accepts Arrow streams with snake_case headers. | 100% of messages validated against spec (CI block rate). |
|
||||
| **Architecture** | The **blueprint** — how components fit together, interact, and scale. Guides system structure and trade-offs. | Architects, Senior Developers, DevOps | C4 diagrams, Mermaid.js, component/network/storage models. | Diagram showing 6-node cluster routing traffic via Caddy → Node.js API → Julia pods. | 100% of major decisions logged with trade-off analysis. |
|
||||
| **Walkthrough** | The **story of flow** — shows how pieces connect end-to-end and why steps are sequenced. Builds intuition for new devs. | New Developers, Team Members | TOUR.md, Loom videos, sequence diagrams. Step-by-step traces with rationale. | "UI sends JSON → Node.js wraps Claim-Check → Julia pulls Arrow data (prevents NATS overflow)." | New developers ship feature in <2 days (PR timeline). |
|
||||
| **Implementation** | The **real code** — business logic, helpers, tests, configs. Where design becomes executable. | Developers, Code Reviewers | Source code, README.md, unit tests, setup scripts. | Julia function for matrix calculation + SvelteKit component rendering table. | >80% unit test coverage, <5% drift from spec. |
|
||||
| **Validation** | The **enforcer** — ensures implementation matches the spec. Blocks drift and human error. | Automation servers, QA, Lead Developers | CI jobs, contract tests, linting, integration checks. | CI job rejects PR with camelCase field not allowed by YAML spec. | <1% of PRs bypass validation gates. |
|
||||
| **Runbook** | The **operational manual** — how the system lives in production, scales, and recovers. Guides on-call engineers. | DevOps, SREs, On-call Developers | K8s manifests, Helm charts, Markdown guides. Deployment, scaling, backup/restore, troubleshooting. | GitOps manifest ensuring 6 Julia replicas restart if memory >80%. | MTTR <15 minutes for P1 incidents. |
|
||||
|
||||
---
|
||||
|
||||
## Detailed Breakdown of Each Document Type
|
||||
## Detailed Document Descriptions
|
||||
|
||||
### 1. Requirements
|
||||
|
||||
**Purpose**: Establish the Business North Star
|
||||
**Purpose**: Capture the *business intent* — why we're building this and what success looks like. Defines boundaries and user-visible outcomes.
|
||||
|
||||
The Requirements document is your anchor point. It answers the fundamental question: "What problem are we solving, and how do we know we've succeeded?"
|
||||
**Why It Matters**:
|
||||
- Aligns engineering efforts with business goals
|
||||
- Provides a north star for feature development
|
||||
- Establishes acceptance criteria before implementation begins
|
||||
- Creates a contract between product and engineering
|
||||
|
||||
**Key Characteristics**:
|
||||
- **Business-Focused**: Written in business terms, not technical jargon
|
||||
- **Boundary-Setting**: Explicitly defines what we will NOT build
|
||||
- **Outcome-Oriented**: Focuses on user outcomes, not features
|
||||
**Content Guidelines**:
|
||||
- User stories with clear acceptance criteria (As a X, I want Y so that Z)
|
||||
- Product Requirements Documents (PRDs) with success metrics
|
||||
- Non-functional requirements (performance, security, scalability)
|
||||
- Boundary definitions (what's in scope vs. out of scope)
|
||||
|
||||
**Best Practices**:
|
||||
- Include user stories that describe the user's perspective
|
||||
- Document business constraints (regulatory, legal, compliance)
|
||||
- Define competitive context and market positioning
|
||||
- Establish clear success metrics from day one
|
||||
|
||||
**Common Pitfalls to Avoid**:
|
||||
- Vague descriptions like "improve user experience"
|
||||
- Changing requirements without updating the document
|
||||
- Not defining what's out of scope
|
||||
- Link each requirement to a measurable KPI
|
||||
- Keep requirements testable and verifiable
|
||||
- Maintain backward compatibility with existing requirements
|
||||
- Review and update requirements as business context changes
|
||||
|
||||
---
|
||||
|
||||
### 2. Spec (Specification)
|
||||
### 2. Specification
|
||||
|
||||
**Purpose**: Create the Technical Contract
|
||||
**Purpose**: The *technical contract* — precise rules for inputs, outputs, and data shape. Ensures consistency across dev and test.
|
||||
|
||||
The Spec serves as the Single Source of Truth for all data interfaces. It's a machine-readable definition that ensures consistency across services.
|
||||
**Why It Matters**:
|
||||
- Prevents implementation drift between components
|
||||
- Enables contract testing in CI/CD pipelines
|
||||
- Provides a single source of truth for data structures
|
||||
- Facilitates integration between teams
|
||||
|
||||
**Key Characteristics**:
|
||||
- **Machine-Readable**: Can be parsed by tools for validation and code generation
|
||||
- **Strictly Typed**: Enforces data types and validation rules
|
||||
- **Comprehensive**: Covers all endpoints, request/response formats, and error codes
|
||||
**Content Guidelines**:
|
||||
- API endpoint definitions (methods, paths, parameters)
|
||||
- Request/response schemas (JSON, XML, Protobuf, AsyncAPI)
|
||||
- Error codes and their meanings
|
||||
- Data validation rules and constraints
|
||||
- Rate limiting and quota definitions
|
||||
|
||||
**Best Practices**:
|
||||
- Use OpenAPI/Swagger for REST APIs or Protobuf for gRPC
|
||||
- Enforce consistent naming conventions (e.g., snake_case)
|
||||
- Define validation rules for all data fields
|
||||
- Document all possible error responses
|
||||
|
||||
**Common Pitfalls to Avoid**:
|
||||
- Letting the spec diverge from the implementation
|
||||
- Incomplete error handling documentation
|
||||
- Not versioning the API spec
|
||||
- Use formal specification languages (OpenAPI 3.0+, AsyncAPI)
|
||||
- Version specifications alongside code
|
||||
- Generate client SDKs from specifications
|
||||
- Block CI on specification violations
|
||||
- Document edge cases and error scenarios
|
||||
|
||||
---
|
||||
|
||||
### 3. Architecture
|
||||
|
||||
**Purpose**: Visualize the System Structure
|
||||
**Purpose**: The *blueprint* — how components fit together, interact, and scale. Guides system structure and trade-offs.
|
||||
|
||||
The Architecture document provides a visual map of how components fit together. It helps identify bottlenecks and understand data flow.
|
||||
**Why It Matters**:
|
||||
- Provides a mental model for system design
|
||||
- Guides technical decision-making and trade-off analysis
|
||||
- Facilitates onboarding of new architects and senior developers
|
||||
- Documents scaling and performance considerations
|
||||
|
||||
**Key Characteristics**:
|
||||
- **Visual**: Uses diagrams to represent complex relationships
|
||||
- **Comprehensive**: Covers system context, data flow, and infrastructure
|
||||
- **Living Document**: Updated as the system evolves
|
||||
**Content Guidelines**:
|
||||
- C4 diagrams (Context, Container, Component levels)
|
||||
- Mermaid.js flowcharts for sequence diagrams
|
||||
- Component interaction diagrams
|
||||
- Network topology and data flow
|
||||
- Storage and caching strategies
|
||||
- Scaling and resilience patterns
|
||||
|
||||
**Best Practices**:
|
||||
- Use Mermaid.js for diagrams-as-code (versionable in Git)
|
||||
- Include multiple views: System Context, C4 model, ERDs, network topology
|
||||
- Document trade-offs and architectural decisions
|
||||
- Show data flow through the system
|
||||
|
||||
**Common Pitfalls to Avoid**:
|
||||
- Over-engineering diagrams with unnecessary detail
|
||||
- Not updating diagrams when the architecture changes
|
||||
- Using static images instead of diagrams-as-code
|
||||
- Use diagrams that are easy to update (Mermaid.js over static images)
|
||||
- Document trade-off decisions with Rationale Documents
|
||||
- Include scaling considerations for each component
|
||||
- Document failure modes and recovery strategies
|
||||
- Keep architecture diagrams versioned with code
|
||||
|
||||
---
|
||||
|
||||
### 4. Walkthrough
|
||||
|
||||
**Purpose**: Build Mental Models
|
||||
**Purpose**: The *story of flow* — shows how pieces connect end-to-end and why steps are sequenced. Builds intuition for new devs.
|
||||
|
||||
The Walkthrough document explains the "why" behind the "how." It helps developers understand the rationale behind design decisions.
|
||||
**Why It Matters**:
|
||||
- Reduces onboarding time for new developers
|
||||
- Provides context that code comments alone cannot convey
|
||||
- Explains the "why" behind architectural decisions
|
||||
- Helps identify gaps in the system design
|
||||
|
||||
**Key Characteristics**:
|
||||
- **Narrative-Driven**: Tells a story about how the system works
|
||||
- **Context-Rich**: Explains trade-offs and decisions
|
||||
- **End-to-End**: Traces flows from user input to system output
|
||||
**Content Guidelines**:
|
||||
- Step-by-step flow descriptions with rationale
|
||||
- Sequence diagrams showing request/response patterns
|
||||
- "Tour of the codebase" guides
|
||||
- Video walkthroughs (Loom, internal recordings)
|
||||
- Debugging and tracing examples
|
||||
|
||||
**Best Practices**:
|
||||
- Document step-by-step traces of core features
|
||||
- Explain architectural trade-offs and why you chose them
|
||||
- Include "The Big Picture" context
|
||||
- Use real examples and data flows
|
||||
|
||||
**Common Pitfalls to Avoid**:
|
||||
- Only documenting the happy path
|
||||
- Assuming developers will figure out the "why"
|
||||
- Not explaining the rationale behind decisions
|
||||
- Walk through real user journeys, not just technical flows
|
||||
- Include "what could go wrong" scenarios
|
||||
- Link walkthroughs to relevant code locations
|
||||
- Keep walkthroughs updated with architecture changes
|
||||
- Make walkthroughs interactive where possible
|
||||
|
||||
---
|
||||
|
||||
### 5. Implementation
|
||||
|
||||
**Purpose**: The Functional Reality
|
||||
**Purpose**: The *real code* — business logic, helpers, tests, configs. Where design becomes executable.
|
||||
|
||||
The Implementation is the actual code that does the work. In SDD, the "boring" parts are auto-generated from the Spec to ensure consistency.
|
||||
**Why It Matters**:
|
||||
- This is the actual artifact that runs in production
|
||||
- Code is the ultimate source of truth (when it matches spec)
|
||||
- Tests validate correctness and prevent regressions
|
||||
- Configuration files define runtime behavior
|
||||
|
||||
**Key Characteristics**:
|
||||
- **Machine-Generated**: Types and routes auto-generated from Spec
|
||||
- **Human-Written**: Business logic and helper functions
|
||||
- **Tested**: Includes unit and integration tests
|
||||
**Content Guidelines**:
|
||||
- Business logic implementation
|
||||
- Helper functions and utilities
|
||||
- Unit and integration tests
|
||||
- Configuration files (YAML, JSON, environment)
|
||||
- Setup and development scripts
|
||||
- Code organization and module structure
|
||||
|
||||
**Best Practices**:
|
||||
- Auto-generate boring parts (types, routes) from the Spec
|
||||
- Keep business logic separate from boilerplate
|
||||
- Maintain comprehensive test coverage
|
||||
- Document the local development setup
|
||||
|
||||
**Common Pitfalls to Avoid**:
|
||||
- Hand-writing types that should be auto-generated
|
||||
- Inconsistent code style
|
||||
- Insufficient test coverage
|
||||
- Follow consistent code style and conventions
|
||||
- Write tests before or alongside implementation (TDD/BDD)
|
||||
- Document complex logic with inline comments
|
||||
- Keep configuration externalized and versioned
|
||||
- Use type annotations where applicable
|
||||
|
||||
---
|
||||
|
||||
### 6. Validation
|
||||
|
||||
**Purpose**: Enforce the Contract
|
||||
**Purpose**: The *enforcer* — ensures implementation matches the spec. Blocks drift and human error.
|
||||
|
||||
The Validation layer provides automated gates that ensure the Implementation matches the Spec. It prevents human error from reaching production.
|
||||
**Why It Matters**:
|
||||
- Prevents breaking changes from reaching production
|
||||
- Catches specification violations early in the CI pipeline
|
||||
- Maintains data integrity and API consistency
|
||||
- Reduces manual QA effort through automation
|
||||
|
||||
**Key Characteristics**:
|
||||
- **Automated**: Runs on every commit/Pull Request
|
||||
- **Comprehensive**: Covers contract tests, integration tests, and security scans
|
||||
- **Blocking**: Prevents merges that violate the contract
|
||||
**Content Guidelines**:
|
||||
- CI/CD pipeline configurations
|
||||
- Contract testing scripts
|
||||
- Linting rules and configurations
|
||||
- Integration test suites
|
||||
- Schema validation jobs
|
||||
- Security scanning and audit jobs
|
||||
|
||||
**Best Practices**:
|
||||
- Use contract testing tools (Dredd, Prism) to validate API contracts
|
||||
- Run integration tests on every commit
|
||||
- Include security scans in the CI pipeline
|
||||
- Fail builds on contract violations
|
||||
|
||||
**Common Pitfalls to Avoid**:
|
||||
- Not running tests on every commit
|
||||
- Allowing manual overrides of validation gates
|
||||
- Not updating tests when the Spec changes
|
||||
- Fail CI on specification violations
|
||||
- Run validation jobs on every commit and PR
|
||||
- Use automated code review tools
|
||||
- Maintain validation job health dashboard
|
||||
- Document validation failure remediation steps
|
||||
|
||||
---
|
||||
|
||||
### 7. Maintenance
|
||||
### 7. Runbook
|
||||
|
||||
**Purpose**: Ensure Long-Term Health
|
||||
**Purpose**: The *operational manual* — how the system lives in production, scales, and recovers. Guides on-call engineers.
|
||||
|
||||
The Maintenance document defines how to upgrade dependencies, manage technical debt, and rotate secrets. It's the guide for "future-proofing" the software.
|
||||
**Why It Matters**:
|
||||
- Reduces Mean Time To Recovery (MTTR) for incidents
|
||||
- Provides step-by-step guidance for common issues
|
||||
- Documents scaling and deployment procedures
|
||||
- Ensures operational knowledge is not siloed
|
||||
|
||||
**Key Characteristics**:
|
||||
- **Procedural**: Step-by-step instructions for common tasks
|
||||
- **Scheduled**: Includes regular maintenance windows
|
||||
- **Documented**: Tracks technical debt and migration history
|
||||
**Content Guidelines**:
|
||||
- Deployment procedures (manual and automated)
|
||||
- Scaling instructions (horizontal/vertical)
|
||||
- Backup and restore procedures
|
||||
- Troubleshooting guides for common issues
|
||||
- Runbook entries for specific error codes
|
||||
- Contact information and escalation paths
|
||||
|
||||
**Best Practices**:
|
||||
- Document dependency update schedules
|
||||
- Create secret rotation procedures
|
||||
- Track technical debt in a "Graveyard"
|
||||
- Document migration history and rollback procedures
|
||||
|
||||
**Common Pitfalls to Avoid**:
|
||||
- Ad-hoc upgrades without documentation
|
||||
- Ignoring technical debt until it becomes critical
|
||||
- Not testing upgrades in staging first
|
||||
|
||||
---
|
||||
|
||||
### 8. Runbook
|
||||
|
||||
**Purpose**: Operational Life-Support
|
||||
|
||||
The Runbook provides instructions for when the system is alive (or dying). In GitOps, this is the "Desired State" of the infrastructure.
|
||||
|
||||
**Key Characteristics**:
|
||||
- **Action-Oriented**: Step-by-step instructions for common operations
|
||||
- **Automated**: Infrastructure as code defines the desired state
|
||||
- **Crisis-Ready**: Includes "3:00 AM" troubleshooting guides
|
||||
|
||||
**Best Practices**:
|
||||
- Document deployment procedures
|
||||
- Define scaling triggers and procedures
|
||||
- Include backup and restore procedures
|
||||
- Create troubleshooting guides for common issues
|
||||
|
||||
**Common Pitfalls to Avoid**:
|
||||
- Not documenting procedures for common issues
|
||||
- Not testing runbook procedures
|
||||
- Not versioning runbooks with the infrastructure
|
||||
- Write runbooks for every P1/P2 incident
|
||||
- Include exact commands and configuration snippets
|
||||
- Test runbooks periodically (chaos engineering)
|
||||
- Link runbook entries to relevant documentation
|
||||
- Keep runbooks updated when system changes
|
||||
|
||||
---
|
||||
|
||||
## How to Use This Approach Effectively
|
||||
|
||||
### Phase 1: Foundation (Week 1-2)
|
||||
### 1. Start with Requirements
|
||||
|
||||
1. **Create Requirements Document**
|
||||
- Define the Business North Star
|
||||
- Establish success metrics
|
||||
- Define out-of-scope items
|
||||
Before writing any code or documentation, establish clear requirements. Ask:
|
||||
- What business problem are we solving?
|
||||
- How will we measure success?
|
||||
- What are the non-negotiable constraints?
|
||||
|
||||
2. **Write the Spec**
|
||||
- Define all data interfaces
|
||||
- Establish naming conventions
|
||||
- Document validation rules
|
||||
**Action**: Create a `docs/requirements/` directory and start with `PRD.md` and `KPIs.md`.
|
||||
|
||||
3. **Design Architecture**
|
||||
- Create system diagrams
|
||||
- Document data flow
|
||||
- Identify potential bottlenecks
|
||||
### 2. Define the Specification First
|
||||
|
||||
### Phase 2: Development (Week 3+)
|
||||
Once requirements are stable, define the technical specification. This becomes the contract for implementation.
|
||||
|
||||
4. **Write Walkthrough**
|
||||
- Document end-to-end flows
|
||||
- Explain architectural trade-offs
|
||||
- Create mental models for developers
|
||||
**Action**: Create `docs/specification/` with `contract.yaml` (or appropriate format) and `error-codes.md`.
|
||||
|
||||
5. **Implement Code**
|
||||
- Auto-generate boring parts from Spec
|
||||
- Write business logic
|
||||
- Implement tests
|
||||
### 3. Design the Architecture
|
||||
|
||||
### Phase 3: Quality Assurance
|
||||
With requirements and specification in place, design the architecture. Document trade-off decisions explicitly.
|
||||
|
||||
6. **Set Up Validation**
|
||||
- Configure CI/CD pipeline
|
||||
- Set up contract testing
|
||||
- Configure security scans
|
||||
**Action**: Create `docs/architecture/` with Mermaid diagrams and `trade-offs.md`.
|
||||
|
||||
7. **Create Runbook**
|
||||
- Document deployment procedures
|
||||
- Define scaling triggers
|
||||
- Create troubleshooting guides
|
||||
### 4. Create Walkthroughs Early
|
||||
|
||||
### Phase 4: Maintenance
|
||||
As soon as the architecture is defined, create walkthroughs. This helps identify gaps and provides onboarding material.
|
||||
|
||||
8. **Document Maintenance**
|
||||
- Create dependency update schedule
|
||||
- Document secret rotation
|
||||
- Track technical debt
|
||||
**Action**: Create `docs/walkthrough/` with `TOUR.md` and sequence diagrams.
|
||||
|
||||
### 5. Implement with Validation in Mind
|
||||
|
||||
Write implementation code that adheres to the specification. Build validation into the CI pipeline from day one.
|
||||
|
||||
**Action**: Ensure test files are co-located with implementation and run on every commit.
|
||||
|
||||
### 6. Automate Validation
|
||||
|
||||
Build automated validation that runs in CI/CD. This ensures spec compliance and prevents drift.
|
||||
|
||||
**Action**: Configure CI jobs to validate against specification and block PRs on violations.
|
||||
|
||||
### 7. Document Operations from Day One
|
||||
|
||||
Create runbook entries as soon as deployment procedures are established. Update them when incidents occur.
|
||||
|
||||
**Action**: Create `docs/runbook/` with entries for deployment, scaling, and common issues.
|
||||
|
||||
---
|
||||
|
||||
## Key Principles for Success
|
||||
## GitOps Integration
|
||||
|
||||
1. **Separation of Concerns**: Keep business concerns separate from technical concerns
|
||||
2. **Machine-Readable Contracts**: Use OpenAPI/Protobuf for specs to enable automation
|
||||
3. **Automation**: Automate boring parts and validation to reduce human error
|
||||
4. **Measurability**: Every document should have measurable outcomes
|
||||
5. **Version Control**: Keep all documentation in Git for history and collaboration
|
||||
6. **Living Documents**: Update documentation as the system evolves
|
||||
7. **Audience-Focused**: Write for the intended audience's needs and knowledge level
|
||||
This documentation framework aligns with GitOps principles:
|
||||
|
||||
| GitOps Principle | Documentation Alignment |
|
||||
|-----------------|------------------------|
|
||||
| **Versioned** | All documentation lives in git, with history and audit trail |
|
||||
| ** declarative** | Specifications and architecture are declarative contracts |
|
||||
| **Automated** | Validation jobs automate spec compliance checks |
|
||||
| **Self-Service** | Walkthroughs and runbooks enable self-service onboarding and operations |
|
||||
| **Observability** | KPIs and metrics are defined for each documentation artifact |
|
||||
|
||||
**Git Structure**:
|
||||
```
|
||||
docs/
|
||||
├── requirements/ # PRDs, user stories, KPIs
|
||||
├── specification/ # OpenAPI, Protobuf, AsyncAPI specs
|
||||
├── architecture/ # C4 diagrams, Mermaid, trade-off docs
|
||||
├── walkthrough/ # TOUR.md, sequence diagrams
|
||||
├── implementation/ # Source code (in src/)
|
||||
├── validation/ # CI configs, test suites
|
||||
└── runbook/ # Deployment, scaling, troubleshooting
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Metrics and Continuous Improvement
|
||||
|
||||
Each documentation artifact has associated KPIs. Track these to ensure quality:
|
||||
|
||||
| Document | KPI | Target |
|
||||
|----------|-----|--------|
|
||||
| Requirements | Requirement coverage | 100% of features have associated requirements |
|
||||
| Specification | Spec compliance rate | 100% of messages validate against spec |
|
||||
| Architecture | Decision documentation | 100% of major decisions logged with trade-offs |
|
||||
| Walkthrough | New dev time-to-first-PR | <2 days from onboarding to first contribution |
|
||||
| Implementation | Test coverage | >80% unit test coverage |
|
||||
| Validation | Bypass rate | <1% of PRs bypass validation gates |
|
||||
| Runbook | MTTR | <15 minutes for P1 incidents |
|
||||
|
||||
**Review Cadence**:
|
||||
- Weekly: Review KPI dashboards and documentation gaps
|
||||
- Monthly: Update documentation based on incident learnings
|
||||
- Quarterly: Full framework review and improvement
|
||||
|
||||
---
|
||||
|
||||
## Template Examples
|
||||
|
||||
### Requirements Template
|
||||
```markdown
|
||||
# PRD: Feature Name
|
||||
|
||||
## Business Goal
|
||||
[What problem are we solving?]
|
||||
|
||||
## Success Metrics
|
||||
- [Metric 1]: Target [value]
|
||||
- [Metric 2]: Target [value]
|
||||
|
||||
## User Stories
|
||||
- As a [role], I want [feature] so that [benefit]
|
||||
- Acceptance Criteria: [details]
|
||||
|
||||
## Non-Functional Requirements
|
||||
- Performance: [details]
|
||||
- Security: [details]
|
||||
- Scalability: [details]
|
||||
|
||||
## Out of Scope
|
||||
- [What's explicitly excluded]
|
||||
```
|
||||
|
||||
### Specification Template
|
||||
```yaml
|
||||
# contract.yaml
|
||||
openapi: 3.0.0
|
||||
info:
|
||||
title: NATSBridge API
|
||||
version: 1.0.0
|
||||
paths:
|
||||
/api/v1/endpoint:
|
||||
post:
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Request'
|
||||
responses:
|
||||
'200':
|
||||
description: Success
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
$ref: '#/components/schemas/Response'
|
||||
```
|
||||
|
||||
### Architecture Template
|
||||
```mermaid
|
||||
%%{init: {'theme': 'base', 'themeVariables': {'primaryColor': '#3b82f6'}}}%%
|
||||
flowchart TD
|
||||
A[Client] --> B[Caddy]
|
||||
B --> C[Node.js API]
|
||||
C --> D[Julia Worker]
|
||||
D --> E[NATS Cluster]
|
||||
E --> F[Storage]
|
||||
|
||||
style A fill:#f9f9f9,stroke:#333
|
||||
style E fill:#e0e7ff,stroke:#3b82f6
|
||||
```
|
||||
|
||||
### Runbook Template
|
||||
```markdown
|
||||
# Runbook: Service Restart
|
||||
|
||||
**Severity**: P2
|
||||
**Estimated Time**: 5 minutes
|
||||
|
||||
## Symptoms
|
||||
- Service is unresponsive
|
||||
- Health checks are failing
|
||||
|
||||
## Steps
|
||||
1. SSH to the host
|
||||
2. Run: `kubectl rollout restart deployment/natsbridge`
|
||||
3. Monitor: `kubectl get pods -l app=natsbridge -w`
|
||||
|
||||
## Rollback
|
||||
- Run: `kubectl rollout undo deployment/natsbridge`
|
||||
|
||||
## Post-Incident
|
||||
- [ ] Review logs for root cause
|
||||
- [ ] Update runbook if needed
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Conclusion
|
||||
|
||||
The SDD + GitOps Documentation Framework provides a comprehensive, structured approach to software development documentation. By following this framework, teams can ensure that:
|
||||
This SDD + GitOps Documentation Framework ensures that documentation is:
|
||||
- **Structured**: Seven distinct artifacts with clear purposes
|
||||
- **Automated**: Validation and CI/CD integration
|
||||
- **Versioned**: All documentation in git with history
|
||||
- **Measurable**: KPIs for quality and effectiveness
|
||||
- **Actionable**: Practical templates and examples
|
||||
|
||||
- Business goals are clearly defined and measurable
|
||||
- Technical contracts are machine-readable and enforced
|
||||
- System architecture is visualized and understood
|
||||
- Developers have clear mental models of the system
|
||||
- Code quality is maintained through automation
|
||||
- Operations are reliable and repeatable
|
||||
|
||||
This framework is not just about documentation—it's about creating a shared understanding across the entire team and ensuring that every decision is aligned with business goals.
|
||||
Use this framework as a living document—update it as your team's needs evolve.
|
||||
Reference in New Issue
Block a user