Build & Deployment
CI/CD strategies, deployment patterns, and build optimization for frontend applications.
Quick Navigation: Monorepo • CI/CD • Deployment • Feature Flags
Monorepo vs Multi-Repo
Monorepo
All projects in single repository.
✓ Shared code and dependencies
✓ Atomic changes across packages
✓ Consistent tooling
✗ Large repo size
✗ Complex CI configuration
✗ Requires Nx/Turborepo tooling
🎯 Best For: Large teams, shared components, design systems
Multi-Repo
Separate repository per project.
✓ Clear ownership boundaries
✓ Independent deployment
✓ Simpler CI/CD
✗ Dependency hell
✗ Code duplication
✗ Cross-repo changes are hard
🎯 Best For: Small teams, independent services, microservices
CI/CD Strategies
Trunk-Based Development
Everyone commits to main, short-lived feature branches.
Pros
- ✓ Faster integration
- ✓ Fewer merge conflicts
- ✓ Continuous deployment ready
Cons
- ✗ Requires feature flags
- ✗ Need strong CI/CD
- ✗ Risk of broken main
GitFlow
Multiple long-lived branches (develop, release, hotfix).
Pros
- ✓ Clear release process
- ✓ Parallel development
- ✓ Stable main branch
Cons
- ✗ Complex branching
- ✗ Merge conflicts
- ✗ Slower releases
Deployment Strategies
Rolling Deployment
Gradually replace instances with new version.
Pros: Zero downtime, resource efficient
Cons: Multiple versions running, slow rollback
Blue-Green Deployment
Two identical environments, switch traffic instantly.
Pros: Instant rollback, test before switch
Cons: Double resources, database migrations tricky
Canary Deployment
Route small % of traffic to new version first.
Pros: Real user testing, minimal risk
Cons: Complex routing, monitoring needed
Feature Flags
Advantages
- ✓Decouple deploy from release: Ship code, enable later
- ✓A/B testing: Test features with subset of users
- ✓Kill switch: Disable features without deploy
- ✓Gradual rollout: 1% → 10% → 50% → 100%
Disadvantages
- ✗Tech debt: Old flags accumulate
- ✗Complexity: Multiple code paths
- ✗Testing: Need to test all combinations
Feature Flag Types
- Release flags: Ship incomplete features safely
- Experiment flags: A/B testing, measure impact
- Ops flags: Circuit breakers, kill switches
- Permission flags: Beta features for certain users
Best Practices
- 1.Automate everything. Build, test, deploy should be one command.
- 2.Deploy frequently. Smaller changes = lower risk.
- 3.Monitor after deploy. Error rates, performance, user behavior.
- 4.Clean up feature flags. Remove after full rollout.
- 5.Have rollback plan. Know how to revert quickly.