⚙️ Software✍️ Khoa📅 20/04/2026☕ 3 phút đọc

Software Architecture: Tổng quan

Section này tập trung vào cách thiết kế hệ thống ở cấp độ code — không phải distributed systems (đã có ở software/distributed-systems/), mà là cách tổ chức code, tách biệt concerns, và đưa ra quyết định kiến trúc.

Độ sâu: Advanced — Edge cases, trade-offs, real-world pitfalls từ kinh nghiệm thực chiến.

Các topic

File Nội dung
ddd-core-concepts.md Domain-Driven Design: Ubiquitous Language, Bounded Context, Aggregate, Entity, Value Object, Repository, Domain Events
clean-and-hexagonal.md Clean Architecture & Hexagonal: Layering (Domain → Application → Interface → Infrastructure), Ports & Adapters, project structure, dependency rule
design-principles.md SOLID + DRY/YAGNI: S/O/L/I/D principles, when to break them, Go-specific interface design, composition over inheritance
interview-and-big-picture.md Architecture Decisions: Monolith vs Microservices, evaluation framework, ADR template, common interview Q&A, consistency models, tech debt management
decomposition-and-migration.md System Decomposition: Strangler fig in depth, anti-corruption layer, seam identification với DDD, shared database migration, organizational pre-conditions
saas/ SaaS Architecture: Multi-tenancy models (silo/pool/bridge), noisy neighbor, tenant management service, entitlements, usage metering

Khi nào cần kiến thức này?

  • System design interview — câu hỏi về cấu trúc code, layering, dependency management
  • Code review — nhận ra vi phạm design principles
  • Onboarding dự án mới — hiểu tại sao code được tổ chức theo cách đó
  • Tech lead / architect role — đưa ra quyết định kiến trúc có documented reasoning
  • Refactoring legacy code — strategy để incrementally improve codebase

Learning Path

Từng bước (không nhất thiết phải theo trình tự):

  1. Foundation: ddd-core-concepts.md — Hiểu business modeling từ DDD
  2. Structure: clean-and-hexagonal.md — Cách organize code thành layers
  3. Quality: design-principles.md — Design principles để keep code clean
  4. Strategy: interview-and-big-picture.md — Quyết định architecture ở scale lớn

Hoặc đọc ngang nếu bạn đã familiar với concepts — mỗi file độc lập, chứa go-to reference + Go code examples.

Real-world Mindset 🎯

Architecture ≠ "Design patterns" hoặc "Clean code"
Architecture = Decision-making framework để quản lý complexity khi hệ thống phát triển
  • Không có "perfect architecture" — chỉ có "right trade-off cho constraints hiện tại"
  • Decisions phải được document (ADR) để future-self + team hiểu "why"
  • Sẵn sàng refactor khi constraints thay đổi, nhưng incremental > big-bang rewrite
  • SOLID/DDD không là dogma — nó là tools, biết khi nào dùng khi nào skip

Cheat Sheet: Khi Nghi Ngờ

Tình huống Hướng dẫn
"Cơ cơ mã bắt đầu rối" Áp dụng DDD: identify bounded contexts, rõ ràng hóa business rules
"Khó để test / modify code" Check SOLID principles: SRP violated? Dependencies too tight?
"Không biết hệ thống scale như nào" Tham khảo Monolith vs Microservices framework
"Team không đồng ý về cách code" Dùng ADR template để document decisions, align team
"Onboarding newbie mất 2 tuần" Project structure không theo Clean Architecture?