Understand Codebase
Onboarding Workflow (Yeni Developer)
Hizli Baslangic (5 Dakika)
1. Tech stack tespit:
ls package.json go.mod pyproject.toml tsconfig.json Cargo.toml manage.py
2. Proje yapisi:
tldr tree . --depth 2
3. Entry point'leri bul:
tldr structure . --lang <detected-lang>
4. README/docs oku:
cat README.md CONTRIBUTING.md docs/
5. CI/CD kontrol:
ls .github/workflows/ .gitlab-ci.yml Jenkinsfile Dockerfile
Detayli Kesif (30 Dakika)
1. Architecture overview:
tldr arch src/
2. Import/dependency graph:
tldr calls src/
3. Test yapisi:
tldr tree . --ext .test.ts,.spec.ts,.test.py,_test.go
4. Config dosyalari:
ls *.config.* .env.example docker-compose.yml
5. Data modelleri:
Grep "interface|type|class|struct|model" --type ts/py/go
Codebase Overview Olusturma
Otomatik Overview
# 1. Dosya dagilimi
tldr tree . | wc -l # toplam dosya
tldr tree . --ext .ts,.tsx # TypeScript dosyalari
tldr tree . --ext .test.ts # Test dosyalari
# 2. Kod yapisi
tldr structure src/ --lang typescript
# Fonksiyonlar, class'lar, export'lar
# 3. Mimari katmanlar
tldr arch src/
# Entry (controller/handler) > Middle (service) > Leaf (util)
# 4. Dead code
tldr dead src/ --entry main,test_
Overview Template
# Project: <name>
## Tech Stack
- Language: <lang> <version>
- Framework: <framework> <version>
- Database: <db>
- CI/CD: <tool>
## Architecture
- Pattern: <MVC|Clean|Hexagonal|Monolith|Microservice>
- Entry points: <files>
- Layers: <controller → service → repository → model>
## Key Directories
- src/ → Kaynak kod
- tests/ → Test dosyalari
- config/ → Konfigürasyon
- scripts/ → Yardimci scriptler
- docs/ → Dokumantasyon
## Key Files
- <entry-file> → Uygulama entry point
- <config-file> → Ana konfigürasyon
- <schema-file> → Data modelleri
- <route-file> → API routing
## Data Flow
<request → middleware → controller → service → repository → database>
## External Dependencies
- <key-dep-1>: <purpose>
- <key-dep-2>: <purpose>
Architecture Dokumentasyonu
Katman Tespiti
# tldr arch ile otomatik tespit
tldr arch src/
# Cikti: entry_layer, middle_layer, leaf_layer, circular_deps
# Manuel tespit: import yonlerini takip et
tldr calls src/ --depth 3
Mimari Patern Tespiti
| Ipucu | Patern | |-------|--------| | controllers/, routes/, handlers/ | MVC / REST API | | domain/, application/, infrastructure/ | Clean Architecture | | ports/, adapters/ | Hexagonal | | services/, modules/ | Modular Monolith | | packages/, apps/ | Monorepo | | pages/, app/ (Next.js) | File-based routing | | resolvers/, schema/ | GraphQL | | commands/, queries/, events/ | CQRS | | aggregates/, entities/, value-objects/ | DDD |
Architectural Decision Records (ADR)
# codebase-memory MCP ile ADR yonetimi
mcp_codebase_memory.manage_adr({
action: "create",
title: "Use PostgreSQL for primary database",
status: "accepted",
context: "Need ACID transactions, complex queries",
decision: "PostgreSQL 16 with pgvector extension",
consequences: "Need DBA expertise, managed service cost"
})
# ADR listele
mcp_codebase_memory.manage_adr({ action: "list" })
Key File Identification
Otomatik Tespit
# Entry point'ler
tldr structure . --lang typescript | grep -i "main\|index\|app\|server"
# Konfigürasyon
ls -la *.config.* .env* tsconfig.json package.json
# Schema/Model
tldr search "schema\|model\|entity\|interface" src/ --lang typescript
# Routing
tldr search "router\|route\|endpoint\|controller" src/
Kritik Dosya Kategorileri
| Kategori | Nasil Bul | Neden Onemli | |----------|-----------|--------------| | Entry point | main.ts, index.ts, app.ts | Uygulamanin baslangici | | Config | .config., .env | Ortam ayarlari | | Schema/Model | models/, schema/, types/ | Data yapisi | | Routes | routes/, controllers/ | API surface | | Middleware | middleware/ | Cross-cutting concerns | | Database | migrations/, seeds/ | DB yapisi | | Tests | .test., .spec. | Test coverage | | CI/CD | .github/workflows/ | Build/deploy | | Docker | Dockerfile, docker-compose | Container config |
Dependency Mapping
Package Dependency Analizi
# Node.js
cat package.json | jq '.dependencies, .devDependencies'
# Python
cat requirements.txt # veya pyproject.toml
pip list --outdated
# Go
cat go.mod
go list -m all
# Rust
cat Cargo.toml
Internal Dependency Graph
# Dosyalar arasi import iliskileri
tldr calls src/ --depth 2
# Spesifik dosyanin import'lari
tldr imports src/services/auth.ts
# Kim bu modulu import ediyor?
tldr importers auth src/
# Impact analizi (refactoring oncesi)
tldr impact processOrder src/ --depth 3
Dependency Risk Analizi
| Risk | Kontrol | Arac | |------|---------|------| | CVE/vulnerability | npm audit / pip audit | snyk, dependabot | | Outdated | major version farki | npm outdated | | Unmaintained | Son commit 1+ yil | GitHub API | | License risk | GPL in commercial | license-checker | | Size bloat | Bundle size | bundlephobia |
Data Flow Tracing
Request-Response Flow
# Fonksiyon cagri zinciri
tldr calls src/ --depth 4
# Spesifik fonksiyonun cagri yolu
tldr trace_call_path src/ fromFunction toFunction
# Data flow analizi
tldr dfg src/services/order.ts processOrder
# Program slice (spesifik satiri etkileyen her sey)
tldr slice src/services/order.ts processOrder 42
Data Flow Mapping Template
USER INPUT
→ Validation (middleware/schema)
→ Controller (routing, request parse)
→ Service (business logic)
→ Repository (data access)
→ Database (persistence)
→ Response (serialization)
→ USER OUTPUT
Side effects:
→ Queue (async processing)
→ Cache (read optimization)
→ External API (3rd party)
→ Event bus (pub/sub)
State Management Flow (Frontend)
User Action
→ Event Handler (onClick, onChange)
→ State Update (useState, dispatch, store.set)
→ Re-render (component tree)
→ Side Effect (useEffect, subscription)
→ API Call (fetch, axios)
→ State Update (response)
→ Re-render
API Surface Discovery
REST API Endpoints
# Route tanimlarini bul
Grep "router\.(get|post|put|patch|delete)\|app\.(get|post|put|patch|delete)" src/
# Express/Fastify route'lar
tldr search "route\|endpoint" src/ --lang typescript
# OpenAPI spec varsa
cat openapi.yaml # veya swagger.json
GraphQL Schema
# Schema tanimlarini bul
Grep "type Query|type Mutation|type Subscription" src/
# Resolver'lari bul
tldr search "resolver\|Resolver" src/
API Dokumantasyonu
Her endpoint icin:
- Method + Path: GET /api/users/:id
- Auth: Bearer token / API key / Public
- Request: Query params, body schema
- Response: Success (200), Error (4xx, 5xx)
- Rate limit: X req/min
Test Coverage Mapping
Test Yapisi Analizi
# Test dosyalarini bul
tldr tree . --ext .test.ts,.spec.ts,.test.py,_test.go
# Test/source orani
echo "Source files:" && tldr tree src/ --ext .ts,.tsx | wc -l
echo "Test files:" && tldr tree . --ext .test.ts,.spec.ts | wc -l
# Hangi dosyalarin testi YOK
tldr dead src/ --entry test_ # test'lerden cagrilmayan fonksiyonlar
Coverage Raporu
# Node.js
npx jest --coverage --coverageReporters=text-summary
# Python
pytest --cov=src --cov-report=term-missing
# Go
go test -coverprofile=coverage.out ./...
go tool cover -func=coverage.out
Test Gap Analizi
| Dosya/Modul | Unit Test | Integration | E2E | Risk | |-------------|-----------|-------------|-----|------| | Auth service |