Design: Basic Todo App
The basic todo app follows a simple client-side architecture with local persistence:
The basic todo app follows a simple client-side architecture with local persistence:
The basic todo app follows a simple client-side architecture with local persistence:
┌─────────────────────────────────────────────┐
│ Browser Client │
│ │
│ ┌─────────────┐ ┌─────────────────────┐ │
│ │ UI │ │ Application │ │
│ │ Component │◄─┤ Logic Layer │ │
│ │ Layer │ │ │ │
│ └─────────────┘ └─────────────────────┘ │
│ │ │
│ ▼ │
│ ┌─────────────────┐ │
│ │ Data Storage │ │
│ │ (LocalStorage) │ │
│ └─────────────────┘ │
└─────────────────────────────────────────────┘App
├── TodoList
│ ├── TodoItem (multiple)
│ │ ├── TodoText
│ │ ├── CompleteButton
│ │ └── DeleteButton
│ └── EmptyState
├── TodoInput
│ ├── TextInput
│ └── AddButton
└── TodoStats
├── TotalCount
└── CompletedCountinterface Todo {
id: string; // UUID v4
text: string; // Task description (1-500 chars)
completed: boolean; // Completion status
createdAt: Date; // Creation timestamp
updatedAt: Date; // Last modification timestamp
}**LocalStorage Key:** `todos` **Format:** JSON array of Todo objects
// Example stored data
{
"todos": [
{
"id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"text": "Complete project documentation",
"completed": false,
"createdAt": "2025-07-21T10:00:00.000Z",
"updatedAt": "2025-07-21T10:00:00.000Z"
}
]
}class TodoService {
// CRUD Operations
static addTodo(text: string): Todo
static getTodos(): Todo[]
static updateTodo(id: string, updates: Partial<Todo>): Todo
static deleteTodo(id: string): boolean
static clearCompleted(): number
// Storage Operations
static saveToStorage(todos: Todo[]): void
static loadFromStorage(): Todo[]
static clearStorage(): void
}// Custom events for UI updates
document.dispatchEvent(new CustomEvent('todosChanged', {
detail: { todos: updatedTodos }
}));┌─────────────────────────────────────────┐
│ Todo App Header │
├─────────────────────────────────────────┤
│ ┌─────────────────────┐ ┌───────────┐ │
│ │ New Task Input │ │ Add │ │
│ └─────────────────────┘ └───────────┘ │
├─────────────────────────────────────────┤
│ ☐ Task 1 - Learn JavaScript [Delete] │
│ ☑ Task 2 - Build Todo App [Delete] │
│ ☐ Task 3 - Deploy Application [Delete] │
├─────────────────────────────────────────┤
│ 2 of 3 tasks completed │
└─────────────────────────────────────────┘:root {
--primary-color: #1D2130;
--success-color: #28a745;
--danger-color: #dc3545;
--text-primary: #333333;
--text-secondary: #666666;
--background: #ffffff;
--border: #e0e0e0;
}function sanitizeInput(input) {
return input
.trim()
.slice(0, 500) // Max length limit
.replace(/[<>]/g, ''); // Basic XSS prevention
}<meta http-equiv="Content-Security-Policy"
content="default-src 'self'; script-src 'self' 'unsafe-inline';">// Performance timing
const startTime = performance.now();
// ... operation
const endTime = performance.now();
console.log(`Operation took ${endTime - startTime}ms`);CDN/Static Host (Netlify, Vercel, GitHub Pages)
├── index.html
├── styles.css
├── app.js
└── manifest.json (PWA support)todo-app/
├── public/
│ ├── index.html # Main HTML template
│ ├── favicon.ico # Application icon
│ └── manifest.json # PWA manifest
├── src/
│ ├── components/
│ │ ├── TodoApp.tsx # Main application component
│ │ ├── TodoList.tsx # Todo list display
│ │ ├── TodoItem.tsx # Individual todo item
│ │ ├── TodoForm.tsx # Add/edit todo form
│ │ └── TodoFilters.tsx # Filter controls
│ ├── services/
│ │ └── todoService.ts # Data management & localStorage
│ ├── hooks/
│ │ └── useTodos.ts # Custom hook for todo state
│ ├── utils/
│ │ └── helpers.ts # Utility functions
│ ├── types/
│ │ └── todo.ts # TypeScript type definitions
│ ├── styles/
│ │ ├── index.css # Global styles
│ │ ├── TodoApp.css # Main component styles
│ │ └── responsive.css # Mobile responsive styles
│ ├── App.tsx # Root component
│ └── index.tsx # Application entry point
├── package.json # Dependencies and scripts
├── package-lock.json # Locked dependency versions
└── tsconfig.json # TypeScript configuration**Risk:** Browser storage cleared, causing todo loss **Impact:** High - Complete data loss **Mitigation:**
**Risk:** Features not supported in older browsers **Impact:** Medium - Reduced user base **Mitigation:**
**Risk:** LocalStorage limit reached with many todos **Impact:** Medium - Cannot add new todos **Mitigation:**
**Risk:** Slow performance with large todo lists **Impact:** Low - Poor user experience **Mitigation:**
---
**Review Status:** Ready for review **Next Phase:** Tasks (pending approval)