# mouredev/hello-sdd architecture

> Architecture diagram of the GitHub repository mouredev/hello-sdd, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mouredev/hello-sdd
- Repository: https://github.com/mouredev/hello-sdd

## Overview

#### Repository Scope
This is an educational Spec-Driven Development repository. It contains reusable SDD course materials in `samples/` and a complete reference implementation, `habits-cli/`: a Python command-line application for tracking study habits and consecutive-day streaks.

#### Application Entry Points
The runnable application is the `habits` Python package:
- Module execution entry point: `habits-cli/habits/__main__.py`
- Command-line parsing and command dispatch: `habits-cli/habits/cli.py`
- Package metadata and console-script/runtime definition: `habits-cli/pyproject.toml`

The CLI exposes the application boundary through `habits add`, `habits done`, and `habits list`.

#### CLI Adapter and Control Flow
`habits-cli/habits/cli.py` translates command-line arguments into application operations, presents results/errors to the terminal, and determines process outcomes. It should not own persistence or streak rules.

Typical flow is: shell invocation → `__main__` → CLI parser/dispatcher → domain operations → storage read/write → formatted terminal output.

Paths:
- `habits-cli/habits/__main__.py`
- `habits-cli/habits/cli.py`
- `habits-cli/habits/core.py`

#### Domain Model and Streak Logic
`habits-cli/habits/core.py` is the business-logic boundary. It defines the habit-oriented operations and computes consecutive-day streaks from completion dates. This isolates behavioral rules from both CLI formatting and JSON/file representation.

Core operations support creating habits, recording completion, listing habits, and deriving current streak information.

Paths:
- `habits-cli/habits/core.py`
- `habits-cli/specs/001-habits-mvp/spec.md`
- `habits-cli/specs/001-habits-mvp/plan.md`

#### Persistence Boundary
`habits-cli/habits/storage.py` owns durable local state: loading existing habits and saving mutations. The application uses local filesystem persistence rather than a database, network API, or hosted service. Domain code should consume this through storage-oriented operations rather than directly manipulating files.

Paths:
- `habits-cli/habits/storage.py`
- `habits-cli/habits/core.py`

#### Runtime and Dependencies
The implementation targets Python and intentionally uses only the standard library. Packaging and execution configuration are in `habits-cli/pyproject.toml`; there is no web server, browser client, cloud infrastructure, database, or third-party external service in the application architecture.

Paths:
- `habits-cli/pyproject.toml`
- `habits-cli/habits/__init__.py`

#### SDD Artifact Chain
The repository treats specifications as upstream architectural inputs. The governing principles, MVP requirements, planned module contracts/data model, and decomposed implementation tasks form the change-control chain before code changes.

Paths:
- `habits-cli/docs/constitution.md`
- `habits-cli/specs/001-habits-mvp/spec.md`
- `habits-cli/specs/001-habits-mvp/plan.md`

#### Reusable Specification Generation
A reusable agent skill guides requirements interviews and creates specifications using the project’s SDD conventions. It is development-process infrastructure, not part of the habits runtime, and is mirrored for different coding-agent environments.

Paths:
- `habits-cli/.claude/skills/spec-generator/SKILL.md`
- `habits-cli/.claude/skills/spec-generator/spec-template.md`
- `habits-cli/.opencode/skill/spec-generator`

Main entry points: [`habits-cli/habits/cli.py`](https://github.com/mouredev/hello-sdd/blob/main/habits-cli/habits/cli.py) (CLI parser & dispatcher), [`habits-cli/specs/001-habits-mvp/plan.md`](https://github.com/mouredev/hello-sdd/blob/main/habits-cli/specs/001-habits-mvp/plan.md) (Implementation plan), [`habits-cli/.claude/skills/spec-generator/SKILL.md`](https://github.com/mouredev/hello-sdd/blob/main/habits-cli/.claude/skills/spec-generator/SKILL.md) (Spec generator skill), [`habits-cli/habits/__main__.py`](https://github.com/mouredev/hello-sdd/blob/main/habits-cli/habits/__main__.py) (Module entry point)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Habits CLI Runtime"]
  node_package["Python package config<br/>packaging<br/>[pyproject.toml]"]
  node_main["Module entry point<br/>Python module<br/>[__main__.py]"]
  node_cli["CLI parser &amp; dispatcher<br/>CLI adapter<br/>[cli.py]"]
  node_core["Habit domain operations<br/>domain logic<br/>[core.py]"]
  node_storage[("Local state storage<br/>persistence adapter<br/>[storage.py]")]
  node_terminal(("Shell user<br/>external actor"))
end

subgraph group_sdd["SDD Change Control"]
  node_constitution["SDD constitution<br/>governing principles<br/>[constitution.md]"]
  node_spec["MVP specification<br/>requirements<br/>[spec.md]"]
  node_plan["Implementation plan<br/>module contracts<br/>[plan.md]"]
end

subgraph group_generation["Specification Generation"]
  node_skill["Spec generator skill<br/>agent skill<br/>[SKILL.md]"]
  node_template["Specification template<br/>[spec-template.md]"]
  node_opencode_skill["OpenCode skill mirror<br/>agent skill mirror<br/>[spec-generator]"]
end

node_package -->|"defines runtime"| node_main
node_terminal -->|"invokes"| node_main
node_main -->|"starts"| node_cli
node_cli -->|"dispatches add / done / list"| node_core
node_core -->|"loads and saves habits"| node_storage
node_cli -->|"prints results and errors"| node_terminal
node_constitution -->|"governs"| node_spec
node_spec -->|"drives"| node_plan
node_plan -.->|"specifies contracts"| node_core
node_plan -.->|"specifies data model"| node_storage
node_skill -->|"uses"| node_template
node_skill -.->|"generates"| node_spec
node_opencode_skill -.->|"mirrors"| node_skill

click node_package "https://github.com/mouredev/hello-sdd/blob/main/habits-cli/pyproject.toml"
click node_main "https://github.com/mouredev/hello-sdd/blob/main/habits-cli/habits/__main__.py"
click node_cli "https://github.com/mouredev/hello-sdd/blob/main/habits-cli/habits/cli.py"
click node_core "https://github.com/mouredev/hello-sdd/blob/main/habits-cli/habits/core.py"
click node_storage "https://github.com/mouredev/hello-sdd/blob/main/habits-cli/habits/storage.py"
click node_constitution "https://github.com/mouredev/hello-sdd/blob/main/habits-cli/docs/constitution.md"
click node_spec "https://github.com/mouredev/hello-sdd/blob/main/habits-cli/specs/001-habits-mvp/spec.md"
click node_plan "https://github.com/mouredev/hello-sdd/blob/main/habits-cli/specs/001-habits-mvp/plan.md"
click node_skill "https://github.com/mouredev/hello-sdd/blob/main/habits-cli/.claude/skills/spec-generator/SKILL.md"
click node_template "https://github.com/mouredev/hello-sdd/blob/main/habits-cli/.claude/skills/spec-generator/spec-template.md"
click node_opencode_skill "https://github.com/mouredev/hello-sdd/blob/main/habits-cli/.opencode/skill/spec-generator"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_package,node_main,node_cli,node_core,node_storage,node_terminal toneBlue
class node_constitution,node_spec,node_plan toneAmber
class node_skill,node_template,node_opencode_skill toneMint
```

## Components

### Habits CLI Runtime

- [Python package config](https://github.com/mouredev/hello-sdd/blob/main/habits-cli/pyproject.toml): packaging · Defines runtime and console-script metadata. · `habits-cli/pyproject.toml`
- [Module entry point](https://github.com/mouredev/hello-sdd/blob/main/habits-cli/habits/__main__.py): Python module · `habits-cli/habits/__main__.py`
- [CLI parser & dispatcher](https://github.com/mouredev/hello-sdd/blob/main/habits-cli/habits/cli.py): CLI adapter · Maps commands and terminal outcomes. · `habits-cli/habits/cli.py`
- [Habit domain operations](https://github.com/mouredev/hello-sdd/blob/main/habits-cli/habits/core.py): domain logic · Creates habits, records completions, and derives streaks. · `habits-cli/habits/core.py`
- [Local state storage](https://github.com/mouredev/hello-sdd/blob/main/habits-cli/habits/storage.py): persistence adapter · Loads and saves durable local habit state. · `habits-cli/habits/storage.py`
- **Shell user**: external actor

### SDD Change Control

- [SDD constitution](https://github.com/mouredev/hello-sdd/blob/main/habits-cli/docs/constitution.md): governing principles · `habits-cli/docs/constitution.md`
- [MVP specification](https://github.com/mouredev/hello-sdd/blob/main/habits-cli/specs/001-habits-mvp/spec.md): requirements · `habits-cli/specs/001-habits-mvp/spec.md`
- [Implementation plan](https://github.com/mouredev/hello-sdd/blob/main/habits-cli/specs/001-habits-mvp/plan.md): module contracts · Defines planned module contracts and data model. · `habits-cli/specs/001-habits-mvp/plan.md`

### Specification Generation

- [Spec generator skill](https://github.com/mouredev/hello-sdd/blob/main/habits-cli/.claude/skills/spec-generator/SKILL.md): agent skill · Guides requirements interviews and specification creation. · `habits-cli/.claude/skills/spec-generator/SKILL.md`
- [Specification template](https://github.com/mouredev/hello-sdd/blob/main/habits-cli/.claude/skills/spec-generator/spec-template.md): template · `habits-cli/.claude/skills/spec-generator/spec-template.md`
- [OpenCode skill mirror](https://github.com/mouredev/hello-sdd/blob/main/habits-cli/.opencode/skill/spec-generator): agent skill mirror · `habits-cli/.opencode/skill/spec-generator`

## Connections

- Python package config → Module entry point: defines runtime
- Shell user → Module entry point: invokes
- Module entry point → CLI parser & dispatcher: starts
- CLI parser & dispatcher → Habit domain operations: dispatches add / done / list
- Habit domain operations → Local state storage: loads and saves habits
- CLI parser & dispatcher → Shell user: prints results and errors
- SDD constitution → MVP specification: governs
- MVP specification → Implementation plan: drives
- Implementation plan → Habit domain operations: specifies contracts
- Implementation plan → Local state storage: specifies data model
- Spec generator skill → Specification template: uses
- Spec generator skill → MVP specification: generates
- OpenCode skill mirror → Spec generator skill: mirrors
