This directory collects key engineering concepts and patterns we've adopted. It serves as a "Knowledge Base" for the team.
ποΈ 1. Architecture Patterns
The Gateway Pattern (@apps/gateway)
- Concept: A single entry point for all external traffic.
- Why: Centralizes Cross-Cutting Concerns (Auth, Rate Limiting, CORS).
- Security: Internal services (Manager, Blog) are hidden. They trust the Gateway via a shared secret (
x-gateway-key).
Monorepo "App as Consumer"
- Concept: Next.js Apps (
apps/*) should be thin wrappers. - Why: Business logic belongs in
packages/*so it can be reused (e.g., by a CLI or Worker). - Rule:
apps/seller-dashboardnever imports fromapps/manager.
ποΈ 2. Database Strategy
Hybrid Tenancy
- Concept: Most tenants share a schema (Row-Level Security), but Enterprise tenants get their own Database.
- Why: Balances cost (Shared) with performance/compliance (Isolated).
- Implementation: A
database_configcolumn in thetenantstable routes the connection.
π§ 3. Coding Standards
Conventional Commits
- Concept: Standardized commit messages (
feat:,fix:,chore:). - Why: Allows automated semantic versioning and changelog generation.
Service Isolation
- Concept: Services share nothing (no shared code, no shared DB tables).
- Why: Allows services to evolve independently without breaking each other.