Loading...
Loading...
Use when designing system architecture, choosing databases, structuring projects, selecting tech stacks, designing APIs, planning caching strategies, or organizing a codebase for scale
npx skill4agent add iankiku/forwward-teams architect| Pattern | When to Use | When to Avoid |
|---|---|---|
| Monolith | <10 engineers, single product, moving fast | Multiple teams needing independent deploys |
| Modular monolith | Growing team, want boundaries without infra cost | Need independent scaling per service |
| Microservices | 20+ engineers, distinct domains, independent scaling | Small team, early stage, unclear boundaries |
| Serverless | Event-driven, spiky traffic, want zero ops | Long-running processes, cost-sensitive at scale |
| Event-driven | Async workflows, decoupled systems, audit trails | Simple CRUD, real-time requirements |
| Need | Database | Why |
|---|---|---|
| General purpose, relational | PostgreSQL | ACID, JSON support, extensions, ecosystem |
| Key-value, caching | Redis / Valkey | Sub-ms reads, TTL, pub/sub |
| Document store, flexible schema | MongoDB | Rapid prototyping, nested documents |
| Full-text search | PostgreSQL FTS or Meilisearch | Postgres built-in is good enough until it isn't |
| Time-series | TimescaleDB (Postgres extension) | Keep one database engine |
| Graph relationships | PostgreSQL with recursive CTEs | Don't add Neo4j unless graph is the core product |
| Vector / embeddings | pgvector (Postgres extension) | Same — keep one database |
src/
├── app/ # Next.js app router — pages and layouts
│ ├── (auth)/ # Route groups for auth pages
│ ├── (dashboard)/ # Route groups for app pages
│ └── api/ # API routes
├── lib/ # Shared utilities, config, constants
│ ├── db/ # Database client, schema, migrations
│ ├── auth/ # Auth config and helpers
│ └── utils/ # Pure utility functions
├── services/ # Business logic — one file per domain
│ ├── user.service.ts
│ └── billing.service.ts
├── components/ # React components
│ ├── ui/ # Primitives (button, input, card)
│ └── features/ # Feature-specific composites
└── types/ # Shared TypeScript typessrc/
├── api/ # Route handlers
│ ├── v1/ # Versioned endpoints
│ └── deps.py # Shared dependencies (auth, db session)
├── core/ # Config, security, constants
├── models/ # SQLAlchemy models
├── schemas/ # Pydantic request/response schemas
├── services/ # Business logic — one file per domain
├── repositories/ # Data access layer
└── tests/
├── unit/
└── integration/user.service.tsgetUserById.tsupdateUser.ts| Decision | Default |
|---|---|
| Protocol | REST for CRUD, tRPC for type-safe full-stack, GraphQL only if multiple clients need different shapes |
| Versioning | URL path: |
| Auth | Bearer token in Authorization header |
| Pagination | Cursor-based for feeds, offset for admin tables |
| Errors | |
| Rate limiting | 100 req/min default, lower for auth endpoints |
| Layer | Tool | TTL | Use When |
|---|---|---|---|
| Browser | Cache-Control headers | Varies | Static assets, API responses |
| CDN | Cloudflare / Vercel Edge | 1-60 min | Public pages, images |
| Application | Redis / in-memory | 5-60 min | Expensive queries, session data |
| Database | Materialized views | Refresh on write | Aggregations, dashboards |
| Users | Likely Bottleneck | Fix |
|---|---|---|
| 0-1K | Nothing | Don't optimize |
| 1K-10K | Database queries | Add indexes, optimize N+1s |
| 10K-100K | Database connections | Connection pooling (PgBouncer) |
| 100K-1M | Read throughput | Add Redis cache layer |
| 1M+ | Write throughput | Read replicas, sharding, queue writes |