Technical Architecture Skill
Provides comprehensive guidance on technical architecture and implementation decisions for full-stack applications, from system design to technology selection.
Quick Decision Guide
What do you need?
System architecture / Tech stack selection
→ Use: THIS skill (overall architecture, technology choices)
Security architecture / Threat modeling
→ Use: security skill (security patterns, compliance, risk)
Code review / Code quality
→ Use: code-review skill (line-by-line review, vulnerabilities)
CI/CD pipeline / Infrastructure / Deployment
→ Use: devops skill (pipelines, containers, monitoring)
UI/UX design / Wireframes / Mockups
→ Use: ux skill (user interface design, user flows)
Product planning / Feature prioritization
→ Use: product-owner skill (roadmap, user stories, backlog)
Scope of This Skill
This Skill Covers (Technical Architecture)
- ✅ Overall system architecture and service design
- ✅ Component architecture and code organization
- ✅ API design (REST, GraphQL, tRPC)
- ✅ Database schema and data modeling
- ✅ State management patterns
- ✅ Technology stack selection
- ✅ Performance optimization strategy
- ✅ Caching architecture
- ✅ Scalability planning
- ✅ Third-party service integration
- ✅ Frontend and backend patterns
Use Other Skills For
- ❌ Security architecture → Use security skill
- ❌ Code security review → Use code-review skill
- ❌ CI/CD pipelines → Use devops skill
- ❌ Infrastructure setup → Use devops skill
- ❌ UI/UX design → Use ux skill
- ❌ Product planning → Use product-owner skill
This Skill Works With Other Skills
- security skill → Technical arch provides structure, security validates it
- code-review skill → Technical arch defines patterns, code-review ensures compliance
- devops skill → Technical arch chooses stack, devops deploys it
- ux skill → UX defines user needs, technical arch implements them
Pre-Planning Checklist
Before starting architectural planning, gather:
Requirements
Constraints
Context
References to Load
Architecture Decision Framework
1. Understand Requirements
Start with the pre-planning checklist above.
2. Choose Architecture Pattern
Based on your stage and needs, select the appropriate pattern:
For MVPs / New Products:
- Pattern 1: Serverless Full-Stack (fast iteration, low maintenance)
For Growing Products:
- Pattern 3: Hybrid (pragmatic middle ground)
For Established Products:
- Pattern 2: Containerized Microservices (full control, scale)
See "Common Architecture Patterns" section below for details.
3. Select Technologies
Consult reference files for detailed guidance:
- Frontend: references/frontend-patterns.md
- Backend: references/backend-patterns.md
- Database: references/database-design.md
- Deployment: references/deployment-systems.md
4. Validate with Other Skills
Security validation:
- Use security skill to threat model your architecture
- Review authentication/authorization patterns
- Validate data protection approach
Code organization validation:
- Use code-review skill to establish coding standards
- Define maintainability criteria
Deployment validation:
- Use devops skill to design CI/CD pipeline
- Plan infrastructure and monitoring
5. Evaluate Tradeoffs
Every architecture decision involves tradeoffs:
Complexity vs Flexibility:
- Simple solutions are easier to maintain
- Complex solutions offer more flexibility
- Rule: Choose simplest solution that meets requirements
Performance vs Development Speed:
- Optimizations take time to implement
- Premature optimization wastes effort
- Rule: Optimize based on actual bottlenecks, not assumptions
Cost vs Scale:
- Serverless: Low cost at low scale, expensive at high scale
- Dedicated servers: Higher baseline cost, cheaper at scale
- Rule: Choose based on expected traffic patterns
Vendor Lock-in vs Convenience:
- Managed services (Vercel, Supabase) are convenient but lock you in
- Self-hosted solutions give flexibility but require maintenance
- Rule: Consider long-term strategic value and exit cost
Build vs Buy:
- Building gives control but takes time
- Buying gets you features fast but adds dependencies
- Rule: Buy for non-core features, build for competitive advantages
Common Architecture Patterns
Pattern 1: Serverless Full-Stack (Recommended for MVPs)
Stack:
Frontend: Next.js on Vercel
Backend: Next.js API Routes (serverless functions)
Database: Supabase (PostgreSQL) or PlanetScale (MySQL)
Cache: Upstash Redis
File Storage: Vercel Blob or S3
Auth: NextAuth.js or Clerk
When to use:
- ✅ New products/MVPs
- ✅ Small to medium scale (< 1M requests/month)
- ✅ Want fast iteration
- ✅ Limited DevOps resources
- ✅ Unpredictable traffic
Pros:
- Fast to build and deploy (hours, not days)
- Scales automatically (0 → 10k users without changes)
- Low maintenance (no servers to manage)
- Pay only for usage (can start at $0/month)
- Excellent developer experience
Cons:
- Can get expensive at high scale (> $500/month at scale)
- Some vendor lock-in (but manageable)
- Cold start latency (200-500ms first request)
- Limited control over infrastructure
Migration path:
When you outgrow this, move to Pattern 3 (Hybrid)
Pattern 2: Containerized Microservices (For Scale)
Stack:
Frontend: Next.js in containers (ECS/Kubernetes)
Backend: Node.js services in containers
Database: RDS PostgreSQL with read replicas
Cache: ElastiCache Redis
File Storage: S3
Auth: Custom JWT implementation
Message Queue: SQS or RabbitMQ
When to use:
- ✅ Proven product with growth (> 100k users)
- ✅ Need more control over infrastructure
- ✅ Complex business logic requiring service isolation
- ✅ Team has DevOps skills
- ✅ Predictable high traffic
Pros:
- Full control over infrastructure
- Better cost at scale ($500-2k/month for high traffic)
- Service isolation (can scale services independently)
- Technology flexibility (mix languages)
- No cold starts
Cons:
- More complex setup (weeks of infrastructure work)
- Requires DevOps expertise
- Higher baseline costs (minimum ~$200/month)
- More maintenance burden
Migration path:
Usually don't migrate away, just add more services
Pattern 3: Hybrid (Pragmatic Middle Ground)
Stack:
Frontend: Next.js on Vercel (fast deploys, edge)
Backend: Dedicated API server on Railway/Render/Fly.io
Database: Managed PostgreSQL (Supabase/Neon/RDS)
Cache: Upstash Redis or managed Redis
File Storage: S3 or Cloudflare R2
Auth: NextAuth.js or custom
When to use:
- ✅ Outgrowing serverless costs (> $300/month)
- ✅ Not ready for full container complexity
- ✅ Need more backend flexibility (long-running tasks)
- ✅ Want good DX with more control
- ✅ Growing team (2-5 developers)
Pros:
- Better cost than pure serverless at scale
- More backend control (background jobs, websockets)
- Frontend still has great DX (Vercel)
- Easier than full microservices
- Good balance of control and convenience
Cons:
- More complex than pure serverless
- Need to manage API server
- Not as automated as Pattern 1
- Not as flexible as Pattern 2
Migration path:
Can move to Pattern 2 when you need service isolation
Technology Selection Guidelines
Frontend Framework
Next.js (Recommended):
- ✅ Full-stack capabilities (API routes, server actions)
- ✅ Excellent performance (SSR, ISR, SSG)
- ✅ Great DX with Vercel
- ✅ Large ecosystem and community
- ✅ Built-in optimizations (images, fonts, code splitting)
- Use for: Most web applications, SEO-critical sites
React SPA:
- ✅ Simple deployment (static files)
- ✅ Full client-side control
- ✅ Works well with any backend
- ❌ Worse SEO (unless prerendering)
- ❌ Slower initial load
- Use for: Admin dashboards, internal tools, web apps where SEO doesn't matter
React Native (Mobile):
- ✅ Code sharing with web (if using React)
- ✅ Native performance
- ✅ Single codebase for iOS + Android
- ❌ More complex than web
- ❌ App store deployment overhead
- Use for: Mobile apps (student/guardian apps for educational app)
Backend Language/Runtime
Node.js/TypeScript (Recommended):
- ✅ Share code and types with frontend
- ✅ Great ecosystem (npm packages)
- ✅ Fast development (familiar to frontend devs)
- ✅ Good for I/O-heavy tasks (APIs, databases)
- ✅ Async by default
- Use for: Most applications, especially full-stack TypeScript
Python:
- ✅ Excellent for ML/AI workloads
- ✅ Great data processing libraries (pandas, numpy)
- ✅ Good for scripts and background jobs
- ❌ Harder to share code with frontend
- ❌ Slower for I/O-heavy tasks
- Use for: ML pipelines, data processing, computer vision, background jobs
When to use both:
- Node.js for API server (user-facing)
- Python for background processing (ML, data analysis)
Database
PostgreSQL (Recommended for most apps):
- ✅ Excellent for relational data
- ✅ ACID transactions (data integrity)
- ✅ Rich query capabilities (joins, aggregations)
- ✅ JSON support for flexibility
- ✅ Great performance with proper indexing
- ✅ Mature ecosystem
- Use for: Educational apps, CRUDs, any structured data
MongoDB:
- ✅ Flexible schema (good for rapid prototyping)
- ✅ Fast writes
- ✅ Good for unstructured data
- ❌ Weaker consistency guarantees
- ❌ No joins (application-level only)
- Use for: Rapid prototyping, analytics, logs, event data
Decision matrix:
- Structured data with relationships? → PostgreSQL
- Need ACID transactions? → PostgreSQL
- Flexible/evolving schema? → MongoDB or PostgreSQL (with JSONB)
- Heavy analytics? → PostgreSQL (with indexing) or ClickHouse
For detailed schema design, consult references/database-design.md
State Management
React Query/SWR (Recommended for server state):
- ✅ Handles 90% of state needs
- ✅ Automatic caching and refetching
- ✅ Loading/error states handled
- ✅ Less boilerplate than Redux
- ✅ Optimistic updates
- Use for: API data, server state, any data from backend
Zustand (Recommended for client state):
- ✅ Simple API
- ✅ Small bundle size (<1KB)
- ✅ No boilerplate
- ✅ TypeScript support
- ✅ No context provider needed
- Use for: Global UI state, user preferences, theme, modals
Context API (Built-in):
- ✅ No dependencies
- ✅ Good for simple state
- ❌ Can cause unnecessary re-renders
- ❌ Verbose for complex state
- Use for: Simple global state (theme, user info)
Redux:
- ✅ Powerful debugging (DevTools)
- ✅ Middleware ecosystem
- ✅ Time-travel debugging
- ❌ More boilerplate
- ❌ Steeper learning curve
- Use for: Very complex state, need time-travel debugging
Rule of thumb:
- Server data → React Query/SWR
- Global UI state → Zustand
- Simple context → Context API
- Complex state machine → Redux or XState
Architecture Review Checklist
When reviewing or planning architecture, verify:
System Design
Scalability
Performance
Maintainability
Developer Experience
Security (High-Level - Delegate to security skill)
Testing (High-Level - Delegate to code-review skill)
Deployment (High-Level - Delegate to devops skill)
Best Practices Summary
Code Organization
- Feature-based structure over type-based
✅ Good: features/assignments/, features/students/
❌ Bad: components/, hooks/, utils/, services/
- Colocate related code (components, hooks, styles together)
- Keep components small (< 200 lines, single responsibility)
- Use absolute imports (
@/components vs ../../../components)
- Separate business logic from UI (custom hooks, service layer)
Performance
- Code splitting for routes (automatic in Next.js)
- React.memo for expensive components
- Optimize images (Next.js Image component, WebP format)
- Database indexes for frequent queries
- Cache expensive operations (React Query, Redis)
- Lazy load heavy components
- Debounce/throttle expensive operations (search, scroll)
API Design
- RESTful conventions (GET/POST/PUT/DELETE, proper status codes)
- Consistent naming (camelCase for JSON, snake_case for DB)
- Versioning (/api/v1/)
- Pagination for collections (limit/offset or cursor-based)
- Error handling (consistent error format)
- Rate limiting (prevent abuse)
- Documentation (OpenAPI/Swagger)
Database Design
- Normalize to avoid redundancy (usually 3NF)
- Index frequently queried fields
- Foreign keys for referential integrity
- Migrations for schema changes
- Soft deletes for important data (deleted_at column)
- Timestamps (created_at, updated_at) on all tables
Integration with Other Skills
With security Skill
Technical Skill: Designs system architecture
↓
Identifies integration points
↓
security Skill: Reviews security architecture
↓
Identifies security requirements
↓
Technical Skill: Incorporates security controls
↓
security Skill: Validates implementation
Example workflow:
- You: "Design authentication system for student/teacher app"
- Technical skill: Recommends NextAuth.js with JWT, session strategy
- security skill: Reviews JWT storage, session management, threat model
- Technical skill: Updates architecture based on security recommendations
With code-review Skill
Technical Skill: Defines architecture patterns
↓
Sets coding standards
↓
code-review Skill: Reviews code against patterns
↓
Identifies deviations and issues
↓
Technical Skill: Updates patterns if needed
Example workflow:
- You: "Review this API endpoint implementation"
- Technical skill: Confirms it follows API design patterns
- code-review skill: Reviews code quality, security, maintainability
- Technical skill: Suggests architectural improvements if patterns emerge
With devops Skill
Technical Skill: Chooses technology stack
↓
Defines deployment requirements
↓
devops Skill: Designs CI/CD pipeline
↓
Sets up infrastructure
↓
Technical Skill: Validates architecture works in production
Example workflow:
- You: "Set up deployment for Next.js app with PostgreSQL"
- Technical skill: Recommends Vercel + Supabase (serverless pattern)
- devops skill: Configures CI/CD, environment variables, monitoring
- Technical skill: Confirms deployed architecture matches design
With ux Skill
ux Skill: Designs user interface and flows
↓
Identifies data requirements
↓
Technical Skill: Designs API and data model
↓
Ensures UI can be implemented efficiently
↓
ux Skill: Adjusts design if technical constraints exist
Example workflow:
- You: "Design task breakdown feature for students"
- ux skill: Creates wireframes and user flow
- Technical skill: Designs database schema and API endpoints
- ux skill: Adjusts UI based on data structure (e.g., nested tasks)
Common Architecture Mistakes to Avoid
Over-Engineering
- ❌ Microservices for a 2-person team
- ❌ Complex caching before measuring performance
- ❌ Custom authentication when NextAuth exists
- ❌ GraphQL when REST would suffice
- Rule: Start simple, add complexity when needed
Under-Engineering
- ❌ No database indexes
- ❌ No caching for expensive operations
- ❌ No error boundaries
- ❌ No loading states
- Rule: Handle the basics (errors, loading, caching)
Wrong Technology Choices
- ❌ MongoDB for highly relational data
- ❌ Redux for simple global state
- ❌ Serverless for compute-heavy workloads
- ❌ NoSQL for ACID requirements
- Rule: Choose technologies based on requirements, not hype
Poor Code Organization
- ❌ Type-based folders (all components in one folder)
- ❌ Deeply nested components (6+ levels)
- ❌ 1000+ line files
- ❌ Mixing business logic and UI
- Rule: Feature-based, colocate, keep files small
Performance Mistakes
- ❌ No code splitting
- ❌ Large unoptimized images
- ❌ Re-rendering entire lists
- ❌ N+1 queries
- Rule: Optimize the common path, measure before optimizing
Security Mistakes (Architecture Level)
- ❌ Authentication logic only on frontend
- ❌ Direct database access from frontend
- ❌ API keys in frontend code
- ❌ No rate limiting
- Rule: Use security skill for comprehensive review
Migration Strategies
From Serverless to Hybrid
When: Serverless costs exceed $300-500/month
Approach:
- Keep frontend on Vercel (still cost-effective)
- Move API to Railway/Render/Fly.io
- Move database to managed service with connection pooling
- Add Redis for caching
- Keep file storage on S3/Vercel Blob
Timeline: 1-2 weeks
From Hybrid to Microservices
When: Need service isolation, team > 5 people
Approach:
- Identify service boundaries (auth, payments, notifications)
- Extract one service at a time (start with least critical)
- Add message queue (SQS, RabbitMQ) for async communication
- Set up service mesh (if using Kubernetes)
- Add centralized logging and monitoring
Timeline: 1-3 months
From Monorepo to Multiple Repos
When: Team > 10 people, clear service ownership
Approach:
- Extract shared code to npm packages
- Split services into separate repos
- Set up consistent CI/CD across repos
- Use dependency management (Renovate, Dependabot)
Timeline: 2-4 weeks
Getting Started
New Project Workflow
- Define requirements (use pre-planning checklist)
- Choose architecture pattern (serverless/hybrid/microservices)
- Select technologies (consult reference files)
- Design data model (references/database-design.md)
- Plan API structure (references/backend-patterns.md)
- Design frontend (references/frontend-patterns.md)
- Validate with security skill (threat model, security controls)
- Set up with devops skill (CI/CD, infrastructure)
- Document decisions (ADRs - Architecture Decision Records)
Existing Project Review Workflow
- Understand current architecture (diagram, document)
- Identify pain points (slow, expensive, hard to maintain)
- Assess against checklist (above)
- Identify gaps (missing caching, poor indexes, etc.)
- Propose improvements (prioritized by impact)
- Create migration plan (phased approach)
- Validate with other skills (security, code-review, devops)
Requesting Architectural Guidance
For best results, provide:
Context:
- What you're building (brief description)
- Current state (greenfield vs existing system)
- Team size and skills
Specific Question:
- What decision are you trying to make?
- What options are you considering?
- What's the tradeoff you're evaluating?
Constraints:
- Budget ($ per month)
- Timeline (MVP in 2 weeks vs production in 3 months)
- Scale requirements (expected users, traffic)
- Compliance (GDPR, HIPAA, etc.)
Example:
"I'm building an educational app for 1000 students and 50 teachers. Need task management, calendar, and file uploads. Team is 2 developers with React/Node.js skills. Budget is $100/month. Need MVP in 4 weeks. Should I use serverless or dedicated backend?"
This skill will consult the relevant references and provide context-specific, actionable recommendations.
Reference Files
Load these for detailed guidance:
- references/frontend-patterns.md - React/Next.js patterns, state management, performance
- references/backend-patterns.md - API design, authentication, caching, background jobs
- references/database-design.md - Schema design, indexing, migrations, scaling
- references/deployment-systems.md - Hosting platforms, CI/CD, monitoring
For comprehensive coverage, use with:
- security skill - Security architecture, threat modeling, compliance
- code-review skill - Code quality, testing strategy, maintainability
- devops skill - CI/CD pipelines, infrastructure, deployment
- ux skill - User interface design, user flows, wireframes
1---2name: technical3description: Comprehensive technical architecture guidance for full-stack applications. Use when discussing system design, component architecture, API design, database schema, state management, deployment strategies, performance optimization, or technical implementation decisions. Covers frontend (React/Next.js), backend (Node.js/serverless), databases (SQL/NoSQL), caching, real-time features, file storage, and technology selection. Ideal for architectural reviews, technical planning, code structure discussions, and scaling strategies. For security architecture, use security skill. For code quality, use code-review skill. For DevOps/CI/CD, use devops skill.4---56# Technical Architecture Skill78Provides comprehensive guidance on technical architecture and implementation decisions for full-stack applications, from system design to technology selection.910## Quick Decision Guide1112**What do you need?**1314```15System architecture / Tech stack selection16 → Use: THIS skill (overall architecture, technology choices)1718Security architecture / Threat modeling19 → Use: security skill (security patterns, compliance, risk)2021Code review / Code quality22 → Use: code-review skill (line-by-line review, vulnerabilities)2324CI/CD pipeline / Infrastructure / Deployment25 → Use: devops skill (pipelines, containers, monitoring)2627UI/UX design / Wireframes / Mockups28 → Use: ux skill (user interface design, user flows)2930Product planning / Feature prioritization31 → Use: product-owner skill (roadmap, user stories, backlog)32```3334## Scope of This Skill3536### This Skill Covers (Technical Architecture)37- ✅ Overall system architecture and service design38- ✅ Component architecture and code organization39- ✅ API design (REST, GraphQL, tRPC)40- ✅ Database schema and data modeling41- ✅ State management patterns42- ✅ Technology stack selection43- ✅ Performance optimization strategy44- ✅ Caching architecture45- ✅ Scalability planning46- ✅ Third-party service integration47- ✅ Frontend and backend patterns4849### Use Other Skills For50- ❌ **Security architecture** → Use security skill51- ❌ **Code security review** → Use code-review skill52- ❌ **CI/CD pipelines** → Use devops skill53- ❌ **Infrastructure setup** → Use devops skill54- ❌ **UI/UX design** → Use ux skill55- ❌ **Product planning** → Use product-owner skill5657### This Skill Works With Other Skills58- **security skill** → Technical arch provides structure, security validates it59- **code-review skill** → Technical arch defines patterns, code-review ensures compliance60- **devops skill** → Technical arch chooses stack, devops deploys it61- **ux skill** → UX defines user needs, technical arch implements them6263## Pre-Planning Checklist6465Before starting architectural planning, gather:6667### Requirements68- [ ] What problem are we solving?69- [ ] Who are the users? (Students, teachers, admins, public)70- [ ] What are the core features?71- [ ] What's the expected scale? (users, data volume, traffic)72- [ ] What's the timeline? (MVP in weeks vs production in months)7374### Constraints75- [ ] Budget limitations?76- [ ] Team skills and size?77- [ ] Performance requirements? (response time, throughput)78- [ ] Compliance requirements? (GDPR, HIPAA, etc.)79- [ ] Integration requirements? (existing systems, APIs)8081### Context82- [ ] Starting from scratch or evolving existing system?83- [ ] Mobile, web, or both?84- [ ] Real-time features needed?85- [ ] Offline support needed?86- [ ] Global users or regional?8788### References to Load89- [ ] **Frontend decisions** → references/frontend-patterns.md90- [ ] **Backend decisions** → references/backend-patterns.md91- [ ] **Database design** → references/database-design.md92- [ ] **Deployment/hosting** → references/deployment-systems.md9394## Architecture Decision Framework9596### 1. Understand Requirements97Start with the pre-planning checklist above.9899### 2. Choose Architecture Pattern100101Based on your stage and needs, select the appropriate pattern:102103**For MVPs / New Products:**104- Pattern 1: Serverless Full-Stack (fast iteration, low maintenance)105106**For Growing Products:**107- Pattern 3: Hybrid (pragmatic middle ground)108109**For Established Products:**110- Pattern 2: Containerized Microservices (full control, scale)111112See "Common Architecture Patterns" section below for details.113114### 3. Select Technologies115116Consult reference files for detailed guidance:117- **Frontend:** references/frontend-patterns.md118- **Backend:** references/backend-patterns.md119- **Database:** references/database-design.md120- **Deployment:** references/deployment-systems.md121122### 4. Validate with Other Skills123124**Security validation:**125- Use security skill to threat model your architecture126- Review authentication/authorization patterns127- Validate data protection approach128129**Code organization validation:**130- Use code-review skill to establish coding standards131- Define maintainability criteria132133**Deployment validation:**134- Use devops skill to design CI/CD pipeline135- Plan infrastructure and monitoring136137### 5. Evaluate Tradeoffs138139Every architecture decision involves tradeoffs:140141**Complexity vs Flexibility:**142- Simple solutions are easier to maintain143- Complex solutions offer more flexibility144- **Rule:** Choose simplest solution that meets requirements145146**Performance vs Development Speed:**147- Optimizations take time to implement148- Premature optimization wastes effort149- **Rule:** Optimize based on actual bottlenecks, not assumptions150151**Cost vs Scale:**152- Serverless: Low cost at low scale, expensive at high scale153- Dedicated servers: Higher baseline cost, cheaper at scale154- **Rule:** Choose based on expected traffic patterns155156**Vendor Lock-in vs Convenience:**157- Managed services (Vercel, Supabase) are convenient but lock you in158- Self-hosted solutions give flexibility but require maintenance159- **Rule:** Consider long-term strategic value and exit cost160161**Build vs Buy:**162- Building gives control but takes time163- Buying gets you features fast but adds dependencies164- **Rule:** Buy for non-core features, build for competitive advantages165166## Common Architecture Patterns167168### Pattern 1: Serverless Full-Stack (Recommended for MVPs)169170**Stack:**171```172Frontend: Next.js on Vercel173Backend: Next.js API Routes (serverless functions)174Database: Supabase (PostgreSQL) or PlanetScale (MySQL)175Cache: Upstash Redis176File Storage: Vercel Blob or S3177Auth: NextAuth.js or Clerk178```179180**When to use:**181- ✅ New products/MVPs182- ✅ Small to medium scale (< 1M requests/month)183- ✅ Want fast iteration184- ✅ Limited DevOps resources185- ✅ Unpredictable traffic186187**Pros:**188- Fast to build and deploy (hours, not days)189- Scales automatically (0 → 10k users without changes)190- Low maintenance (no servers to manage)191- Pay only for usage (can start at $0/month)192- Excellent developer experience193194**Cons:**195- Can get expensive at high scale (> $500/month at scale)196- Some vendor lock-in (but manageable)197- Cold start latency (200-500ms first request)198- Limited control over infrastructure199200**Migration path:**201When you outgrow this, move to Pattern 3 (Hybrid)202203---204205### Pattern 2: Containerized Microservices (For Scale)206207**Stack:**208```209Frontend: Next.js in containers (ECS/Kubernetes)210Backend: Node.js services in containers211Database: RDS PostgreSQL with read replicas212Cache: ElastiCache Redis213File Storage: S3214Auth: Custom JWT implementation215Message Queue: SQS or RabbitMQ216```217218**When to use:**219- ✅ Proven product with growth (> 100k users)220- ✅ Need more control over infrastructure221- ✅ Complex business logic requiring service isolation222- ✅ Team has DevOps skills223- ✅ Predictable high traffic224225**Pros:**226- Full control over infrastructure227- Better cost at scale ($500-2k/month for high traffic)228- Service isolation (can scale services independently)229- Technology flexibility (mix languages)230- No cold starts231232**Cons:**233- More complex setup (weeks of infrastructure work)234- Requires DevOps expertise235- Higher baseline costs (minimum ~$200/month)236- More maintenance burden237238**Migration path:**239Usually don't migrate away, just add more services240241---242243### Pattern 3: Hybrid (Pragmatic Middle Ground)244245**Stack:**246```247Frontend: Next.js on Vercel (fast deploys, edge)248Backend: Dedicated API server on Railway/Render/Fly.io249Database: Managed PostgreSQL (Supabase/Neon/RDS)250Cache: Upstash Redis or managed Redis251File Storage: S3 or Cloudflare R2252Auth: NextAuth.js or custom253```254255**When to use:**256- ✅ Outgrowing serverless costs (> $300/month)257- ✅ Not ready for full container complexity258- ✅ Need more backend flexibility (long-running tasks)259- ✅ Want good DX with more control260- ✅ Growing team (2-5 developers)261262**Pros:**263- Better cost than pure serverless at scale264- More backend control (background jobs, websockets)265- Frontend still has great DX (Vercel)266- Easier than full microservices267- Good balance of control and convenience268269**Cons:**270- More complex than pure serverless271- Need to manage API server272- Not as automated as Pattern 1273- Not as flexible as Pattern 2274275**Migration path:**276Can move to Pattern 2 when you need service isolation277278---279280## Technology Selection Guidelines281282### Frontend Framework283284**Next.js (Recommended):**285- ✅ Full-stack capabilities (API routes, server actions)286- ✅ Excellent performance (SSR, ISR, SSG)287- ✅ Great DX with Vercel288- ✅ Large ecosystem and community289- ✅ Built-in optimizations (images, fonts, code splitting)290- **Use for:** Most web applications, SEO-critical sites291292**React SPA:**293- ✅ Simple deployment (static files)294- ✅ Full client-side control295- ✅ Works well with any backend296- ❌ Worse SEO (unless prerendering)297- ❌ Slower initial load298- **Use for:** Admin dashboards, internal tools, web apps where SEO doesn't matter299300**React Native (Mobile):**301- ✅ Code sharing with web (if using React)302- ✅ Native performance303- ✅ Single codebase for iOS + Android304- ❌ More complex than web305- ❌ App store deployment overhead306- **Use for:** Mobile apps (student/guardian apps for educational app)307308---309310### Backend Language/Runtime311312**Node.js/TypeScript (Recommended):**313- ✅ Share code and types with frontend314- ✅ Great ecosystem (npm packages)315- ✅ Fast development (familiar to frontend devs)316- ✅ Good for I/O-heavy tasks (APIs, databases)317- ✅ Async by default318- **Use for:** Most applications, especially full-stack TypeScript319320**Python:**321- ✅ Excellent for ML/AI workloads322- ✅ Great data processing libraries (pandas, numpy)323- ✅ Good for scripts and background jobs324- ❌ Harder to share code with frontend325- ❌ Slower for I/O-heavy tasks326- **Use for:** ML pipelines, data processing, computer vision, background jobs327328**When to use both:**329- Node.js for API server (user-facing)330- Python for background processing (ML, data analysis)331332---333334### Database335336**PostgreSQL (Recommended for most apps):**337- ✅ Excellent for relational data338- ✅ ACID transactions (data integrity)339- ✅ Rich query capabilities (joins, aggregations)340- ✅ JSON support for flexibility341- ✅ Great performance with proper indexing342- ✅ Mature ecosystem343- **Use for:** Educational apps, CRUDs, any structured data344345**MongoDB:**346- ✅ Flexible schema (good for rapid prototyping)347- ✅ Fast writes348- ✅ Good for unstructured data349- ❌ Weaker consistency guarantees350- ❌ No joins (application-level only)351- **Use for:** Rapid prototyping, analytics, logs, event data352353**Decision matrix:**354- Structured data with relationships? → PostgreSQL355- Need ACID transactions? → PostgreSQL356- Flexible/evolving schema? → MongoDB or PostgreSQL (with JSONB)357- Heavy analytics? → PostgreSQL (with indexing) or ClickHouse358359For detailed schema design, consult references/database-design.md360361---362363### State Management364365**React Query/SWR (Recommended for server state):**366- ✅ Handles 90% of state needs367- ✅ Automatic caching and refetching368- ✅ Loading/error states handled369- ✅ Less boilerplate than Redux370- ✅ Optimistic updates371- **Use for:** API data, server state, any data from backend372373**Zustand (Recommended for client state):**374- ✅ Simple API375- ✅ Small bundle size (<1KB)376- ✅ No boilerplate377- ✅ TypeScript support378- ✅ No context provider needed379- **Use for:** Global UI state, user preferences, theme, modals380381**Context API (Built-in):**382- ✅ No dependencies383- ✅ Good for simple state384- ❌ Can cause unnecessary re-renders385- ❌ Verbose for complex state386- **Use for:** Simple global state (theme, user info)387388**Redux:**389- ✅ Powerful debugging (DevTools)390- ✅ Middleware ecosystem391- ✅ Time-travel debugging392- ❌ More boilerplate393- ❌ Steeper learning curve394- **Use for:** Very complex state, need time-travel debugging395396**Rule of thumb:**397- Server data → React Query/SWR398- Global UI state → Zustand399- Simple context → Context API400- Complex state machine → Redux or XState401402---403404## Architecture Review Checklist405406When reviewing or planning architecture, verify:407408### System Design409- [ ] Architecture pattern chosen (serverless/hybrid/containers)?410- [ ] Frontend and backend clearly separated?411- [ ] API design follows REST/GraphQL best practices?412- [ ] Database schema normalized appropriately?413- [ ] State management approach defined?414- [ ] Authentication strategy chosen?415- [ ] File storage solution selected?416417### Scalability418- [ ] Can handle 10x current load?419- [ ] Database properly indexed?420- [ ] Caching strategy in place?421- [ ] No N+1 query problems?422- [ ] Background jobs for heavy processing?423- [ ] CDN for static assets?424425### Performance426- [ ] Images optimized?427- [ ] Code splitting implemented?428- [ ] Lazy loading for heavy components?429- [ ] Database queries optimized?430- [ ] Caching for expensive operations?431- [ ] Bundle size monitored?432433### Maintainability434- [ ] Clear code organization (feature-based)?435- [ ] Consistent naming conventions?436- [ ] Components focused (single responsibility)?437- [ ] TypeScript for type safety?438- [ ] Linting and formatting configured?439- [ ] Documentation for complex logic?440441### Developer Experience442- [ ] Easy local development setup?443- [ ] Environment variables managed properly?444- [ ] Hot reload working?445- [ ] Fast build times (< 30 seconds)?446- [ ] Clear error messages?447448### Security (High-Level - Delegate to security skill)449- [ ] **Use security skill for detailed review**450- [ ] Authentication implemented?451- [ ] HTTPS enabled?452- [ ] Secrets not in code?453- [ ] Input validation at API boundaries?454455### Testing (High-Level - Delegate to code-review skill)456- [ ] **Use code-review skill for test strategy**457- [ ] Critical paths have tests?458- [ ] API endpoints tested?459- [ ] E2E tests for key flows?460461### Deployment (High-Level - Delegate to devops skill)462- [ ] **Use devops skill for CI/CD design**463- [ ] Automated deployments configured?464- [ ] Staging environment available?465- [ ] Rollback plan ready?466467---468469## Best Practices Summary470471### Code Organization472- **Feature-based structure** over type-based473 ```474 ✅ Good: features/assignments/, features/students/475 ❌ Bad: components/, hooks/, utils/, services/476 ```477- **Colocate related code** (components, hooks, styles together)478- **Keep components small** (< 200 lines, single responsibility)479- **Use absolute imports** (`@/components` vs `../../../components`)480- **Separate business logic** from UI (custom hooks, service layer)481482### Performance483- **Code splitting** for routes (automatic in Next.js)484- **React.memo** for expensive components485- **Optimize images** (Next.js Image component, WebP format)486- **Database indexes** for frequent queries487- **Cache expensive operations** (React Query, Redis)488- **Lazy load** heavy components489- **Debounce/throttle** expensive operations (search, scroll)490491### API Design492- **RESTful conventions** (GET/POST/PUT/DELETE, proper status codes)493- **Consistent naming** (camelCase for JSON, snake_case for DB)494- **Versioning** (/api/v1/)495- **Pagination** for collections (limit/offset or cursor-based)496- **Error handling** (consistent error format)497- **Rate limiting** (prevent abuse)498- **Documentation** (OpenAPI/Swagger)499500### Database Design501- **Normalize** to avoid redundancy (usually 3NF)502- **Index** frequently queried fields503- **Foreign keys** for referential integrity504- **Migrations** for schema changes505- **Soft deletes** for important data (deleted_at column)506- **Timestamps** (created_at, updated_at) on all tables507508---509510## Integration with Other Skills511512### With security Skill513```514Technical Skill: Designs system architecture515 ↓516 Identifies integration points517 ↓518security Skill: Reviews security architecture519 ↓520 Identifies security requirements521 ↓522Technical Skill: Incorporates security controls523 ↓524security Skill: Validates implementation525```526527**Example workflow:**5281. You: "Design authentication system for student/teacher app"5292. Technical skill: Recommends NextAuth.js with JWT, session strategy5303. security skill: Reviews JWT storage, session management, threat model5314. Technical skill: Updates architecture based on security recommendations532533### With code-review Skill534```535Technical Skill: Defines architecture patterns536 ↓537 Sets coding standards538 ↓539code-review Skill: Reviews code against patterns540 ↓541 Identifies deviations and issues542 ↓543Technical Skill: Updates patterns if needed544```545546**Example workflow:**5471. You: "Review this API endpoint implementation"5482. Technical skill: Confirms it follows API design patterns5493. code-review skill: Reviews code quality, security, maintainability5504. Technical skill: Suggests architectural improvements if patterns emerge551552### With devops Skill553```554Technical Skill: Chooses technology stack555 ↓556 Defines deployment requirements557 ↓558devops Skill: Designs CI/CD pipeline559 ↓560 Sets up infrastructure561 ↓562Technical Skill: Validates architecture works in production563```564565**Example workflow:**5661. You: "Set up deployment for Next.js app with PostgreSQL"5672. Technical skill: Recommends Vercel + Supabase (serverless pattern)5683. devops skill: Configures CI/CD, environment variables, monitoring5694. Technical skill: Confirms deployed architecture matches design570571### With ux Skill572```573ux Skill: Designs user interface and flows574 ↓575 Identifies data requirements576 ↓577Technical Skill: Designs API and data model578 ↓579 Ensures UI can be implemented efficiently580 ↓581ux Skill: Adjusts design if technical constraints exist582```583584**Example workflow:**5851. You: "Design task breakdown feature for students"5862. ux skill: Creates wireframes and user flow5873. Technical skill: Designs database schema and API endpoints5884. ux skill: Adjusts UI based on data structure (e.g., nested tasks)589590---591592## Common Architecture Mistakes to Avoid593594### Over-Engineering595- ❌ Microservices for a 2-person team596- ❌ Complex caching before measuring performance597- ❌ Custom authentication when NextAuth exists598- ❌ GraphQL when REST would suffice599- **Rule:** Start simple, add complexity when needed600601### Under-Engineering602- ❌ No database indexes603- ❌ No caching for expensive operations604- ❌ No error boundaries605- ❌ No loading states606- **Rule:** Handle the basics (errors, loading, caching)607608### Wrong Technology Choices609- ❌ MongoDB for highly relational data610- ❌ Redux for simple global state611- ❌ Serverless for compute-heavy workloads612- ❌ NoSQL for ACID requirements613- **Rule:** Choose technologies based on requirements, not hype614615### Poor Code Organization616- ❌ Type-based folders (all components in one folder)617- ❌ Deeply nested components (6+ levels)618- ❌ 1000+ line files619- ❌ Mixing business logic and UI620- **Rule:** Feature-based, colocate, keep files small621622### Performance Mistakes623- ❌ No code splitting624- ❌ Large unoptimized images625- ❌ Re-rendering entire lists626- ❌ N+1 queries627- **Rule:** Optimize the common path, measure before optimizing628629### Security Mistakes (Architecture Level)630- ❌ Authentication logic only on frontend631- ❌ Direct database access from frontend632- ❌ API keys in frontend code633- ❌ No rate limiting634- **Rule:** Use security skill for comprehensive review635636---637638## Migration Strategies639640### From Serverless to Hybrid641642**When:** Serverless costs exceed $300-500/month643644**Approach:**6451. Keep frontend on Vercel (still cost-effective)6462. Move API to Railway/Render/Fly.io6473. Move database to managed service with connection pooling6484. Add Redis for caching6495. Keep file storage on S3/Vercel Blob650651**Timeline:** 1-2 weeks652653---654655### From Hybrid to Microservices656657**When:** Need service isolation, team > 5 people658659**Approach:**6601. Identify service boundaries (auth, payments, notifications)6612. Extract one service at a time (start with least critical)6623. Add message queue (SQS, RabbitMQ) for async communication6634. Set up service mesh (if using Kubernetes)6645. Add centralized logging and monitoring665666**Timeline:** 1-3 months667668---669670### From Monorepo to Multiple Repos671672**When:** Team > 10 people, clear service ownership673674**Approach:**6751. Extract shared code to npm packages6762. Split services into separate repos6773. Set up consistent CI/CD across repos6784. Use dependency management (Renovate, Dependabot)679680**Timeline:** 2-4 weeks681682---683684## Getting Started685686### New Project Workflow6876881. **Define requirements** (use pre-planning checklist)6892. **Choose architecture pattern** (serverless/hybrid/microservices)6903. **Select technologies** (consult reference files)6914. **Design data model** (references/database-design.md)6925. **Plan API structure** (references/backend-patterns.md)6936. **Design frontend** (references/frontend-patterns.md)6947. **Validate with security skill** (threat model, security controls)6958. **Set up with devops skill** (CI/CD, infrastructure)6969. **Document decisions** (ADRs - Architecture Decision Records)697698### Existing Project Review Workflow6997001. **Understand current architecture** (diagram, document)7012. **Identify pain points** (slow, expensive, hard to maintain)7023. **Assess against checklist** (above)7034. **Identify gaps** (missing caching, poor indexes, etc.)7045. **Propose improvements** (prioritized by impact)7056. **Create migration plan** (phased approach)7067. **Validate with other skills** (security, code-review, devops)707708---709710## Requesting Architectural Guidance711712For best results, provide:713714**Context:**715- What you're building (brief description)716- Current state (greenfield vs existing system)717- Team size and skills718719**Specific Question:**720- What decision are you trying to make?721- What options are you considering?722- What's the tradeoff you're evaluating?723724**Constraints:**725- Budget ($ per month)726- Timeline (MVP in 2 weeks vs production in 3 months)727- Scale requirements (expected users, traffic)728- Compliance (GDPR, HIPAA, etc.)729730**Example:**731> "I'm building an educational app for 1000 students and 50 teachers. Need task management, calendar, and file uploads. Team is 2 developers with React/Node.js skills. Budget is $100/month. Need MVP in 4 weeks. Should I use serverless or dedicated backend?"732733This skill will consult the relevant references and provide context-specific, actionable recommendations.734735---736737## Reference Files738739Load these for detailed guidance:740741- **references/frontend-patterns.md** - React/Next.js patterns, state management, performance742- **references/backend-patterns.md** - API design, authentication, caching, background jobs743- **references/database-design.md** - Schema design, indexing, migrations, scaling744- **references/deployment-systems.md** - Hosting platforms, CI/CD, monitoring745746**For comprehensive coverage, use with:**747- **security skill** - Security architecture, threat modeling, compliance748- **code-review skill** - Code quality, testing strategy, maintainability749- **devops skill** - CI/CD pipelines, infrastructure, deployment750- **ux skill** - User interface design, user flows, wireframes