The Spec-Driven SDLC in Practice: Mastering Phase 3, The Software Design Document (SDD)

The Spec-Driven SDLC in Practice: Mastering Phase 3, The Software Design Document (SDD)

Introduction

If the PRD was the client's brief and the SRS was the list of required rooms and functions, the Software Design Document (SDD) is the detailed architectural blueprint. It's the plan that shows the structural supports, the plumbing, and the electrical systems before a single brick is laid. This is the phase where we translate the "what" defined in our requirements into a concrete "how" for the engineering team.

This article is a hands-on tutorial for creating a comprehensive SDD in collaboration with an AI partner. We will take the approved SRS for our "Comments Feature" and design a robust, scalable, and well-documented technical solution. By the end of this guide, you will know how to structure a modern architectural document, craft an effective AI persona, and, most importantly, specify system behavior with the precision required for flawless AI code generation.

What is an SDD? The Blueprint for Implementation

The Software Design Document (SDD) is the primary technical specification that describes the system's high-level architecture and low-level design. It is the definitive guide for the development team, providing a complete plan for building and implementing the software specified in the SRS.

The Core Components (Using the C4 Model)

To avoid creating a monolithic, unreadable document, we will structure our SDD using the C4 model. This model provides four hierarchical levels of abstraction, allowing us to explain the architecture with increasing levels of detail.

  • Level 1: System Context: A high-level view showing how our system fits into the world.
  • Level 2: Containers: Decomposes the system into its major deployable units (e.g., a microservice, a database).
  • Level 3: Components: Decomposes a single container into its key logical modules.
  • Level 4: Component Behavior: Details the business logic of a specific component using formalisms like sequence diagrams or state machines. This level is essential for AI code generation.

The Critical Shift: Designing for an AI Coder

A human developer can infer a great deal from a high-level design; they fill in the blanks with experience. An AI Coder, however, has zero implicit context. It operates only on the explicit instructions it is given. If a design omits error handling, transaction logic, or edge cases, the AI-generated code will also omit them.

Therefore, our SDD must be more than a structural blueprint; it must also be a behavioral blueprint. Level 4 is not optional—it is the source code for the business logic, specified in a way that is both unambiguous for the AI and readable for the human Conductor Team.

Assembling the Team for Phase 3

  • The Human Role (The Architectural Lead): The Architectural Lead from the Conductor Team is the ultimate decision-maker. They guide the high-level architectural strategy and validate the AI's proposed design and logic against the NFRs and business goals.
  • The AI Role (The Software Architect AI): This AI persona is an expert in software architecture, design patterns, and system modeling. Its job is to propose a coherent technical design and to detail the behavior of each component with precision.

The Four-Step SDD Generation Process

Step 1: Crafting the SA_AI's Persona (The System Prompt)

The persona for our Architect AI must be instructed to think like a seasoned architect and a meticulous technical writer.


Example System Prompt:

You are a world-class Software Architect AI. Your name is "Blueprint." Your purpose is to create clear, robust, and scalable Software Design Documents (SDDs).

Your Core Principles:

  1. C4 Model: You will structure all SDDs using the C4 model (Context, Containers, Components, and Component Behavior).
  2. NFR-Driven Design: Your architectural choices must be explicitly justified based on the Non-Functional Requirements (NFRs).
  3. Diagrams as Code: You will generate all diagrams (component, sequence, state machine) using Mermaid.js syntax.
  4. Explicit Behavior: For each key component, you will create a Level 4 section detailing its business logic with sequence diagrams to show interactions and state machines for complex state transitions.
  5. Justify Decisions: For any significant architectural choice, you will create an "Architectural Decision Record" (ADR) section.


Step 2: The Initial Input (The Task Prompt)

The input is the approved SRS. The task prompt instructs the AI to begin the design process.


Example Task Prompt:

"Hi Blueprint. Using the attached srs-communication-v1.md, please generate the first draft of the sdd-communication-v1.md.

Architectural Constraint: Our company has a 'microservices-first' policy. Please design this solution as a new, independent service. Start by creating the C4 Level 2 (Containers) and C4 Level 3 (Components) diagrams and descriptions. Then, for the primary 'Comment Logic' component, create a Level 4 sequence diagram for the 'Create Comment' use case."


Step 3: Analyzing the First Draft (The AI's Output)

The AI will now generate the SDD, including both structural and behavioral diagrams.


Snippet of the AI-Generated SDD:

Level 3: Components - Comments Service

The Comments Service is a self-contained microservice responsible for all logic related to message creation, retrieval, and user mentions.

Component Diagram:

```mermaid
graph TD
  subgraph "Comments Service"
        A[API Controller]
        B[Comment Logic]
        C[Data Access Layer]
    end
      D(API Gateway) --> A; A --> B; B --> C;
    C -- "CRUD Ops" --> E(Comments DB);
    B -- "Validate User" --> F(Project Service API);
    B -- "Publishes Event" --> G(Message Bus);
```        

Level 4: Component Behavior - Comment Logic

Sequence Diagram: Create Comment

This diagram details the sequence of operations when a user creates a new comment, fulfilling FR-001, FR-002, and FR-003.

```mermaid
sequenceDiagram
    participant User
    participant Gateway as API Gateway
    participant Controller as API Controller
    participant Logic as Comment Logic
    participant ProjService as Project Service
    participant DB as Comments DB
    User->>Gateway: POST /comments (payload)
    Gateway->>Controller: Forward Request
    Controller->>Logic: createComment(data)
    Logic->>ProjService: validateUser(userId)
    ProjService-->>Logic: User OK
    Logic->>DB: insertComment(comment)
    DB-->>Logic: Success
    Logic-->>Controller: Comment Created
    Controller-->>Gateway: 201 Created
    Gateway-->>User: 201 Created
```        

Step 4: The Iteration & Feedback Loops

A. Human Feedback (Guiding Strategic Decisions)

The Architectural Lead reviews the design for trade-offs and strategic alignment.


Example of Human Feedback:

"Blueprint, this is a solid start. The sequence diagram is clear. Now, please add error handling to it. Show what happens if the validateUser call to the Project Service fails (e.g., user not found). The system should return a 403 Forbidden error."


B. Inter-Agent Feedback (The Completeness Check)

Once the design is stable, it's sent to the Requirements Manager AI ("Trace") for validation.


Prompt to RM_AI:

"Trace, please review the attached sdd-communication-v1.md. Does the proposed design, including the behavioral diagrams, fully address every functional and non-functional requirement from the srs-communication-v1.md? List any requirements that are not explicitly satisfied."


Best Practices for a Resilient SDD

  • Let NFRs Drive Your Design: NFRs are hard constraints that dictate major architectural choices. A great SDD shows how the architecture is a direct response to these constraints.
  • Visualize Everything (with Code): Embedding Mermaid.js diagrams for both structure and behavior is a superpower. They are version-controlled, easy to update, and provide unambiguous instructions for the Coder AI.
  • Document Your Decisions (ADRs): A great SDD explains not just what was designed, but why. An Architectural Decision Record (ADR) captures the context, options, and reasoning behind a significant choice.

Finalizing the SDD: The Handoff to Implementation

  • Exit Criteria: The SDD is approved by the Conductor Team and has been validated for completeness by the RM_AI. The behavioral specifications are detailed enough for AI code generation.
  • The Final Action: The approved sdd-communication-v1.md is merged into the main branch.
  • The Handoff: This document is now the definitive technical blueprint. It will be used by the Test Manager AI to create a test strategy and by the Architect AI itself to generate the detailed implementation plan for our Coder AI.

Conclusion & What's Next

We have successfully translated the "what" into a concrete "how." We have a complete, validated, and buildable technical blueprint that specifies not only the static structure of our system but also its dynamic behavior. This level of precision is the key to unlocking reliable and accurate AI code generation.

With our architectural blueprint in hand, our path now splits. We are ready to both plan the tests and prepare for implementation. In our next article, we will hand our SDD to the Test Manager AI to create a comprehensive Test Plan, ensuring that quality is built into our process from the very beginning.


To view or add a comment, sign in

More articles by Marko Gacesa

Others also viewed

Explore content categories