Comprehensive software architecture design guide covering pattern selection, directory structures, trade-off analysis, and architectural decision records for projects of all sizes.
Architecture Design Guide - Systematic approach to selecting, implementing, and documenting software architecture patterns.
Core Philosophy:
Key Capabilities:
Quick Commands:
/jikime:1-plan --ultrathinkβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Step 1: UNDERSTAND Step 2: ASSESS Step 3: SELECT β
β βββββββββββββββββ βββββββββββββββββ βββββββββββββββββ β
β β Requirements ββββββΆβ Project Size ββββββΆβ Architecture β β
β β & Constraints β β & Team Skills β β Pattern β β
β βββββββββββββββββ βββββββββββββββββ βββββββββββββββββ β
β β β β
β β Step 5: DOCUMENT Step 4: STRUCTURE β
β β βββββββββββββββββ βββββββββββββββββ β
β βββββββββββ ADR βββββββββββ Directory β β
β β Creation β β Layout β β
β βββββββββββββββββ βββββββββββββββββ β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
Requirements Checklist:
## Functional Requirements
- [ ] Core features and user stories defined
- [ ] Integration points identified
- [ ] Data model understood
## Non-Functional Requirements (NFRs)
- [ ] Performance: Expected load, response times
- [ ] Scalability: Growth trajectory, peak loads
- [ ] Security: Compliance, data sensitivity
- [ ] Availability: Uptime requirements, SLA
- [ ] Maintainability: Change frequency, team turnover
Constraint Categories:
| Category | Questions to Answer |
|---|---|
| Technical | Existing tech stack? Legacy integrations? |
| Business | Budget? Timeline? Regulatory requirements? |
| Team | Size? Experience level? Distributed? |
| Operational | Deployment frequency? Monitoring needs? |
Project Size Matrix:
| Size | Lines of Code | Features | Recommended Complexity |
|---|---|---|---|
| Small | < 10K | < 10 | Simple (Layered, MVC) |
| Medium | 10K - 100K | 10-50 | Moderate (Clean, Hexagonal) |
| Large | 100K - 500K | 50-200 | Complex (Modular Monolith) |
| Enterprise | > 500K | > 200 | Distributed (Microservices) |
Team Size Matrix:
| Team | Coordination | Recommended |
|---|---|---|
| 1-3 devs | Minimal | Monolith with clear modules |
| 4-10 devs | Moderate | Modular Monolith, clear boundaries |
| 10-30 devs | Significant | Service-Oriented, domain teams |
| 30+ devs | Complex | Microservices (if justified) |
Decision Matrix:
Small Team ββββββββββββββββββΆ Large Team
β β
Simple ββββΌβββββββββββββββββββββββββββββΌβββ Complex
Project β βββββββββββββββ β Project
β β MODULAR β β
β β MONOLITH β β
β β (Sweet β β
β β Spot) β β
β βββββββββββββββ β
β β
MONOLITH MICROSERVICES
For detailed diagrams and explanations, see:
| Pattern | Complexity | Best For |
|---|---|---|
| Layered | Simple | CRUD apps, small teams, prototypes |
| Clean | Moderate | Complex business logic, testability |
| Hexagonal | Moderate | Multiple entry points, swappable deps |
| Event-Driven | Complex | Loose coupling, async processing |
| CQRS | Complex | Different read/write scaling |
| Modular Monolith | Moderate | Medium-large projects (recommended) |
| Microservices | Complex | Large distributed teams, polyglot |
src/
βββ features/ # Domain features
β βββ users/
β β βββ api/ # Route handlers, controllers
β β β βββ users.controller.ts
β β β βββ users.routes.ts
β β βββ application/ # Use cases, services
β β β βββ create-user.ts
β β β βββ get-user.ts
β β βββ domain/ # Entities, value objects
β β β βββ user.entity.ts
β β β βββ email.value-object.ts
β β βββ infrastructure/ # External implementations
β β β βββ user.repository.ts
β β βββ index.ts # Public API
β β
β βββ orders/
β βββ api/
β βββ application/
β βββ domain/
β βββ infrastructure/
β
βββ shared/ # Cross-cutting concerns
β βββ domain/ # Shared value objects
β βββ infrastructure/ # Shared adapters
β βββ utils/ # Pure utility functions
β
βββ app/ # Application bootstrap
βββ config/
βββ middleware/
βββ main.ts
src/
βββ controllers/ # HTTP layer
β βββ user.controller.ts
β βββ order.controller.ts
βββ services/ # Business logic
β βββ user.service.ts
β βββ order.service.ts
βββ models/ # Data models
β βββ user.model.ts
β βββ order.model.ts
βββ repositories/ # Data access
β βββ user.repository.ts
β βββ order.repository.ts
βββ middlewares/ # Express middlewares
βββ utils/ # Helper functions
βββ app.ts # Entry point
ADR Template:
# ADR-{NUMBER}: {Title}
## Status
Proposed | Accepted | Deprecated | Superseded by ADR-XXX
## Date
YYYY-MM-DD
## Context
What is the issue that we're seeing that is motivating this decision?
## Decision Drivers
- [Driver 1]
- [Driver 2]
- [Constraint 1]
## Considered Options
1. **Option A**: [Description]
2. **Option B**: [Description]
3. **Option C**: [Description]
## Decision
We chose **Option X** because [reasoning].
## Trade-off Analysis
| Criteria | Option A | Option B | Option C |
|----------|----------|----------|----------|
| Complexity | Low | Medium | High |
| Scalability | Low | High | High |
| Team familiarity | High | Medium | Low |
| Time to implement | 1 week | 3 weeks | 6 weeks |
## Consequences
### Positive
- [Benefit 1]
- [Benefit 2]
### Negative
- [Drawback 1]
- [Mitigation strategy]
### Risks
- [Risk 1]: [Mitigation]
## Related Decisions
- ADR-XXX: [Related decision]
## Notes
[Any additional context or references]
Automated tests that verify architectural decisions:
// No domain depending on infrastructure
describe('Architecture Fitness', () => {
it('domain should not import infrastructure', () => {
const domainFiles = glob.sync('src/**/domain/**/*.ts');
for (const file of domainFiles) {
const content = fs.readFileSync(file, 'utf-8');
expect(content).not.toMatch(/from ['"].*infrastructure/);
}
});
it('features should not cross-import', () => {
const usersFiles = glob.sync('src/features/users/**/*.ts');
for (const file of usersFiles) {
const content = fs.readFileSync(file, 'utf-8');
expect(content).not.toMatch(/from ['"].*features\/orders/);
}
});
});
# Visualize module dependencies
npx madge --image graph.svg src/
# Detect circular dependencies
npx madge --circular src/
Commands:
/jikime:1-plan --ultrathink - Deep architecture planning/jikime:architect - Architecture reviewSkills:
jikime-foundation-core - Core patterns and SPEC workflowjikime-workflow-spec - SPEC document creationjikime-domain-backend - Backend implementation patternsjikime-domain-frontend - Frontend architecture patternsAgents:
architect - System architecture specialistmanager-strategy - Strategic decision makingmanager-spec - Requirements and SPEC creation| Scenario | Recommended Pattern |
|---|---|
| MVP/Prototype | Layered Architecture |
| SaaS product (1-3 devs) | Clean Architecture |
| Growing product (4-10 devs) | Modular Monolith |
| Enterprise (10+ devs, multiple teams) | Microservices (if mature DevOps) |
| High async processing | Event-Driven |
| Complex read/write patterns | CQRS |
| Multiple external integrations | Hexagonal |
Architecture Validation:
- [ ] Pattern matches project size and complexity
- [ ] Architecture aligns with team skills and experience
- [ ] Current requirements are supported
- [ ] Anticipated growth can be accommodated
- [ ] Dependencies flow inward (core has no external deps)
- [ ] Clear boundaries between modules/layers
- [ ] Testing strategy is feasible with this architecture
- [ ] Trade-offs are documented in ADR
- [ ] Fitness functions defined for critical constraints
Version: 1.0.0 Last Updated: 2026-01-25 Integration Status: Complete - Full architecture design workflow