Skip to content

Commit f504f43

Browse files
authored
docs: add Vertical Slice Architecture to Phase 3 roadmap (#395)
* docs: add Vertical Slice Architecture pattern to Phase 3 roadmap Name Vertical Slice Architecture as the target pattern for Phase 3. Add target end-state directory structure and key design principles. Add two new steps: 3.14 (Presentation Layer Extraction) and 3.15 (Domain Directory Grouping). Renumber old 3.14 to 3.16. * docs: fix directory structure inconsistencies in VSA roadmap
1 parent 5a1d7ce commit f504f43

1 file changed

Lines changed: 70 additions & 2 deletions

File tree

docs/roadmap/ROADMAP.md

Lines changed: 70 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Codegraph is a strong local-first code graph CLI. This roadmap describes planned
1616
| [**2**](#phase-2--foundation-hardening) | Foundation Hardening | Parser registry, complete MCP, test coverage, enhanced config, multi-repo MCP | **Complete** (v1.4.0) |
1717
| [**2.5**](#phase-25--analysis-expansion) | Analysis Expansion | Complexity metrics, community detection, flow tracing, co-change, manifesto, boundary rules, check, triage, audit, batch, hybrid search | **Complete** (v2.6.0) |
1818
| [**2.7**](#phase-27--deep-analysis--graph-enrichment) | Deep Analysis & Graph Enrichment | Dataflow analysis, intraprocedural CFG, AST node storage, expanded node/edge types, extractors refactoring, CLI consolidation, interactive viewer, exports command, normalizeSymbol | **Complete** (v3.0.0) |
19-
| [**3**](#phase-3--architectural-refactoring) | Architectural Refactoring | Unified AST analysis framework, command/query separation, repository pattern, queries.js decomposition, composable MCP, CLI commands, domain errors, curated API, unified graph model | **In Progress** (v3.1.1) |
19+
| [**3**](#phase-3--architectural-refactoring) | Architectural Refactoring (Vertical Slice) | Unified AST analysis framework, command/query separation, repository pattern, queries.js decomposition, composable MCP, CLI commands, domain errors, presentation layer, domain grouping, curated API, unified graph model | **In Progress** (v3.1.1) |
2020
| [**4**](#phase-4--typescript-migration) | TypeScript Migration | Project setup, core type definitions, leaf -> core -> orchestration module migration, test migration | Planned |
2121
| [**5**](#phase-5--intelligent-embeddings) | Intelligent Embeddings | LLM-generated descriptions, enhanced embeddings, build-time semantic metadata, module summaries | Planned |
2222
| [**6**](#phase-6--natural-language-queries) | Natural Language Queries | `ask` command, conversational sessions, LLM-narrated graph queries, onboarding tools | Planned |
@@ -560,6 +560,30 @@ Plus updated enums on existing tools (edge_kinds, symbol kinds).
560560

561561
> Reference: [generated/architecture.md](../../generated/architecture.md) -- full analysis with code examples and rationale.
562562
563+
**Architecture pattern: Vertical Slice Architecture.** Each CLI command is a natural vertical slice — thin command entry point → domain logic → data access → formatted output. This avoids the overhead of layered patterns (Hexagonal, Clean Architecture) that would create abstractions with only one implementation, while giving clear boundaries and independent testability per feature. The target end-state directory structure:
564+
565+
```
566+
src/
567+
commands/ # Thin CLI entry points (one per command)
568+
domain/ # Core logic grouped by feature
569+
graph/ # builder, resolve, cycles, watcher
570+
analysis/ # symbol-lookup, impact, dependencies, module-map, context, exports, roles
571+
search/ # embedder, semantic search, hybrid
572+
ast-analysis/ # Unified visitor framework (already in place)
573+
db/ # Repository, migrations, query-builder, connection
574+
extractors/ # Per-language tree-sitter extractors (already in place)
575+
mcp/ # MCP server, tool registry, per-tool handlers
576+
presentation/ # Output formatting: viewer, export (DOT/Mermaid/JSON), result-formatter, table, sequence-renderer
577+
infrastructure/ # Config, logger, native loader, pagination, test-filter, errors
578+
shared/ # Constants, normalize, generators
579+
```
580+
581+
Key principles:
582+
- **Commands are thin** — parse args, call domain, format output. No business logic in CLI layer
583+
- **Domain modules don't import presentation** — they return data, callers decide format
584+
- **Shared kernel stays flat**`db/`, `infrastructure/`, `shared/` are cross-cutting
585+
- **No premature abstractions** — no interfaces/ports for single implementations
586+
563587
**Context:** Phases 2.5 and 2.7 added 38 modules and grew the codebase from 5K to 26,277 lines without introducing shared abstractions. The dual-function anti-pattern was replicated across 19 modules. Three independent AST analysis engines (complexity, CFG, dataflow) totaling 4,801 lines share the same fundamental pattern but no infrastructure. Raw SQL is scattered across 25+ modules touching 13 tables. The priority ordering has been revised based on actual growth patterns -- the new #1 priority is the unified AST analysis framework.
564588

565589
### 3.1 -- Unified AST Analysis Framework ★ Critical 🔄
@@ -888,7 +912,51 @@ The repository pattern (3.3) enables true unit testing:
888912

889913
**Current gap:** Many "unit" tests still hit SQLite because there's no repository abstraction.
890914

891-
### 3.14 -- Remaining Items (Lower Priority)
915+
### 3.14 -- Presentation Layer Extraction
916+
917+
Separate all output formatting from domain logic into a dedicated `src/presentation/` directory. Currently `viewer.js` (948 lines) and `export.js` (681 lines) mix graph traversal with rendering. `result-formatter.js` already exists in `infrastructure/` as a first step.
918+
919+
```
920+
src/
921+
presentation/
922+
viewer.js # Interactive terminal viewer (tree rendering, color, layout)
923+
export.js # DOT, Mermaid, JSON, SVG graph serialization
924+
table.js # Tabular CLI output (used by complexity, stats, etc.)
925+
sequence-renderer.js # Mermaid sequence diagram formatting (from sequence.js)
926+
result-formatter.js # Structured result formatting (moved from infrastructure/)
927+
```
928+
929+
- 🔲 Extract rendering logic from `viewer.js` — keep graph data loading in domain, move formatting to presentation
930+
- 🔲 Extract serialization from `export.js` — DOT/Mermaid/JSON writers become pure data → string transforms
931+
- 🔲 Extract table formatting helpers used across `queries-cli.js`, `complexity`, `stats`
932+
- 🔲 Move `result-formatter.js` from `infrastructure/` to `presentation/` (it's output formatting, not infrastructure)
933+
- 🔲 Extract Mermaid rendering from `sequence.js` into `sequence-renderer.js`
934+
935+
**Principle:** Domain functions return plain data objects. Presentation functions are pure transforms: `data → formatted string`. Commands wire the two together.
936+
937+
**Affected files:** `src/viewer.js`, `src/export.js`, `src/sequence.js`, `src/infrastructure/result-formatter.js`
938+
939+
### 3.15 -- Domain Directory Grouping
940+
941+
Once 3.2-3.4 are complete and analysis modules are standalone, group them under `src/domain/` by feature area. This is a move-only refactor — no logic changes, just directory organization to match the vertical slice target structure.
942+
943+
```
944+
src/domain/
945+
graph/ # builder.js, resolve.js, cycles.js, watcher.js
946+
analysis/ # symbol-lookup.js, impact.js, dependencies.js, module-map.js,
947+
# context.js, exports.js, roles.js (from 3.4 decomposition)
948+
search/ # embedder.js subsystem (from 3.10)
949+
```
950+
951+
- 🔲 Move builder pipeline modules to `domain/graph/`
952+
- 🔲 Move decomposed query modules (from 3.4) to `domain/analysis/`
953+
- 🔲 Move embedder subsystem (from 3.10) to `domain/search/`
954+
- 🔲 Update all import paths across codebase
955+
- 🔲 Update `package.json` exports map (from 3.7)
956+
957+
**Prerequisite:** 3.2, 3.4, 3.9, 3.10 should be complete before this step — it organizes the results of those decompositions.
958+
959+
### 3.16 -- Remaining Items (Lower Priority)
892960

893961
These items from the original Phase 3 are still valid but less urgent:
894962

0 commit comments

Comments
 (0)