Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Dependencies
node_modules/
npm-debug.log*
yarn-debug.log*
yarn-error.log*
package-lock.json
yarn.lock

# Build outputs
/dist
/build
/.next
/.nuxt
/coverage

# Environment files
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

# IDE files
.vscode/
.idea/
*.swp
*.swo
*~

# OS generated files
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
Thumbs.db

# Logs
logs
*.log

# Temporary files
/tmp
*.tmp
*.temp

# Cache directories
.cache/
.parcel-cache/
128 changes: 127 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,127 @@
# DevPatterns
# DevPatterns

A comprehensive collection of development patterns inspired by [patterns.dev](https://www.patterns.dev/), organized from vanilla JavaScript fundamentals to advanced React patterns.

## πŸ“š Pattern Categories

### 🟨 Vanilla Patterns
Start your journey with fundamental patterns that work in any JavaScript environment.

#### 🎯 Design Patterns
Classic software design patterns implemented in vanilla JavaScript:
- **Creational**: [Singleton](./vanilla-patterns/design-patterns/singleton), [Factory](./vanilla-patterns/design-patterns/factory), [Abstract Factory](./vanilla-patterns/design-patterns/abstract-factory), [Builder](./vanilla-patterns/design-patterns/builder), [Prototype](./vanilla-patterns/design-patterns/prototype)
- **Structural**: [Adapter](./vanilla-patterns/design-patterns/adapter), [Bridge](./vanilla-patterns/design-patterns/bridge), [Composite](./vanilla-patterns/design-patterns/composite), [Decorator](./vanilla-patterns/design-patterns/decorator), [Facade](./vanilla-patterns/design-patterns/facade), [Flyweight](./vanilla-patterns/design-patterns/flyweight), [Proxy](./vanilla-patterns/design-patterns/proxy)
- **Behavioral**: [Chain of Responsibility](./vanilla-patterns/design-patterns/chain-of-responsibility), [Command](./vanilla-patterns/design-patterns/command), [Iterator](./vanilla-patterns/design-patterns/iterator), [Mediator](./vanilla-patterns/design-patterns/mediator), [Memento](./vanilla-patterns/design-patterns/memento), [Observer](./vanilla-patterns/design-patterns/observer), [State](./vanilla-patterns/design-patterns/state), [Strategy](./vanilla-patterns/design-patterns/strategy), [Template Method](./vanilla-patterns/design-patterns/template-method), [Visitor](./vanilla-patterns/design-patterns/visitor)

#### ⚑ Performance Patterns
Optimize your vanilla JavaScript applications:
- [Bundling](./vanilla-patterns/performance-patterns/bundling)
- [Code Splitting](./vanilla-patterns/performance-patterns/code-splitting)
- [Tree Shaking](./vanilla-patterns/performance-patterns/tree-shaking)
- [Preload](./vanilla-patterns/performance-patterns/preload) & [Prefetch](./vanilla-patterns/performance-patterns/prefetch)
- [Import on Visibility](./vanilla-patterns/performance-patterns/import-on-visibility)
- [Import on Interaction](./vanilla-patterns/performance-patterns/import-on-interaction)
- [Route-based Splitting](./vanilla-patterns/performance-patterns/route-based-splitting)
- [Bundle Splitting](./vanilla-patterns/performance-patterns/bundle-splitting)

### βš›οΈ React Patterns
Advanced patterns specifically for React applications.

#### 🧩 Component Patterns
Master React component design and composition:
- [Container/Presentational](./react-patterns/component-patterns/container-presentational)
- [Higher-Order Components](./react-patterns/component-patterns/higher-order-component)
- [Render Props](./react-patterns/component-patterns/render-props)
- [Hooks Pattern](./react-patterns/component-patterns/hooks-pattern)
- [Provider Pattern](./react-patterns/component-patterns/provider-pattern)
- [Compound Pattern](./react-patterns/component-patterns/compound-pattern)

#### πŸ–₯️ Rendering Patterns
Optimize how and when your React components render:
- [Client-Side Rendering](./react-patterns/rendering-patterns/client-side-rendering)
- [Server-Side Rendering](./react-patterns/rendering-patterns/server-side-rendering)
- [Static Generation](./react-patterns/rendering-patterns/static-generation)
- [Incremental Static Generation](./react-patterns/rendering-patterns/incremental-static-generation)
- [Progressive Hydration](./react-patterns/rendering-patterns/progressive-hydration)
- [Streaming SSR](./react-patterns/rendering-patterns/streaming-ssr)
- [Selective Hydration](./react-patterns/rendering-patterns/selective-hydration)
- [Islands Architecture](./react-patterns/rendering-patterns/islands-architecture)

#### πŸš€ Performance Patterns
React-specific performance optimizations:
- [Dynamic Imports](./react-patterns/performance-patterns/dynamic-imports)
- [React.lazy](./react-patterns/performance-patterns/react-lazy)
- [Code Splitting](./react-patterns/performance-patterns/code-splitting)
- [Bundle Splitting](./react-patterns/performance-patterns/bundle-splitting)
- [Tree Shaking](./react-patterns/performance-patterns/tree-shaking)
- [Virtualization](./react-patterns/performance-patterns/virtualization)
- [Memoization](./react-patterns/performance-patterns/memoization)

### 🌐 Modern Web Patterns
Cutting-edge patterns for modern web applications:
- [Micro Frontends](./modern-web-patterns/micro-frontends)
- [Module Federation](./modern-web-patterns/module-federation)
- [Web Workers](./modern-web-patterns/web-workers)
- [Service Workers](./modern-web-patterns/service-workers)
- [WebAssembly](./modern-web-patterns/web-assembly)
- [Streaming](./modern-web-patterns/streaming)
- [Progressive Web Apps](./modern-web-patterns/progressive-web-apps)

## πŸš€ Getting Started

1. **Clone the repository**:
```bash
git clone https://github.com/ctrl-hack/DevPatterns.git
cd DevPatterns
```

2. **Install dependencies**:
```bash
npm install
```

3. **Choose your starting point**:
- **New to patterns?** Start with [vanilla-patterns/design-patterns/singleton](./vanilla-patterns/design-patterns/singleton)
- **React developer?** Jump to [react-patterns/component-patterns](./react-patterns/component-patterns)
- **Performance focused?** Explore performance patterns in both vanilla and React sections

## πŸ“– Learning Path

### Recommended Learning Sequence:

1. **Foundation** (Vanilla Patterns)
- Start with Design Patterns (Singleton β†’ Observer β†’ Factory)
- Learn Performance Patterns basics

2. **React Fundamentals**
- Component Patterns (Container/Presentational β†’ Hooks)
- Basic Rendering Patterns (CSR β†’ SSR)

3. **Advanced React**
- Advanced Component Patterns (HOC β†’ Render Props)
- Advanced Rendering Patterns (SSG β†’ Islands)
- React Performance Patterns

4. **Modern Architecture**
- Modern Web Patterns
- Advanced Performance Optimization

## 🀝 Contributing

Each pattern directory contains:
- `README.md` - Pattern explanation and use cases
- `index.js` - Basic implementation
- `example/` - Practical examples
- `tests/` - Unit tests (where applicable)

Feel free to contribute implementations, examples, or improvements!

## πŸ“š Resources

- [Patterns.dev](https://www.patterns.dev/) - The inspiration for this repository
- [JavaScript Design Patterns](https://addyosmani.com/resources/essentialjsdesignpatterns/book/)
- [React Patterns](https://reactpatterns.com/)

## πŸ“„ License

MIT License - see [LICENSE](LICENSE) file for details.
163 changes: 163 additions & 0 deletions modern-web-patterns/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
# Modern Web Patterns

Advanced patterns for building cutting-edge web applications using the latest technologies and architectural approaches.

## πŸ—οΈ Architecture Patterns

### Micro Frontends
- **[Micro Frontends](./micro-frontends)** - Break large frontend applications into smaller, manageable pieces
- **[Module Federation](./module-federation)** - Share code between separate applications at runtime

### Benefits:
- Independent development and deployment
- Technology diversity across teams
- Better scalability and maintainability
- Fault isolation

## 🧡 Concurrency Patterns

### Web Workers
- **[Web Workers](./web-workers)** - Run JavaScript in background threads
- **[Service Workers](./service-workers)** - Enable offline functionality and advanced caching

### Use Cases:
- Heavy computations without blocking UI
- Background data processing
- Offline-first applications
- Push notifications
- Advanced caching strategies

## πŸš€ Performance Patterns

### Advanced Loading
- **[Streaming](./streaming)** - Stream content to users as it becomes available
- **[Progressive Web Apps](./progressive-web-apps)** - Build app-like experiences on the web

### Modern Technologies
- **[WebAssembly](./web-assembly)** - Run high-performance code in the browser

## When to Use These Patterns

### Micro Frontends
βœ… **Use when:**
- Large teams working on different parts
- Need technology diversity
- Independent deployment cycles
- Legacy system integration

❌ **Avoid when:**
- Small applications
- Simple requirements
- Performance is critical
- Limited development resources

### Web Workers
βœ… **Use when:**
- CPU-intensive tasks
- Large data processing
- Complex calculations
- Image/video manipulation

❌ **Avoid when:**
- Simple DOM manipulations
- Small calculations
- Frequent data exchange needed
- Simple applications

### Service Workers
βœ… **Use when:**
- Offline functionality needed
- Advanced caching required
- Push notifications
- Background sync

❌ **Avoid when:**
- Simple static sites
- No offline requirements
- Limited browser support needed

### WebAssembly
βœ… **Use when:**
- Performance-critical code
- Porting existing C/C++/Rust code
- Complex mathematical operations
- Games or simulations

❌ **Avoid when:**
- Simple web applications
- Heavy DOM manipulation
- Small performance gains
- First-time WASM developers

## Implementation Complexity

| Pattern | Complexity | Setup Time | Maintenance |
|---------|------------|------------|-------------|
| Micro Frontends | High | Weeks | High |
| Module Federation | Medium | Days | Medium |
| Web Workers | Medium | Hours | Low |
| Service Workers | Medium | Days | Medium |
| WebAssembly | High | Days-Weeks | Medium |
| Streaming | Medium | Days | Medium |
| PWA | Medium | Days | Medium |

## Prerequisites

### Technical Knowledge
- Strong JavaScript fundamentals
- Understanding of build tools and bundlers
- Basic knowledge of HTTP and web protocols
- Browser API familiarity

### For Micro Frontends
- Module bundlers (webpack, Rollup, Vite)
- Build and deployment pipelines
- Container orchestration (optional)

### For Workers
- Understanding of JavaScript concurrency
- Browser security models
- Async/await and Promises

### For WebAssembly
- Basic knowledge of C/C++/Rust (optional)
- Understanding of memory management
- Build toolchains (Emscripten, wasm-pack)

## Getting Started

1. **Begin with Web Workers** - Easiest to implement and understand
2. **Try Service Workers** - Add offline capabilities to existing apps
3. **Explore Streaming** - Improve perceived performance
4. **Consider PWA features** - Enhance user experience
5. **Evaluate Micro Frontends** - For larger applications
6. **Experiment with WebAssembly** - For performance-critical features

## Browser Support

Most modern patterns require modern browsers. Check compatibility:

- **Web Workers**: Excellent (95%+ support)
- **Service Workers**: Good (90%+ support)
- **Module Federation**: Requires modern bundlers
- **WebAssembly**: Excellent (95%+ support)
- **Streaming**: Good with polyfills
- **PWA Features**: Varies by feature

## Performance Considerations

These patterns can significantly improve or hurt performance depending on implementation:

### Potential Benefits
- Faster loading through better caching
- Non-blocking operations with workers
- Reduced main thread work
- Better resource utilization

### Potential Drawbacks
- Additional complexity overhead
- Network latency in micro frontends
- Memory usage with multiple contexts
- Build and deployment complexity

Choose patterns based on actual performance requirements and measurement data.
29 changes: 29 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"name": "dev-patterns",
"version": "1.0.0",
"description": "A comprehensive collection of development patterns from vanilla JavaScript to React patterns",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"dev": "echo \"Development server not configured yet\"",
"build": "echo \"Build script not configured yet\""
},
"keywords": [
"design-patterns",
"javascript",
"react",
"performance",
"web-development",
"patterns",
"architecture"
],
"author": "DevPatterns Contributors",
"license": "MIT",
"dependencies": {},
"devDependencies": {},
"repository": {
"type": "git",
"url": "https://github.com/ctrl-hack/DevPatterns.git"
},
"homepage": "https://github.com/ctrl-hack/DevPatterns#readme"
}
Loading