Bu doküman JUNIOR işi değildir. CariGo, "çalışsın yeter" projesi değil; domain-driven, test edilebilir, yarın SaaS’a evrilebilir, senior showcase bir backend mimarisiyle inşa edilir.
- ❌ God handler yok
- ❌ DB modeli = domain modeli değil
- ❌ Handler içinde iş kuralı YOK
- ❌ Float / money hack YOK
- ❌ "Sonra refactor" YOK
- Clean Architecture + DDD (pragmatik)
- Dependency Inversion
- Explicit boundaries
- Test-first domain
- Infrastructure detayları içeri sızamaz
┌─────────────────────────────┐
│ HTTP / UI Layer │ → Gin handlers, DTO
├─────────────────────────────┤
│ Application Layer │ → UseCases / Services
├─────────────────────────────┤
│ Domain Layer │ → Entities, Rules
├─────────────────────────────┤
│ Infrastructure Layer │ → SQLite, Repo impl
└─────────────────────────────┘Üst katman alt katmanı TANIMAZ Sadece interface görür.
carigo/
├── cmd/
│ └── api/
│ └── main.go # Sadece wiring
│
├── internal/
│ ├── domain/
│ │ ├── customer.go
│ │ ├── invoice.go
│ │ ├── payment.go
│ │ ├── allocation.go
│ │ ├── money.go # VALUE OBJECT
│ │ └── errors.go
│ │
│ ├── application/
│ │ ├── ports/ # Interfaces
│ │ │ ├── repositories.go
│ │ │ └── clock.go
│ │ ├── usecases/
│ │ │ ├── create_invoice.go
│ │ │ ├── register_payment.go
│ │ │ └── generate_statement.go
│ │ └── dto/
│ │
│ ├── infrastructure/
│ │ ├── persistence/
│ │ │ ├── sqlite/
│ │ │ │ ├── customer_repo.go
│ │ │ │ ├── invoice_repo.go
│ │ │ │ └── allocation_repo.go
│ │ └── clock/
│ │
│ ├── interfaces/
│ │ └── http/
│ │ ├── handlers/
│ │ ├── middleware/
│ │ └── router.go
│ │
│ └── bootstrap/
│ └── container.go # DI manual
│
├── migrations/
├── web/ # Iconic template
├── Dockerfile
├── docker-compose.yml
└── README.mdİş kuralları burada yaşar. DB, HTTP, JSON umurunda değil.
- amount_cents
- Safe add / subtract
- Negatif koruması
- Open / Partial / Paid state machine
- Allocation sonrası otomatik status değişimi
- Bir payment → N invoice
- Bir invoice ← N payment
- Overpayment desteklenir
❗ Allocation logic domain testleri olmadan geçmez
Use-case bazlı, senaryoya göre çalışan katman.
- Input: customer_id, amount, date
- Açık faturaları çek
- Allocation planı üret
- Allocation onay
- Transactional commit
- Mutabakat hesapla
- DTO üret
Domain’e asla iş kuralı sokmadan persistence.
- Transaction support
- Lock & concurrency safe
- Idempotent
- Startup’ta çalışır
Sadece translate eder. Request → UseCase → Response
- Validation burada
- Domain leak yok
- Iconic template
- Server-render
- Constructor injection
- Interface binding
- Domain: %100 unit
- UseCase: happy path + edge
- Repo: integration
- Allocation %100 doğru
- Domain testleri yeşil
- UI → gerçek senaryo çalışıyor
Bu mimariyle yapılan CariGo:
- CV’ye girer
- Senior interview’da anlatılır
- 2 yıl sonra çöpe atılmaz
🔥 Bu noktadan sonra bu bir oyuncak değil, mühendisliktir.