Repository/Data Access Architecture Lens
Cognitive Mode: Data-Centric
Primary Question: "How is data accessed?"
Focus: Repository Pattern, Entity Relationships, Query Patterns, Format Conversion
When to Use
- Need to understand data access layer architecture
- Documenting repository pattern implementation
- Analyzing entity relationships and query patterns
- User invokes
/autoskillit:arch-lens-repository-access or /autoskillit:make-arch-diag repository
Critical Constraints
NEVER:
- Modify any source code files
- Focus on data flow (that's data lineage lens)
- Include business logic details
- Run subagents in the background (
run_in_background: true is prohibited)
ALWAYS:
Arguments
/autoskillit:arch-lens-repository-access [context_path]
- context_path (optional) — Absolute path to a PR context file containing new files
(★-prefixed) and modified files (●-prefixed) from the PR diff. When provided, read
this file before beginning analysis and focus the diagram on the architectural areas
affected by these specific files. When absent, explore the full CWD.
Analysis Workflow
Step 0: Read PR context (when provided)
If a context_path positional argument is present:
- Read the file at
context_path
- Extract: new files list (★-prefixed), modified files list (●-prefixed)
- Focus Step 1 exploration on the modules/components these files belong to
- Apply ★ prefix on diagram nodes representing new files/components
- Apply ● prefix on diagram nodes representing modified files/components
If no context_path is provided, skip this step and explore the full CWD in Step 1.
Step 1: Launch Parallel Exploration Subagents
Spawn Explore subagents to investigate:
Repository Classes
- Find all repository implementations
- Identify base repository patterns
- Look for: Repository classes, DAO (Data Access Object) patterns, base repository abstractions
Entity Models
- Find entity/model classes
- Identify table/collection definitions
- Look for: ORM models (ActiveRecord, Entity Framework, TypeORM, etc.), data models, entity classes
CRUD Operations
- Find standard CRUD methods
- Identify specialized query methods
- Look for: create, get, update, delete, save, find_*, get_by_*, query methods
Query Patterns
- Find complex queries and joins
- Identify index usage patterns
- Look for: filter, where, join, order_by, group_by, query builders
Factory/Scoping
- Find repository factory patterns
- Identify scope management
- Look for: Factory patterns, dependency injection, session/context management
Format Conversion
- Find adapter/converter patterns
- Identify boundary conversions
- Look for: Adapters, DTOs, to_*/from_* methods, serializers, mappers
Step 2: Map Entity Relationships
Document:
- Entities: All model classes
- Relationships: Foreign key relationships, cardinality
- Key Fields: Primary keys, business keys
- Repositories: Which repo manages which entity
CRITICAL - Analyze Read/Write Direction:
For EVERY repository method and data access:
- Read methods:
get_*, find_*, query_* - data flows OUT of storage
- Write methods:
save_*, create_*, update_*, delete_* - data flows INTO storage
- Bulk operations: Direction of each operation in batch
For EVERY caller-to-repository relationship:
- Does the caller READ from this repository?
- Does the caller WRITE to this repository?
- Or both?
Label connections accordingly (reads, writes, reads/writes)
Step 3: Document Access Patterns
| Pattern |
Repository Method |
Use Case |
| By ID |
get_by_id() |
Single entity lookup |
| By Business Key |
get_by_* |
Domain-specific lookup |
| List |
get_all(), get_for_* |
Collection queries |
| Bulk |
save_many() |
Batch operations |
Step 4: Create the Diagram
Use flowchart with:
Direction: LR (left-to-right) for caller-to-storage flow
Subgraphs:
- Callers (who uses repositories)
- Factory (repository construction)
- Repositories by Category
- Conversion (format boundaries)
- Storage (database tables)
Node Styling:
cli class: Callers (nodes, handlers)
phase class: Factory, scoping
newComponent class: Repositories (green to highlight)
handler class: Conversion adapters
integration class: Database storage
Show Relationships:
- Entity relationships with cardinality (1:N)
- Repository-to-table mapping
- Conversion flow
Step 5: Write Output
Write the diagram to: {{AUTOSKILLIT_TEMP}}/arch-lens-repository-access/arch_diag_repository_access_{YYYY-MM-DD_HHMMSS}.md (relative to the current working directory)
After writing the diagram file, emit a structured output line:
IMPORTANT: Emit the structured output tokens as literal plain text with no
markdown formatting on the token names. Do not wrap token names in **bold**,
*italic*, or any other markdown. The adjudicator performs a regex match on the
exact token name — decorators cause match failure.
diagram_path = {absolute_path_to_diagram_file}
Output Template
# Repository/Data Access Diagram: {System Name}
**Lens:** Repository/Data Access (Data-Centric)
**Question:** How is data accessed?
**Date:** {YYYY-MM-DD}
**Scope:** {What was analyzed}
## Repository Overview
| Category | Count | Key Repositories |
|----------|-------|------------------|
| {category} | {N} | {names} |
## Data Access Diagram
```mermaid
%%{init: {'flowchart': {'nodeSpacing': 50, 'rankSpacing': 60, 'curve': 'basis'}}}%%
flowchart LR
%% CLASS DEFINITIONS %%
classDef cli fill:#1a237e,stroke:#7986cb,stroke-width:2px,color:#fff;
classDef stateNode fill:#004d40,stroke:#4db6ac,stroke-width:2px,color:#fff;
classDef handler fill:#e65100,stroke:#ffb74d,stroke-width:2px,color:#fff;
classDef phase fill:#6a1b9a,stroke:#ba68c8,stroke-width:2px,color:#fff;
classDef output fill:#00695c,stroke:#4db6ac,stroke-width:2px,color:#fff;
classDef integration fill:#c62828,stroke:#ef9a9a,stroke-width:2px,color:#fff;
classDef newComponent fill:#2e7d32,stroke:#81c784,stroke-width:2px,color:#fff;
subgraph Callers ["CALLERS"]
CALLER1["Handler/Service<br/>━━━━━━━━━━<br/>Business logic"]
end
subgraph Factory ["REPOSITORY FACTORY"]
direction TB
FAC["RepositoryFactory<br/>━━━━━━━━━━<br/>Dependency injection"]
SCOPE["Scoping<br/>━━━━━━━━━━<br/>Context management"]
end
subgraph Repositories ["REPOSITORIES"]
direction TB
REPO1["EntityRepository<br/>━━━━━━━━━━<br/>CRUD methods"]
BASE["BaseRepository<T><br/>━━━━━━━━━━<br/>Generic CRUD"]
end
subgraph Conversion ["FORMAT CONVERSION"]
direction TB
ADAPTER["Adapters/DTOs<br/>━━━━━━━━━━<br/>Serialization"]
end
subgraph Storage ["DATABASE"]
direction TB
DB[("Table/Collection<br/>━━━━━━━━━━<br/>Persistent storage")]
end
%% FLOW %%
CALLER1 --> FAC
FAC --> SCOPE
SCOPE --> REPO1
BASE --> REPO1
REPO1 --> ADAPTER
ADAPTER --> DB
%% CLASS ASSIGNMENTS %%
class CALLER1 cli;
class FAC,SCOPE phase;
class REPO1 newComponent;
class BASE stateNode;
class ADAPTER handler;
class DB integration;
Color Legend:
| Color |
Category |
Description |
| Dark Blue |
Callers |
Services/handlers that use repositories |
| Purple |
Factory |
Repository construction and scoping |
| Green |
Repositories |
Repository implementations |
| Teal |
Base |
Generic base repository |
| Orange |
Conversion |
Format adapters/DTOs |
| Red |
Storage |
Database tables/collections |
Repository Categories
| Category |
Count |
Key Repositories |
| {category} |
{N} |
{list} |
Key Query Patterns
| Pattern |
Repository Method |
Use Case |
| {pattern} |
{method} |
{use case} |
Entity Relationships
| Parent |
Child |
Cardinality |
FK |
| {parent} |
{child} |
{1:N/1:1} |
{fk field} |
---
## Pre-Diagram Checklist
Before creating the diagram, verify:
- [ ] LOADED `/autoskillit:mermaid` skill using the Skill tool
- [ ] Using ONLY classDef styles from the mermaid skill (no invented colors)
- [ ] Diagram will include a color legend table
---
## Related Skills
- `/autoskillit:make-arch-diag` - Parent skill for lens selection
- `/autoskillit:mermaid` - MUST BE LOADED before creating diagram
- `/autoskillit:arch-lens-data-lineage` - For data flow view
- `/autoskillit:arch-lens-c4-container` - For storage container view
1---2name: arch-lens-repository-access3description: Create Repository/Data Access architecture diagram showing the repository pattern, entity relationships, and data access patterns. Data-centric lens answering "How is data accessed?"4---56# Repository/Data Access Architecture Lens78**Cognitive Mode:** Data-Centric9**Primary Question:** "How is data accessed?"10**Focus:** Repository Pattern, Entity Relationships, Query Patterns, Format Conversion1112## When to Use1314- Need to understand data access layer architecture15- Documenting repository pattern implementation16- Analyzing entity relationships and query patterns17- User invokes `/autoskillit:arch-lens-repository-access` or `/autoskillit:make-arch-diag repository`1819## Critical Constraints2021**NEVER:**22- Modify any source code files23- Focus on data flow (that's data lineage lens)24- Include business logic details25- Run subagents in the background (`run_in_background: true` is prohibited)2627**ALWAYS:**28- Focus on REPOSITORIES and their methods29- Show entity relationships (1:1, 1:N, N:N)30- Document key query patterns31- Identify format conversion boundaries32- BEFORE creating any diagram, LOAD the `/autoskillit:mermaid` skill using the Skill tool - this is MANDATORY33- If the Skill tool cannot be used (disable-model-invocation) or refuses this invocation, do NOT proceed with diagram creation. Abort this step and omit the diagram from output.34- After writing the diagram file, emit the **absolute path** as a structured output35 token as your final output. Resolve the relative `temp/arch-lens-repository-access/...`36 save path to absolute by prepending the full CWD:37 ```38 diagram_path = /absolute/cwd/temp/arch-lens-repository-access/{filename}.md39 ```40 This token is MANDATORY — the pipeline cannot proceed without it.4142## Arguments4344`/autoskillit:arch-lens-repository-access [context_path]`4546- **context_path** (optional) — Absolute path to a PR context file containing new files47 (★-prefixed) and modified files (●-prefixed) from the PR diff. When provided, read48 this file before beginning analysis and focus the diagram on the architectural areas49 affected by these specific files. When absent, explore the full CWD.5051---5253## Analysis Workflow5455### Step 0: Read PR context (when provided)5657If a `context_path` positional argument is present:581. Read the file at `context_path`592. Extract: new files list (★-prefixed), modified files list (●-prefixed)603. Focus Step 1 exploration on the modules/components these files belong to614. Apply ★ prefix on diagram nodes representing new files/components625. Apply ● prefix on diagram nodes representing modified files/components6364If no `context_path` is provided, skip this step and explore the full CWD in Step 1.6566### Step 1: Launch Parallel Exploration Subagents6768Spawn Explore subagents to investigate:6970**Repository Classes**71- Find all repository implementations72- Identify base repository patterns73- Look for: Repository classes, DAO (Data Access Object) patterns, base repository abstractions7475**Entity Models**76- Find entity/model classes77- Identify table/collection definitions78- Look for: ORM models (ActiveRecord, Entity Framework, TypeORM, etc.), data models, entity classes7980**CRUD Operations**81- Find standard CRUD methods82- Identify specialized query methods83- Look for: create, get, update, delete, save, find_*, get_by_*, query methods8485**Query Patterns**86- Find complex queries and joins87- Identify index usage patterns88- Look for: filter, where, join, order_by, group_by, query builders8990**Factory/Scoping**91- Find repository factory patterns92- Identify scope management93- Look for: Factory patterns, dependency injection, session/context management9495**Format Conversion**96- Find adapter/converter patterns97- Identify boundary conversions98- Look for: Adapters, DTOs, to_*/from_* methods, serializers, mappers99100### Step 2: Map Entity Relationships101102Document:103- **Entities**: All model classes104- **Relationships**: Foreign key relationships, cardinality105- **Key Fields**: Primary keys, business keys106- **Repositories**: Which repo manages which entity107108**CRITICAL - Analyze Read/Write Direction:**109For EVERY repository method and data access:110- **Read methods**: `get_*`, `find_*`, `query_*` - data flows OUT of storage111- **Write methods**: `save_*`, `create_*`, `update_*`, `delete_*` - data flows INTO storage112- **Bulk operations**: Direction of each operation in batch113114For EVERY caller-to-repository relationship:115- Does the caller READ from this repository?116- Does the caller WRITE to this repository?117- Or both?118119Label connections accordingly (reads, writes, reads/writes)120121### Step 3: Document Access Patterns122123| Pattern | Repository Method | Use Case |124|---------|------------------|----------|125| By ID | get_by_id() | Single entity lookup |126| By Business Key | get_by_* | Domain-specific lookup |127| List | get_all(), get_for_* | Collection queries |128| Bulk | save_many() | Batch operations |129130### Step 4: Create the Diagram131132Use flowchart with:133134**Direction:** `LR` (left-to-right) for caller-to-storage flow135136**Subgraphs:**137- Callers (who uses repositories)138- Factory (repository construction)139- Repositories by Category140- Conversion (format boundaries)141- Storage (database tables)142143**Node Styling:**144- `cli` class: Callers (nodes, handlers)145- `phase` class: Factory, scoping146- `newComponent` class: Repositories (green to highlight)147- `handler` class: Conversion adapters148- `integration` class: Database storage149150**Show Relationships:**151- Entity relationships with cardinality (1:N)152- Repository-to-table mapping153- Conversion flow154155### Step 5: Write Output156157Write the diagram to: `{{AUTOSKILLIT_TEMP}}/arch-lens-repository-access/arch_diag_repository_access_{YYYY-MM-DD_HHMMSS}.md` (relative to the current working directory)158159After writing the diagram file, emit a structured output line:160161> **IMPORTANT:** Emit the structured output tokens as **literal plain text with no162> markdown formatting on the token names**. Do not wrap token names in `**bold**`,163> `*italic*`, or any other markdown. The adjudicator performs a regex match on the164> exact token name — decorators cause match failure.165166```167diagram_path = {absolute_path_to_diagram_file}168```169170---171172## Output Template173174```markdown175# Repository/Data Access Diagram: {System Name}176177**Lens:** Repository/Data Access (Data-Centric)178**Question:** How is data accessed?179**Date:** {YYYY-MM-DD}180**Scope:** {What was analyzed}181182## Repository Overview183184| Category | Count | Key Repositories |185|----------|-------|------------------|186| {category} | {N} | {names} |187188## Data Access Diagram189190```mermaid191%%{init: {'flowchart': {'nodeSpacing': 50, 'rankSpacing': 60, 'curve': 'basis'}}}%%192flowchart LR193 %% CLASS DEFINITIONS %%194 classDef cli fill:#1a237e,stroke:#7986cb,stroke-width:2px,color:#fff;195 classDef stateNode fill:#004d40,stroke:#4db6ac,stroke-width:2px,color:#fff;196 classDef handler fill:#e65100,stroke:#ffb74d,stroke-width:2px,color:#fff;197 classDef phase fill:#6a1b9a,stroke:#ba68c8,stroke-width:2px,color:#fff;198 classDef output fill:#00695c,stroke:#4db6ac,stroke-width:2px,color:#fff;199 classDef integration fill:#c62828,stroke:#ef9a9a,stroke-width:2px,color:#fff;200 classDef newComponent fill:#2e7d32,stroke:#81c784,stroke-width:2px,color:#fff;201202 subgraph Callers ["CALLERS"]203 CALLER1["Handler/Service<br/>━━━━━━━━━━<br/>Business logic"]204 end205206 subgraph Factory ["REPOSITORY FACTORY"]207 direction TB208 FAC["RepositoryFactory<br/>━━━━━━━━━━<br/>Dependency injection"]209 SCOPE["Scoping<br/>━━━━━━━━━━<br/>Context management"]210 end211212 subgraph Repositories ["REPOSITORIES"]213 direction TB214 REPO1["EntityRepository<br/>━━━━━━━━━━<br/>CRUD methods"]215 BASE["BaseRepository<T><br/>━━━━━━━━━━<br/>Generic CRUD"]216 end217218 subgraph Conversion ["FORMAT CONVERSION"]219 direction TB220 ADAPTER["Adapters/DTOs<br/>━━━━━━━━━━<br/>Serialization"]221 end222223 subgraph Storage ["DATABASE"]224 direction TB225 DB[("Table/Collection<br/>━━━━━━━━━━<br/>Persistent storage")]226 end227228 %% FLOW %%229 CALLER1 --> FAC230 FAC --> SCOPE231 SCOPE --> REPO1232 BASE --> REPO1233 REPO1 --> ADAPTER234 ADAPTER --> DB235236 %% CLASS ASSIGNMENTS %%237 class CALLER1 cli;238 class FAC,SCOPE phase;239 class REPO1 newComponent;240 class BASE stateNode;241 class ADAPTER handler;242 class DB integration;243```244245**Color Legend:**246| Color | Category | Description |247|-------|----------|-------------|248| Dark Blue | Callers | Services/handlers that use repositories |249| Purple | Factory | Repository construction and scoping |250| Green | Repositories | Repository implementations |251| Teal | Base | Generic base repository |252| Orange | Conversion | Format adapters/DTOs |253| Red | Storage | Database tables/collections |254255## Repository Categories256257| Category | Count | Key Repositories |258|----------|-------|------------------|259| {category} | {N} | {list} |260261## Key Query Patterns262263| Pattern | Repository Method | Use Case |264|---------|------------------|----------|265| {pattern} | {method} | {use case} |266267## Entity Relationships268269| Parent | Child | Cardinality | FK |270|--------|-------|-------------|-----|271| {parent} | {child} | {1:N/1:1} | {fk field} |272```273274---275276## Pre-Diagram Checklist277278Before creating the diagram, verify:279280- [ ] LOADED `/autoskillit:mermaid` skill using the Skill tool281- [ ] Using ONLY classDef styles from the mermaid skill (no invented colors)282- [ ] Diagram will include a color legend table283284---285286## Related Skills287288- `/autoskillit:make-arch-diag` - Parent skill for lens selection289- `/autoskillit:mermaid` - MUST BE LOADED before creating diagram290- `/autoskillit:arch-lens-data-lineage` - For data flow view291- `/autoskillit:arch-lens-c4-container` - For storage container view