Repo Map SSOT
Overview
Single Source of Truth (SSOT) สำหรับ repository structure ที่ให้ AI และคนเข้าใจ codebase ได้ทันที รวม folder structure, key files, และ architectural decisions ในที่เดียว
Why This Matters
- Quick orientation: รู้ว่าอะไรอยู่ตรงไหนทันที
- AI efficiency: AI ไม่ต้อง explore ซ้ำทุกครั้ง
- Onboarding: คนใหม่เข้าใจ repo structure เร็ว
- Consistency: ทุกคนมี mental model เดียวกัน
Core Concepts
1. Structure Overview
- สรุป “โครงบนสุด” ของ repo ให้เห็นภาพใน 30 วินาที (src/tests/docs/scripts/config)
- ระบุว่าเป็น monorepo หรือ single service และ boundaries อยู่ตรงไหน
2. Key Directories
- เขียน “purpose” ของแต่ละโฟลเดอร์ใหญ่เป็น 1–2 บรรทัด (อะไรอยู่ในนั้น / อะไรไม่ควรอยู่)
- ใส่ ownership ถ้ามี (ทีม/owner) เพื่อช่วย routing PR/review
3. Entry Points
- ระบุไฟล์เริ่มต้น: server bootstrap, routes, DI/container, job runners, consumers
- ระบุ “happy path”: ถ้าจะตาม flow request เข้า service ต้องเริ่มอ่านที่ไหน
4. Configuration Files
- บอกที่อยู่ของ env/config และลำดับความสำคัญ (สอดคล้องกับ config conventions)
- list config files ที่ทำให้ deploy แตกต่าง (docker, k8s, terraform, workflows)
5. Domain Boundaries
- ระบุ domain modules และ dependency direction (domain ไม่ควรรู้ infra)
- ระบุ shared contracts/types และวิธี versioning/backward-compat
6. Shared Code
- รวม “จุดรวม” ของ shared libs และข้อห้าม (เช่น ห้าม import จาก app layer)
- อธิบาย pattern ของ barrel exports (ใช้/ไม่ใช้) เพื่อลด confusion
7. External Integrations
- list integrations สำคัญ (payment, auth, email, analytics) + config location + docs link
- ระบุ webhook/queues/topics ที่เกี่ยวข้อง (ถ้ามี)
8. Build & Deploy
- ระบุ scripts ที่ต้องรู้: build/test/lint/migrate/seed
- ระบุ pipeline/deploy target (GitHub Actions, k8s, ECS, serverless) และไฟล์ config ที่เกี่ยวข้อง
Quick Start
# Create/maintain `REPO.md` at repo root:
# - 30s overview (tree + key entry points)
# - Where configs live (env, secrets, deploy)
# - Domain boundaries + owners
# - Links to deeper docs (architecture, API, runbooks)
Production Checklist
Repo Map Template
# REPO.md - Repository Map
> Last updated: 2024-01-15 | Auto-generated: Yes
## Quick Overview
[Project name] - [One sentence description]
## Structure
```
├── src/ # Application source code
│ ├── api/ # HTTP/REST endpoints
│ ├── domain/ # Business logic, entities
│ ├── infrastructure/ # Database, external services
│ └── shared/ # Cross-cutting utilities
├── tests/ # Test files (mirrors src/)
├── docs/ # Documentation
├── scripts/ # Build, deploy, utility scripts
├── config/ # Environment configs
└── [key files at root]
```
## Entry Points
| File | Purpose |
|------|---------|
| `src/index.ts` | Application bootstrap |
| `src/api/routes.ts` | API route definitions |
| `package.json` | Dependencies, scripts |
## Key Directories
### `src/api/`
HTTP layer: routes, controllers, middleware
- Owner: @backend-team
- Related: OpenAPI spec at `docs/api.yaml`
### `src/domain/`
Business logic, domain models, services
- Owner: @domain-team
- Pattern: Domain-Driven Design
### `src/infrastructure/`
External integrations: DB, cache, queues, APIs
- Owner: @infra-team
## Configuration
| File | Purpose |
|------|---------|
| `.env.example` | Required environment variables |
| `config/default.ts` | Default configuration |
| `tsconfig.json` | TypeScript settings |
## External Dependencies
| System | Purpose | Config Location |
|--------|---------|-----------------|
| PostgreSQL | Primary database | `src/infrastructure/db/` |
| Redis | Caching, queues | `src/infrastructure/cache/` |
| Stripe | Payments | `src/infrastructure/stripe/` |
## Build & Deploy
- Build: `npm run build`
- Test: `npm test`
- Deploy: GitHub Actions → AWS ECS
## Quick Commands
```bash
npm run dev # Start dev server
npm run test # Run tests
npm run lint # Lint code
npm run build # Build for production
```
## Related Docs
- [Architecture](./docs/architecture.md)
- [API Reference](./docs/api.md)
- [Development Guide](./docs/development.md)
Anti-patterns
- No map: ต้อง explore ทุกครั้ง
- Outdated map: ไม่ตรงกับ reality
- Too detailed: เป็น full docs แทน overview
- Missing entry points: ไม่รู้จะเริ่มจากไหน
Auto-Generation
# Generate repo map from folder structure
find . -type d -name "node_modules" -prune -o -type f -print | \
grep -E '\.(ts|js|py|go)$' | \
tree --fromfile > REPO_STRUCTURE.txt
Integration Points
- IDE plugins (file tree)
- Documentation generators
- AI context loaders
- CI checks (verify map is current)
Further Reading
1---2name: repo-map-ssot3description: Single source of truth for repository structure and entry points, including key directories, domain boundaries, shared code, integrations, and build/deploy references4---5
6# Repo Map SSOT
7
8## Overview
9
10Single Source of Truth (SSOT) สำหรับ repository structure ที่ให้ AI และคนเข้าใจ codebase ได้ทันที รวม folder structure, key files, และ architectural decisions ในที่เดียว
11
12## Why This Matters
13
14- **Quick orientation**: รู้ว่าอะไรอยู่ตรงไหนทันที
15- **AI efficiency**: AI ไม่ต้อง explore ซ้ำทุกครั้ง
16- **Onboarding**: คนใหม่เข้าใจ repo structure เร็ว
17- **Consistency**: ทุกคนมี mental model เดียวกัน
18
19---
20
21## Core Concepts
22
23### 1. Structure Overview
24
25- สรุป “โครงบนสุด” ของ repo ให้เห็นภาพใน 30 วินาที (src/tests/docs/scripts/config)
26- ระบุว่าเป็น monorepo หรือ single service และ boundaries อยู่ตรงไหน
27
28### 2. Key Directories
29
30- เขียน “purpose” ของแต่ละโฟลเดอร์ใหญ่เป็น 1–2 บรรทัด (อะไรอยู่ในนั้น / อะไรไม่ควรอยู่)
31- ใส่ ownership ถ้ามี (ทีม/owner) เพื่อช่วย routing PR/review
32
33### 3. Entry Points
34
35- ระบุไฟล์เริ่มต้น: server bootstrap, routes, DI/container, job runners, consumers
36- ระบุ “happy path”: ถ้าจะตาม flow request เข้า service ต้องเริ่มอ่านที่ไหน
37
38### 4. Configuration Files
39
40- บอกที่อยู่ของ env/config และลำดับความสำคัญ (สอดคล้องกับ config conventions)
41- list config files ที่ทำให้ deploy แตกต่าง (docker, k8s, terraform, workflows)
42
43### 5. Domain Boundaries
44
45- ระบุ domain modules และ dependency direction (domain ไม่ควรรู้ infra)
46- ระบุ shared contracts/types และวิธี versioning/backward-compat
47
48### 6. Shared Code
49
50- รวม “จุดรวม” ของ shared libs และข้อห้าม (เช่น ห้าม import จาก app layer)
51- อธิบาย pattern ของ barrel exports (ใช้/ไม่ใช้) เพื่อลด confusion
52
53### 7. External Integrations
54
55- list integrations สำคัญ (payment, auth, email, analytics) + config location + docs link
56- ระบุ webhook/queues/topics ที่เกี่ยวข้อง (ถ้ามี)
57
58### 8. Build & Deploy
59
60- ระบุ scripts ที่ต้องรู้: build/test/lint/migrate/seed
61- ระบุ pipeline/deploy target (GitHub Actions, k8s, ECS, serverless) และไฟล์ config ที่เกี่ยวข้อง
62
63## Quick Start
64
65```markdown
66# Create/maintain `REPO.md` at repo root:
67# - 30s overview (tree + key entry points)
68# - Where configs live (env, secrets, deploy)
69# - Domain boundaries + owners
70# - Links to deeper docs (architecture, API, runbooks)
71```
72
73## Production Checklist
74
75- [ ] REPO.md exists at root
76- [ ] All major directories documented
77- [ ] Entry points clearly marked
78- [ ] Domain boundaries defined
79- [ ] Kept up-to-date (review quarterly)
80- [ ] Links to detailed docs
81
82## Repo Map Template
83
84````markdown
85# REPO.md - Repository Map
86
87> Last updated: 2024-01-15 | Auto-generated: Yes
88
89## Quick Overview
90[Project name] - [One sentence description]
91
92## Structure
93
94```
95├── src/ # Application source code
96│ ├── api/ # HTTP/REST endpoints
97│ ├── domain/ # Business logic, entities
98│ ├── infrastructure/ # Database, external services
99│ └── shared/ # Cross-cutting utilities
100├── tests/ # Test files (mirrors src/)
101├── docs/ # Documentation
102├── scripts/ # Build, deploy, utility scripts
103├── config/ # Environment configs
104└── [key files at root]
105```
106
107## Entry Points
108| File | Purpose |
109|------|---------|
110| `src/index.ts` | Application bootstrap |
111| `src/api/routes.ts` | API route definitions |
112| `package.json` | Dependencies, scripts |
113
114## Key Directories
115
116### `src/api/`
117HTTP layer: routes, controllers, middleware
118- Owner: @backend-team
119- Related: OpenAPI spec at `docs/api.yaml`
120
121### `src/domain/`
122Business logic, domain models, services
123- Owner: @domain-team
124- Pattern: Domain-Driven Design
125
126### `src/infrastructure/`
127External integrations: DB, cache, queues, APIs
128- Owner: @infra-team
129
130## Configuration
131| File | Purpose |
132|------|---------|
133| `.env.example` | Required environment variables |
134| `config/default.ts` | Default configuration |
135| `tsconfig.json` | TypeScript settings |
136
137## External Dependencies
138| System | Purpose | Config Location |
139|--------|---------|-----------------|
140| PostgreSQL | Primary database | `src/infrastructure/db/` |
141| Redis | Caching, queues | `src/infrastructure/cache/` |
142| Stripe | Payments | `src/infrastructure/stripe/` |
143
144## Build & Deploy
145- Build: `npm run build`
146- Test: `npm test`
147- Deploy: GitHub Actions → AWS ECS
148
149## Quick Commands
150```bash
151npm run dev # Start dev server
152npm run test # Run tests
153npm run lint # Lint code
154npm run build # Build for production
155```
156
157## Related Docs
158- [Architecture](./docs/architecture.md)
159- [API Reference](./docs/api.md)
160- [Development Guide](./docs/development.md)
161````
162
163## Anti-patterns
164
1651. **No map**: ต้อง explore ทุกครั้ง
1662. **Outdated map**: ไม่ตรงกับ reality
1673. **Too detailed**: เป็น full docs แทน overview
1684. **Missing entry points**: ไม่รู้จะเริ่มจากไหน
169
170## Auto-Generation
171
172```bash
173# Generate repo map from folder structure
174find . -type d -name "node_modules" -prune -o -type f -print | \
175 grep -E '\.(ts|js|py|go)$' | \
176 tree --fromfile > REPO_STRUCTURE.txt
177```
178
179## Integration Points
180
181- IDE plugins (file tree)
182- Documentation generators
183- AI context loaders
184- CI checks (verify map is current)
185
186## Further Reading
187
188- [Monorepo Tools](https://monorepo.tools/)
189- [Architecture Documentation](https://arc42.org/)