This document provides comprehensive guidance for working with the frontend-resources repository, covering both educational content and website codebase development. It complements the AGENTS.md and copilot-instructions.md files and ensures consistent, high-quality contributions.
The frontend-resources repository is an educational knowledge base containing practical examples, implementations, and explanations of:
- JavaScript concepts (ES6+, promises, proxies, etc.)
- Data structures and algorithms (DSA)
- Design patterns (factory, singleton, observer, etc.)
- Utility functions and polyfills (array methods, promise utilities, etc.)
- Machine-coding examples (real-world implementation patterns)
- General frontend knowledge (browser rendering, performance, etc.)
AI agents should help maintain, enhance, and extend this repository while adhering to established conventions and quality standards.
- Generate new educational resources following the established structure
- Create practical, well-commented code examples with modern ES6+ syntax
- Provide clear explanations complemented by use cases and edge cases
- Ensure all code examples follow project conventions (snake_case filenames, emoji headings, etc.)
- Validate TypeScript types where applicable
- Check for completeness: introductions, core concepts, use cases, limitations, summaries
- Follow the established content structure across all markdown files
- Maintain code style consistency (arrow functions,
const-first approach, error handling) - Use emoji prefixes in markdown headings for visual navigation
- Direct users to existing resources when relevant
- Suggest cross-references between related topics
- Identify gaps in coverage for future content
Every educational resource in this repository should follow this structure:
# 🎯 Feature Name: Clear Description
**Target Level:** Junior → Senior → Staff Engineer (if applicable)
**Duration:** 45-60 minutes (for interview-style articles)
**Interview Focus:** Key areas covered
Brief one-liner explaining what this is.Interview Importance: 🔴 Critical / 🟡 Important / 🟢 Good-to-know — One line explaining why this matters in interviews
- What is this concept?
- Why should developers care?
- Quick relevance statement
- For system design articles: include clarifying questions and back-of-envelope estimation
Structure content in layers so readers at different levels get value:
- 🟢 Junior: Core concept, basic implementation, fundamental trade-offs
- 🟡 Senior: Scaling concerns, caching, replication, production hardening
- 🔴 Staff: Distributed systems, global architecture, advanced trade-offs, capacity planning
- Prefer mermaid diagrams (
```mermaid) over ASCII art for architecture, sequence diagrams, and flow charts — the website renders them as interactive SVGs - Use mermaid
graph,sequenceDiagram,flowchartfor system architecture - Use comparison tables for trade-off analysis
- ASCII diagrams are acceptable for inline bit layouts or simple structures
graph TD
Client([Client]) --> LB[Load Balancer]
LB --> API[API Server]
API --> Cache[(Redis Cache)]
API --> DB[(Database)]
- Basic implementation with detailed comments
- Practical, real-world use cases
- Edge cases and error handling
- Variations and alternatives
- 🔍 Dry Run for key algorithms showing step-by-step state
- Use tables to compare alternatives (e.g., 301 vs 302, cache strategies)
- Document WHY you chose one approach over another
- Include what breaks if you make the wrong choice
- 5-6 Q&A pairs with detailed answers
- Include tricky questions interviewers actually ask
- Code snippets in answers where needed
- 3-4 pitfalls with ❌ BAD and ✅ GOOD code examples
- Explanation of what goes wrong and why
- Time & space complexity table for key operations
- For system design: capacity estimation, QPS, storage projections
- Quick reference table mapping concepts to their level
- 5 key takeaways as bullet points
- Best practices
- 2-3 authoritative links (MDN, official docs, seminal papers)
- Cross-references to related articles in this repo
Every article MUST include a quick quiz at the end to test reader understanding. Add 2-3 multiple choice questions using this format:
<!-- quiz-start -->
### Q1: Your question here?
- [ ] Wrong answer option
- [x] Correct answer (mark with x)
- [ ] Another wrong option
- [ ] Yet another option
### Q2: Second question?
- [ ] Option A
- [x] Option B (correct)
- [ ] Option C
### Q3: Third question?
- [x] Correct answer
- [ ] Wrong answer
- [ ] Another wrong answer
<!-- quiz-end -->Quiz Guidelines:
- Include 2-3 questions per article
- Questions should test key concepts from the article
- Each question needs 3-4 options with exactly ONE correct answer marked with
[x] - Mark wrong answers with
[ ] - Questions should be practical, not trivial
- Cover the most important takeaways
- Place quiz at the very end of the article
// ✅ DO: Use modern ES6+ syntax
const processData = (items) => {
return items.filter(item => item.active)
.map(item => ({ ...item, processed: true }));
};
// ❌ DON'T: Avoid var and function declarations
var processData = function(items) {
return items.filter(function(item) { return item.active; });
};
// ✅ DO: Include error handling
function divide(a, b) {
if (b === 0) throw new Error('Division by zero');
return a / b;
}
// ✅ DO: Use const by default, let when needed
const maxRetries = 3; // Never changes
let currentRetry = 0; // Changes in loop
// ✅ DO: Include TypeScript types where applicable
/**
* @param {number[]} arr - Input array
* @returns {number} Sum of array elements
*/
const sum = (arr) => arr.reduce((acc, num) => acc + num, 0);// ✅ DO: Explain "why", not "what"
const cache = new Map(); // Prevent redundant calculations
// ❌ DON'T: State the obvious
const cache = new Map(); // Create a new Map- Use
snake_casefor all filenames - Use descriptive names:
deep_clone.md, notutil1.md - Group related files in folders:
/polyfills/arrays/,/promises/,/general-concepts/
- Use emoji prefixes in headings for visual scanning
- Maintain consistent heading hierarchy (don't skip levels)
- Use code blocks with proper language specification
- Use tables for comparisons
/frontend-resources
├── /ai # AI/LLM integration resources
├── /dsa # Data structures & algorithms
├── /general # Frontend concepts
│ └── /design-patterns # Design patterns (factory, singleton, etc.)
├── /js # JavaScript topics
│ ├── /general-concepts # Core JS concepts (prototype, spread, etc.)
│ ├── /polyfills # Implementations of standard methods
│ │ ├── /arrays # Array method polyfills
│ │ └── /general # Function polyfills (call, bind, apply)
│ ├── /promises # Promise patterns & utilities
│ └── /utils # Utility functions (debounce, deep_clone, etc.)
├── /machine-coding # Practical real-world implementations
└── /system-design # System design resources
All content is completely free and open to everyone. This repository is designed as a community resource for frontend developers to learn and grow their skills.
After adding or modifying content, run:
cd website && node scripts/generate-content.jsThis regenerates:
website/src/data/content.json- Main content datawebsite/public/content.json- For service worker/PWA
- Determine Category: Select the appropriate folder based on content type
- Check for Duplicates: Search existing files to avoid redundancy
- Follow Naming: Use
snake_casewith descriptive names - Apply Structure: Follow the 7-step structure outlined above
- Add Examples: Include 2-3 practical use cases minimum
- Test Code: Verify all code examples are syntactically correct
Before considering a resource complete, verify:
- Title: Clear emoji prefix and descriptive name
- Introduction: Explains concept and relevance (2-3 sentences)
- Core Concepts: Technical details explained clearly
- Code Examples:
- At least 2-3 practical use cases
- Modern ES6+ syntax used
- Error handling included where needed
- Comments explain "why", not "what"
- Limitations: Edge cases or gotchas mentioned
- Summary: Key takeaways provided
- Formatting:
- Markdown syntax correct
- Code blocks have language specified
- Emoji prefixes consistent
- Heading hierarchy maintained
- Cross-References: Links to related resources where applicable
- No Duplicates: Content doesn't overlap significantly with existing files
- Implement standard JavaScript Array methods
- Include edge case handling
- Show both basic and advanced usage
Example: js/polyfills/arrays/map.md
- Simple map implementation
- Comparing with native performance
- Use cases and limitations
- Handling
thiscontext
- Implement helper functions for common tasks
- Provide variations with different approaches
- Include performance considerations
Example: js/utils/deep_clone.md
- Recursive deep cloning
- Handling circular references
- Comparing with structuredClone API
- Performance implications
- Implement promise utilities or patterns
- Explain async flow control
- Include error handling patterns
Example: js/promises/retry.md
- Retry logic implementation
- Exponential backoff pattern
- Handling timeout edge cases
- Real-world use cases (API calls, network requests)
- Real-world implementation challenges
- Complete working examples with commentary
- Include trade-offs and considerations
Example: machine-coding/analytics_sdk.md
- Practical implementation patterns
- Event tracking and batching
- Network considerations
- Error recovery
Use these emoji prefixes consistently throughout markdown files:
| Emoji | Use Case |
|---|---|
| 🎯 | Main topic/feature title |
| 💡 | General concepts |
| 🔄 | Prototype/inheritance patterns |
| 📄 | Basic explanations |
| 🧠 | Detailed explanations/how-it-works |
| ✅ | Correct/recommended approach |
| ❌ | Incorrect/anti-pattern |
| 🧪 | Examples/testing/demonstration |
| 📊 | Arrays/data structures |
| 🔗 | Functions/method binding |
| ⏳ | Promises/async patterns |
| ⏱️ | Timing-related (debounce, throttle) |
| 🧰 | Utilities |
| 🧬 | Deep operations (clone, copy) |
| 🔔 | Event-related |
| 🔍 | Analysis/inspection |
| 📈 | Progress/incremental |
| 🛠️ | Machine-coding |
User Request: "Add a resource about XYZ"
Agent Steps:
- Check if resource exists
- Identify category and placement
- Review similar existing resources for style
- Generate content following the 7-step structure
- Include 2-3 practical examples
- Provide summary
User Request: "Review this code example"
Agent Steps:
- Check against code style conventions
- Verify error handling
- Suggest ES6+ improvements if applicable
- Ensure comments explain "why"
- Validate TypeScript types
User Request: "What topics are missing?"
Agent Steps:
- Scan existing content structure
- Identify common frontend topics not covered
- Suggest priority additions
- Provide outline for new resources
User Request: "Ensure all files follow conventions"
Agent Steps:
- Audit file naming (snake_case)
- Check markdown structure compliance
- Verify code style consistency
- Update emoji prefixes
- Fix heading hierarchy
When creating new content, link to related resources:
### 📚 Related Resources
- See [deep_clone.md](../utils/deep_clone.md) for object cloning
- Learn about [promise utilities](../promises/) for async patterns
- Review [design patterns](../../general/design-patterns/) for architectural approaches- ✅ Follow established code and markdown conventions
- ✅ Provide practical, tested examples
- ✅ Include error handling in examples
- ✅ Link to related existing resources
- ✅ Explain trade-offs and limitations
- ✅ Use modern ES6+ JavaScript
- ✅ Include edge case discussions
- ❌ Create code that contradicts established style
- ❌ Duplicate existing resources
- ❌ Use outdated syntax or patterns (var, function declarations)
- ❌ Omit error handling in practical examples
- ❌ Skip the summary/key takeaways section
- ❌ Leave code examples untested or syntactically incorrect
- ❌ Break existing cross-references when reorganizing
Use this template as a starting point for new educational resources:
# 🎯 Feature Name: One-liner Description
**Target Level:** Junior → Senior → Staff Engineer
**Duration:** 45-60 minutes
**Interview Focus:** Key areas
> **Interview Importance:** 🔴 Critical — Why this matters in interviews.
---
## 1️⃣ Clarifying Questions
Scope the problem before designing:
- Functional requirements (what does it do?)
- Non-functional requirements (scale, latency, availability)
- Constraints (tech stack, regulatory, budget)
### Back-of-Envelope Estimation
| Metric | Value |
|--------|-------|
| Reads/sec | X QPS |
| Writes/sec | Y QPS |
| Storage/year | Z TB |
---
## 2️⃣ Stage 1: Junior Level — Basic Design
What we're building at the simplest level.
\`\`\`mermaid
graph TD
Client([Client]) --> API[API Server]
API --> DB[(Database)]
\`\`\`
### Core Implementation
\`\`\`javascript
// Basic implementation with comments explaining WHY, not WHAT
\`\`\`
### Key Trade-offs
| Decision | Option A | Option B | Recommendation |
|----------|----------|----------|----------------|
| Example | Choice 1 | Choice 2 | Why this one |
---
## 3️⃣ Stage 2: Senior Level — Scaling for Production
What breaks at scale and how to fix it.
\`\`\`mermaid
graph TD
Client([Clients]) --> LB[Load Balancer]
LB --> API1[API Server 1]
LB --> API2[API Server N]
API1 --> Cache[(Redis Cache)]
API1 --> DB[(Primary DB)]
DB --> Replica[(Read Replica)]
\`\`\`
### Caching Strategy
### Rate Limiting
### Database Scaling
---
## 4️⃣ Stage 3: Staff Level — Distributed System
Global architecture, analytics pipelines, abuse prevention.
\`\`\`mermaid
graph TB
subgraph "Region 1"
LB1[LB] --> API1[API Cluster]
API1 --> DB1[(Primary DB)]
end
subgraph "Region 2"
LB2[LB] --> API2[API Cluster]
API2 --> DB2[(Replica)]
end
DB1 -->|"Async Replication"| DB2
\`\`\`
---
## 5️⃣ Data Flow: Complete Request Lifecycle
\`\`\`mermaid
sequenceDiagram
participant C as Client
participant API as API Server
participant Cache as Redis
participant DB as Database
C->>API: Request
API->>Cache: Check cache
Cache-->>API: Hit/Miss
API->>DB: Query (on miss)
DB-->>API: Result
API-->>C: Response
\`\`\`
---
## 6️⃣ Key Trade-offs Summary
| Decision | Option A | Option B | Recommendation |
|----------|----------|----------|----------------|
| Trade-off 1 | ... | ... | ... |
---
## 7️⃣ Common Interview Questions
**Q1: Question here?**
Detailed answer with code if needed.
---
## 8️⃣ Common Pitfalls
### ❌ Pitfall 1: Description
\`\`\`javascript
// ❌ BAD: Why this is wrong
\`\`\`
\`\`\`javascript
// ✅ GOOD: Why this is right
\`\`\`
---
## 🔟 Complexity Summary
| Component | Time | Space |
|-----------|------|-------|
| Operation 1 | O(1) | O(n) |
---
## 🔍 Summary
| Level | What You Add | Key Concepts |
|-------|-------------|--------------|
| 🟢 Junior | ... | ... |
| 🟡 Senior | ... | ... |
| 🔴 Staff | ... | ... |
### Key Takeaways
- Takeaway 1
- Takeaway 2
- Takeaway 3
---
## 📚 Further Reading
- [Resource 1](url) — Description
- [Resource 2](url) — Description
---
<!-- quiz-start -->
### Q1: Question?
- [ ] Wrong
- [x] Correct
- [ ] Wrong
### Q2: Question?
- [x] Correct
- [ ] Wrong
- [ ] Wrong
<!-- quiz-end -->- Clear emoji in title
- 2-3 paragraph introduction
- Code with modern syntax
- 3+ practical examples
- Edge cases covered
- Limitations section
- Summary with key takeaways
- Cross-references provided
- Vague title without emoji
- Single code example
- Missing error handling
- No limitations discussed
- Incomplete summary
- Audit existing content for style consistency
- Identify gaps in coverage
- Suggest improvements to aging resources
- Update examples to modern syntax/practices
- Improve cross-references between topics
- Enhance README with new additions
- Be concise: Point to specific existing resources
- Be specific: Reference file names and sections
- Be helpful: Suggest next steps or related topics
- Be accurate: Verify content exists before referencing
- Be respectful: Acknowledge project conventions in responses
When generating educational articles for interview preparation, use the following comprehensive structure and guidelines:
-
Title with Emoji - Descriptive title
-
Interview Importance Badge - Add after title:
Interview Importance: 🔴 Critical / 🟡 Important / 🟢 Good-to-know — [One line explaining why this matters in interviews]
-
Section 1️⃣ What is X?
- Clear conceptual explanation
- ASCII diagram or visual representation
- Real-world analogy that makes the concept click
-
Section 2️⃣ Why Use X? / Why Does This Matter?
- Table of common use cases with Problem → Solution format
- Performance benefits with concrete numbers if applicable
-
Section 3️⃣ How It Works — Implementation
- Basic implementation with detailed comments
- 🔍 Dry Run - Step-by-step execution trace showing:
- Initial state
- Each step with variable values
- Final output
- Use ASCII tables or diagrams for the dry run
-
Section 4️⃣ Understanding Key Concepts
- Explain WHY each important line of code exists
- What breaks if you remove it?
- Edge cases it handles
-
Section 5️⃣ Production/Advanced Implementation
- Complete implementation with:
- Input validation
- Error handling
- Edge cases covered
- Additional features (cancel, flush, options, etc.)
- Complete implementation with:
-
Section 6️⃣ Real-World Examples
- React hooks implementation (if applicable)
- Practical usage patterns
- Integration examples
-
Section 7️⃣ Comparisons (if applicable)
- vs similar concepts (table format)
- When to use which
- Visual comparison diagram
-
Section 8️⃣ Common Interview Questions
- 5-6 Q&A pairs
- Include tricky questions interviewers ask
- Code snippets for answers where needed
-
Section 9️⃣ Common Pitfalls
- 3-4 pitfalls with:
- ❌ BAD code example
- ✅ GOOD code example
- Explanation of what goes wrong
- 3-4 pitfalls with:
-
Section 🔟 Time & Space Complexity
- Table format with Operation | Complexity | Explanation
-
Summary
- Quick reference table
- 5 key takeaways as bullet points
-
📚 Further Reading
- 2-3 authoritative links (MDN, official docs)
- Use GitHub-flavored markdown
- Use emoji headers (1️⃣, 2️⃣, etc.) for main sections
- Use tables for comparisons, trade-offs, and structured data
- Use code blocks with
javascriptsyntax highlighting - Prefer mermaid diagrams over ASCII art for architecture and flows:
graph TD
A[Component A] --> B[Component B]
B --> C[(Database)]
- ASCII diagrams are still acceptable for inline bit layouts or simple inline visuals
- Include both ❌ BAD and ✅ GOOD examples for pitfalls
- Every implementation MUST have a dry run
- Dry runs should show variable state at each step
- Use horizontal rules (---) to separate major sections
- Keep explanations concise but thorough
- Focus on the "WHAT, WHY, HOW" framework
- Progressive complexity: Structure articles from Junior → Senior → Staff when the topic supports it
- Trade-off tables: Always explain WHY you chose one approach, not just WHAT you chose
Step 1: functionCall(args)
─────────────────────────────────────────────────────────
variable1 = value
variable2 = value
Condition check: expression → result
Action taken: description
State after step: variable1 = newValue
Step 2: Next operation
─────────────────────────────────────────────────────────
...
- Depth over breadth - Explain concepts thoroughly
- Interview-focused - Include what interviewers actually ask
- Practical - Real code that works, not theoretical
- Edge cases - Cover what most tutorials skip
- Memory aids - Include mnemonics or memorable analogies
- No fluff - Every line should add value
The website directory contains the React-based frontend application that serves educational content to users. This section provides guidance for working with the website codebase.
- React 19 - UI component library with hooks
- TypeScript - Static typing for better developer experience
- Vite - Fast build tool and dev server
- Framer Motion - Smooth animations and transitions
- Supabase - Backend-as-a-service (auth, database, storage)
- React Router - Client-side routing
- React Markdown - Markdown rendering with syntax highlighting
website/src/
├── components/ # Reusable UI components (AdUnit, Paywall, QuizSection, etc.)
├── pages/ # Route page components (LibraryRefactored, ResourceDetail, Admin)
├── context/ # React Context for state management
│ ├── AuthContext.tsx
│ ├── SubscriptionContext.tsx
│ ├── ThemeContext.tsx
│ └── ProgressContext.tsx
├── hooks/ # Custom React hooks (useLibraryFilters, useNotifications, etc.)
├── types/ # Centralized TypeScript type definitions (See Type Organization below)
├── lib/ # Utility functions and Supabase integration
├── config/ # Configuration files (filters, categories, constants)
└── data/ # Generated JSON data (content.json from markdown files)
website/api/ # Serverless API routes (Vercel Functions)
├── create-order.js # Razorpay payment order creation
├── premium-content.js # Premium content delivery
├── notify-new-content.js
└── razorpay-webhook.js
website/scripts/ # Build and utility scripts
└── generate-content.js # Content generation from markdown to JSON
| Command | Description |
|---|---|
cd website && npm run dev |
Start Vite dev server (HMR enabled) |
npm run build |
Production build with content generation |
npm run lint |
ESLint code quality check |
npm run type-check |
TypeScript compilation check |
cd .. && node check-distribution.js |
Verify premium/free content split |
All TypeScript types are centralized in src/types/ for consistency:
| File | Types |
|---|---|
types/index.ts |
Re-exports all types |
types/auth.ts |
User, Session, AuthContextValue, AuthMode |
types/content.ts |
Article, ContentItem, CategoryInfo, BreadcrumbItem |
types/filters.ts |
FilterState, FilterPreset, Subcategory, Filter types |
types/notifications.ts |
NotificationState, PermissionResult, PushResult, UseNotificationsReturn |
types/quiz.ts |
QuizQuestion, QuizSectionProps, AnswersState |
types/subscription.ts |
Payment, Razorpay, SubscriptionContextValue, AppliedCoupon |
types/admin.ts |
Coupon, Settings, Message, Stats, AdminTab |
types/theme.ts |
Theme, ThemeContextValue |
types/progress.ts |
ProgressStats, ProgressContextValue, CategoryProgress |
- Use
interfacefor component props - Prefer interfaces over types for object shapes - Import from
src/types/- Never duplicate type definitions across files - Export re-exports - Keep backward compatibility when moving types
- Functional components only - No class components
- Use React.FC - Explicit component type annotations
- Avoid
any- Use proper typing even with// @ts-expect-errorcomments when necessary
| Component | Lines | Issue |
|---|---|---|
| LibraryRefactored.tsx | 2,209 | Filtering/sorting logic needs extraction |
| ResourceDetail.tsx | 1,905 | Mixed rendering/premium/navigation concerns |
| Layout.tsx | 2,100 | Contains 6+ independent features |
| Admin.tsx | 1,182 | Tab-based features should be separate |
QuizSection.tsx- Quiz rendering with parseQuizFromMarkdown utilityPaywall.tsx- Premium content protectionAdUnit.tsx- Ad placementAuthModal.tsx- Sign in/signup flow
| Context | Purpose |
|---|---|
| AuthContext | User authentication and session management |
| SubscriptionContext | Premium content access, payments |
| ProgressContext | Track read articles (Supabase sync) |
| ThemeContext | Dark/light mode, system preferences |
- Markdown files created in root directories (e.g.,
/js/utils/debounce.md) - Run
npm run buildin website directory - generate-content.js scans markdown files and creates
website/src/data/content.json - Premium status automatically assigned based on rules in CLAUDE.md
- Override with frontmatter if specific
premium: true/falseneeded in markdown
- Content data is generated at build time (not fetched dynamically)
- Quiz parsing happens at render time (consider memoization for large lists)
- Progress tracking syncs with Supabase only when signed in
- Use React.lazy + Suspense for large route pages
All serverless functions expect environment variables:
SUPABASE_URL
SUPABASE_ANON_KEY
SUPABASE_SERVICE_ROLE_KEY (for server-side operations)
RAZORPAY_KEY_ID
RAZORPAY_KEY_SECRET- Content not updating? → Run
npm run buildto regenerate content.json - Types missing? → Check
types/index.tshas re-export - Supabase issues? → Verify environment variables in Vercel/local .env
- Premium content not gating? → Check SubscriptionContext.isPremium logic
Last Updated: January 8, 2026 Version: 1.2 Maintained by: frontend-resources repository