# §1. Project Overview

Project    : {{PROJECT_NAME}}
Language   : {{LANGUAGE}}          # vd: Java 17 / TypeScript / C# / Go
Framework  : {{FRAMEWORK}}         # vd: Spring Boot 3.2 / Angular 17 / .NET 8
Build      : {{BUILD_COMMAND}}     # vd: mvn clean install -DskipTests / dotnet build / ng build
Test       : {{TEST_COMMAND}}      # vd: mvn test / dotnet test / ng test
Domains    : {{COMMA_SEPARATED_DOMAINS}}

# §2. Architecture

style: "{{ARCH_STYLE}}"  # vd: Layered / Clean / Hexagonal / Component-based

layers: "{{LAYER_STACK}}"
# Ví dụ:
#   Java/Spring:  Controller → Facade → Service → Repository
#   .NET Clean:   Presentation → Application → Domain → Infrastructure
#   Angular:      Component → Service → HTTP Client → Backend API
#   Go:           Handler → UseCase → Repository → Domain

rules:
  - "{{ARCH_RULE_1}}"  # vd: Controller không được chứa business logic
  - "{{ARCH_RULE_2}}"  # vd: Service sở hữu ranh giới transaction
  - "{{ARCH_RULE_3}}"  # vd: Repository không được gọi service

# Chiều phụ thuộc giữa các layer (layer trong không được phụ thuộc layer ngoài):
# {{OUTER_LAYER}} → {{MIDDLE_LAYER}} → {{INNER_LAYER}}

# §3. Coding Standards

naming:
  classes: "{{CLASS_NAMING}}"        # vd: PascalCase / PascalCase+Suffix
  methods: "{{METHOD_NAMING}}"       # vd: camelCase / PascalCase
  packages: "{{PACKAGE_NAMING}}"     # vd: lowercase / lowercase.snake_case
  files: "{{FILE_NAMING}}"           # vd: PascalCase.java / kebab-case.ts

patterns:
  response_wrapper: "{{RESPONSE_WRAPPER}}"  # vd: ApiResponse<T> / Result<T> / IActionResult
  mapping: "{{MAPPING_LIBRARY}}"            # vd: MapStruct / AutoMapper / manual
  exception_base: "{{BASE_EXCEPTION}}"      # vd: ResourceNotFoundException / DomainException

forbidden:
  - "Magic number — dùng hằng số có tên"
  - "Lệnh debug print trong code production"
  - "{{PROJECT_SPECIFIC_FORBIDDEN_PATTERN}}"

# §4. API Conventions

versioning: "{{API_VERSIONING}}"     # vd: tiền tố /v1/ / theo header / query param
auth: "{{AUTH_MECHANISM}}"           # vd: JWT Bearer / OAuth2 / API Key

http_status:
  get_list:    200   # danh sách phân trang hoặc đầy đủ
  get_single:  200
  create:      201
  update:      200
  delete:      204
  bad_request: 400
  unauthorized: 401
  forbidden:   403
  not_found:   404
  server_error: 500

error_response_format: |
  {
    "code": "ERROR_CODE",
    "message": "Human readable message",
    "details": {}   // optional field-level errors
  }

# §5. Error Handling

not_found_exception: "{{NOT_FOUND_EXCEPTION_CLASS}}"  # vd: ResourceNotFoundException
validation_exception: "{{VALIDATION_EXCEPTION_CLASS}}" # vd: ValidationException
domain_exception: "{{DOMAIN_EXCEPTION_CLASS}}"         # vd: DomainException / BusinessRuleViolationException

global_handler: "{{GLOBAL_EXCEPTION_HANDLER}}"  # vd: @ControllerAdvice / ExceptionHandlerMiddleware

rules:
  - "Không bao giờ nuốt exception âm thầm"
  - "Log ở mức error kèm full stack trace cho lỗi 5xx"
  - "{{PROJECT_SPECIFIC_ERROR_RULE}}"

# §6. Testing Standards

unit_test_framework: "{{UNIT_TEST_FW}}"        # vd: JUnit 5 + Mockito / xUnit + Moq / Jest
integration_test_framework: "{{IT_TEST_FW}}"   # vd: Spring Boot Test / WebApplicationFactory

coverage_targets:
  unit: "{{UNIT_COVERAGE_PCT}}%"          # vd: 80%
  integration: "{{IT_COVERAGE_PCT}}%"     # vd: phủ các flow chính

naming_pattern: "{{TEST_METHOD_NAMING}}"  # vd: methodName_whenCondition_shouldExpectation

rules:
  - "Unit test chỉ mock các dependency trực tiếp"
  - "Integration test phủ happy path + các luồng lỗi chính"
  - "Mọi scenario trong .feature phải có test tương ứng"

# §7. Git Conventions

branch_feature: "feature/{{TICKET_PREFIX}}-{N}-{slug}"
branch_fix:     "fix/{{TICKET_PREFIX}}-{N}-{slug}"
branch_chore:   "chore/{slug}"

commit_feature: "feat({{TICKET_PREFIX}}-{N}): {description}"
commit_fix:     "fix({{TICKET_PREFIX}}-{N}): {description}"
commit_chore:   "chore: {description}"
commit_docs:    "docs: {description}"

pr_title: "{{TICKET_PREFIX}}-{N}: {feature name}"
pr_requires_review: true
pr_branch_protection: "{{BASE_BRANCH}}"  # vd: main / develop
