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-access3categories: [arch-lens]4activate_deps: [mermaid]5description: Create Repository/Data Access architecture diagram showing the repository pattern, entity relationships, and data access patterns. Data-centric lens answering "How is data accessed?"6hooks:7 PreToolUse:8 - matcher: "*"9 hooks:10 - type: command11 command: "echo 'Repository Access Lens - Analyzing data access patterns...'"12 once: true13metadata:14 source: https://skillmd.com/skills/talont-org/arch-lens-repository-access15---1617# Repository/Data Access Architecture Lens1819**Cognitive Mode:** Data-Centric20**Primary Question:** "How is data accessed?"21**Focus:** Repository Pattern, Entity Relationships, Query Patterns, Format Conversion2223## When to Use2425- Need to understand data access layer architecture26- Documenting repository pattern implementation27- Analyzing entity relationships and query patterns28- User invokes `/autoskillit:arch-lens-repository-access` or `/autoskillit:make-arch-diag repository`2930## Critical Constraints3132**NEVER:**33- Modify any source code files34- Focus on data flow (that's data lineage lens)35- Include business logic details36- Run subagents in the background (`run_in_background: true` is prohibited)3738**ALWAYS:**39- Focus on REPOSITORIES and their methods40- Show entity relationships (1:1, 1:N, N:N)41- Document key query patterns42- Identify format conversion boundaries43- BEFORE creating any diagram, LOAD the `/autoskillit:mermaid` skill using the Skill tool - this is MANDATORY44- 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.45- After writing the diagram file, emit the **absolute path** as a structured output46 token as your final output. Resolve the relative `temp/arch-lens-repository-access/...`47 save path to absolute by prepending the full CWD:48 ```49 diagram_path = /absolute/cwd/temp/arch-lens-repository-access/{filename}.md50 ```51 This token is MANDATORY — the pipeline cannot proceed without it.5253## Arguments5455`/autoskillit:arch-lens-repository-access [context_path]`5657- **context_path** (optional) — Absolute path to a PR context file containing new files58 (★-prefixed) and modified files (●-prefixed) from the PR diff. When provided, read59 this file before beginning analysis and focus the diagram on the architectural areas60 affected by these specific files. When absent, explore the full CWD.6162---6364## Analysis Workflow6566### Step 0: Read PR context (when provided)6768If a `context_path` positional argument is present:691. Read the file at `context_path`702. Extract: new files list (★-prefixed), modified files list (●-prefixed)713. Focus Step 1 exploration on the modules/components these files belong to724. Apply ★ prefix on diagram nodes representing new files/components735. Apply ● prefix on diagram nodes representing modified files/components7475If no `context_path` is provided, skip this step and explore the full CWD in Step 1.7677### Step 1: Launch Parallel Exploration Subagents7879Spawn Explore subagents to investigate:8081**Repository Classes**82- Find all repository implementations83- Identify base repository patterns84- Look for: Repository classes, DAO (Data Access Object) patterns, base repository abstractions8586**Entity Models**87- Find entity/model classes88- Identify table/collection definitions89- Look for: ORM models (ActiveRecord, Entity Framework, TypeORM, etc.), data models, entity classes9091**CRUD Operations**92- Find standard CRUD methods93- Identify specialized query methods94- Look for: create, get, update, delete, save, find_*, get_by_*, query methods9596**Query Patterns**97- Find complex queries and joins98- Identify index usage patterns99- Look for: filter, where, join, order_by, group_by, query builders100101**Factory/Scoping**102- Find repository factory patterns103- Identify scope management104- Look for: Factory patterns, dependency injection, session/context management105106**Format Conversion**107- Find adapter/converter patterns108- Identify boundary conversions109- Look for: Adapters, DTOs, to_*/from_* methods, serializers, mappers110111### Step 2: Map Entity Relationships112113Document:114- **Entities**: All model classes115- **Relationships**: Foreign key relationships, cardinality116- **Key Fields**: Primary keys, business keys117- **Repositories**: Which repo manages which entity118119**CRITICAL - Analyze Read/Write Direction:**120For EVERY repository method and data access:121- **Read methods**: `get_*`, `find_*`, `query_*` - data flows OUT of storage122- **Write methods**: `save_*`, `create_*`, `update_*`, `delete_*` - data flows INTO storage123- **Bulk operations**: Direction of each operation in batch124125For EVERY caller-to-repository relationship:126- Does the caller READ from this repository?127- Does the caller WRITE to this repository?128- Or both?129130Label connections accordingly (reads, writes, reads/writes)131132### Step 3: Document Access Patterns133134| Pattern | Repository Method | Use Case |135|---------|------------------|----------|136| By ID | get_by_id() | Single entity lookup |137| By Business Key | get_by_* | Domain-specific lookup |138| List | get_all(), get_for_* | Collection queries |139| Bulk | save_many() | Batch operations |140141### Step 4: Create the Diagram142143Use flowchart with:144145**Direction:** `LR` (left-to-right) for caller-to-storage flow146147**Subgraphs:**148- Callers (who uses repositories)149- Factory (repository construction)150- Repositories by Category151- Conversion (format boundaries)152- Storage (database tables)153154**Node Styling:**155- `cli` class: Callers (nodes, handlers)156- `phase` class: Factory, scoping157- `newComponent` class: Repositories (green to highlight)158- `handler` class: Conversion adapters159- `integration` class: Database storage160161**Show Relationships:**162- Entity relationships with cardinality (1:N)163- Repository-to-table mapping164- Conversion flow165166### Step 5: Write Output167168Write the diagram to: `{{AUTOSKILLIT_TEMP}}/arch-lens-repository-access/arch_diag_repository_access_{YYYY-MM-DD_HHMMSS}.md` (relative to the current working directory)169170After writing the diagram file, emit a structured output line:171172> **IMPORTANT:** Emit the structured output tokens as **literal plain text with no173> markdown formatting on the token names**. Do not wrap token names in `**bold**`,174> `*italic*`, or any other markdown. The adjudicator performs a regex match on the175> exact token name — decorators cause match failure.176177```178diagram_path = {absolute_path_to_diagram_file}179```180181---182183## Output Template184185```markdown186# Repository/Data Access Diagram: {System Name}187188**Lens:** Repository/Data Access (Data-Centric)189**Question:** How is data accessed?190**Date:** {YYYY-MM-DD}191**Scope:** {What was analyzed}192193## Repository Overview194195| Category | Count | Key Repositories |196|----------|-------|------------------|197| {category} | {N} | {names} |198199## Data Access Diagram200201```mermaid202%%{init: {'flowchart': {'nodeSpacing': 50, 'rankSpacing': 60, 'curve': 'basis'}}}%%203flowchart LR204 %% CLASS DEFINITIONS %%205 classDef cli fill:#1a237e,stroke:#7986cb,stroke-width:2px,color:#fff;206 classDef stateNode fill:#004d40,stroke:#4db6ac,stroke-width:2px,color:#fff;207 classDef handler fill:#e65100,stroke:#ffb74d,stroke-width:2px,color:#fff;208 classDef phase fill:#6a1b9a,stroke:#ba68c8,stroke-width:2px,color:#fff;209 classDef output fill:#00695c,stroke:#4db6ac,stroke-width:2px,color:#fff;210 classDef integration fill:#c62828,stroke:#ef9a9a,stroke-width:2px,color:#fff;211 classDef newComponent fill:#2e7d32,stroke:#81c784,stroke-width:2px,color:#fff;212213 subgraph Callers ["CALLERS"]214 CALLER1["Handler/Service<br/>━━━━━━━━━━<br/>Business logic"]215 end216217 subgraph Factory ["REPOSITORY FACTORY"]218 direction TB219 FAC["RepositoryFactory<br/>━━━━━━━━━━<br/>Dependency injection"]220 SCOPE["Scoping<br/>━━━━━━━━━━<br/>Context management"]221 end222223 subgraph Repositories ["REPOSITORIES"]224 direction TB225 REPO1["EntityRepository<br/>━━━━━━━━━━<br/>CRUD methods"]226 BASE["BaseRepository<T><br/>━━━━━━━━━━<br/>Generic CRUD"]227 end228229 subgraph Conversion ["FORMAT CONVERSION"]230 direction TB231 ADAPTER["Adapters/DTOs<br/>━━━━━━━━━━<br/>Serialization"]232 end233234 subgraph Storage ["DATABASE"]235 direction TB236 DB[("Table/Collection<br/>━━━━━━━━━━<br/>Persistent storage")]237 end238239 %% FLOW %%240 CALLER1 --> FAC241 FAC --> SCOPE242 SCOPE --> REPO1243 BASE --> REPO1244 REPO1 --> ADAPTER245 ADAPTER --> DB246247 %% CLASS ASSIGNMENTS %%248 class CALLER1 cli;249 class FAC,SCOPE phase;250 class REPO1 newComponent;251 class BASE stateNode;252 class ADAPTER handler;253 class DB integration;254```255256**Color Legend:**257| Color | Category | Description |258|-------|----------|-------------|259| Dark Blue | Callers | Services/handlers that use repositories |260| Purple | Factory | Repository construction and scoping |261| Green | Repositories | Repository implementations |262| Teal | Base | Generic base repository |263| Orange | Conversion | Format adapters/DTOs |264| Red | Storage | Database tables/collections |265266## Repository Categories267268| Category | Count | Key Repositories |269|----------|-------|------------------|270| {category} | {N} | {list} |271272## Key Query Patterns273274| Pattern | Repository Method | Use Case |275|---------|------------------|----------|276| {pattern} | {method} | {use case} |277278## Entity Relationships279280| Parent | Child | Cardinality | FK |281|--------|-------|-------------|-----|282| {parent} | {child} | {1:N/1:1} | {fk field} |283```284285---286287## Pre-Diagram Checklist288289Before creating the diagram, verify:290291- [ ] LOADED `/autoskillit:mermaid` skill using the Skill tool292- [ ] Using ONLY classDef styles from the mermaid skill (no invented colors)293- [ ] Diagram will include a color legend table294295---296297## Related Skills298299- `/autoskillit:make-arch-diag` - Parent skill for lens selection300- `/autoskillit:mermaid` - MUST BE LOADED before creating diagram301- `/autoskillit:arch-lens-data-lineage` - For data flow view302- `/autoskillit:arch-lens-c4-container` - For storage container view