Habit Tracker
The Habit Tracker fixture is the canonical end-to-end example. It exercises every Layer-2-carrying kind, every provenance pattern, and the full SenLang lowering.
Source: atomprd/examples/habit-tracker/.
What it contains
Section titled “What it contains”- 1
vision - 1
persona(Self-improver) - 1
module(Habits) - 1
entity(Habit) + 3fieldatoms - 6
featureatoms - 1
ui_view(multi-screen: list / add / detail) - 1
rule(habit_name_not_empty) - 1
integration(Habits REST API) - 2
criterionatoms (initial-load empty state, streak increments on check-in) - 2
fixtureatoms (empty state, streak-at-4)
Total: 21 atoms, ~12 relations.
What it produces
Section titled “What it produces”out/├── app.sen.json # 1 SenLang Document v0.3├── app.sen.map.json # RFC-0009 source map└── scenarios/ ├── cri_initial_load_h31a.json └── cri_streak_increments_b2c2.jsonThe .sen.json runs in @senlang/renderer-react with no build step. See it live at the cloud’s /demos/from-atomprd page (or run the fixture locally).
Running locally
Section titled “Running locally”cd atomprd/examples/habit-trackerbun installbun run gen# → writes out/
# Inspectcat out/app.sen.json | jq .views.ui_habits_screen_a1b2
# Render in a browsercd ../../packages/renderer-react/examplebun run dev# Open http://localhost:5173 and import out/app.sen.jsonPattern coverage
Section titled “Pattern coverage”The fixture is intentionally crafted to exercise all four provenance patterns:
| Atom | Behavior fields | Patterns demonstrated |
|---|---|---|
feat_create_habit_h14a | 4 steps | A on validate, C on call + setState |
feat_load_habits_e5f6 | 1 step | B (empty Layer 2 → bridge default) at first; C after Pattern C run |
ui_habits_screen_a1b2 | 3 screens | C from rendered_by entity + viewType template |
rul_name_not_empty_a1b2 | 2 enforced_at | C from uses_rule reverse edges |
cri_initial_load_h31a | 1 api_call, state_diff | A — hand-authored |
cri_streak_increments_b2c2 | 1 api_call, state_diff | C from feature.behavior.steps |
fix_empty_state_a1b2 | empty before/after | A |
fix_streak_at_4_z9z9 | full before/after | D — LLM suggested, accepted |
Walk-through
Section titled “Walk-through”The full step-by-step authoring walkthrough lives at atomprd/docs/tutorial-habit-tracker.md. It covers:
- Creating the project in the cloud authoring UI.
- Adding vision + persona + module + entity + 3 fields.
- Adding 6 features. Filling Layer 1 first.
- Adding 1 multi-screen
ui_view. SettingviewType=listand wiringrendered_by. - Adding 1 rule with two enforcement sites.
- Adding 1 integration (HTTP REST).
- Adding 2 criteria with
verifiesedges. - Adding 2 fixtures with
linked_criteria. - Running Pattern C on each Layer-2 kind. Reviewing the diff. Locking trusted fields.
- Filling the gaps with Pattern D for the one feature without a linked criterion.
- Generating the SenLang Document. Rendering it.
Total time: ~15 minutes end-to-end.
Reverse direction — Sen → atoms
Section titled “Reverse direction — Sen → atoms”The reverse bridge @senlang/to-atomprd extracts a draft AtomPRD manifest from a working Sen Document. Useful if you start in SenLang and want to formalise the PRD shape after:
import { toAtomPrd } from "@senlang/to-atomprd";import senDoc from "./my-app.sen.json";
const { manifest, warnings } = toAtomPrd(senDoc, { projectId: "imported" });console.log(JSON.stringify(manifest, null, 2));Atoms come back tagged provenance: C, source: "from-sen:...". vision, persona, module, criterion, fixture, runtime atoms are NOT inferred — they require human intent that doesn’t exist in the Sen Document.
See also
Section titled “See also”- Codegen → SenLang bridge — lowering rules.
- Concepts → Four patterns — how the fixture exercises each.
- Authoring → Workflow — the 13-step order.