FastTodo - Offline-First Task Manager
A production-ready, offline-first todo application with authentication, multi-list organization, and rich task metadata. Built with Next.js 15, TypeScript, and MongoDB.




โจ Features
๐ Authentication & Security
- undefinedSecure Authentication: Email/Password signup and login with JWT
- undefinedHTTP-only Cookies: Session management with secure, HTTP-only cookies
- undefinedRoute Protection: Automatic redirect to login for protected routes
- undefinedData Isolation: Complete user data privacy and separation
- undefinedRobust Logout: Clean session termination with client-side cleanup
๐ Multi-List Organization
- undefinedUnlimited Lists: Create and manage multiple todo lists
- undefinedList Management: Rename and delete lists with ease
- undefinedCascading Delete: Deleting a list removes all associated todos
- undefinedSmart Defaults: Auto-select first list on load
- undefinedList Switching: Quick dropdown navigation between lists
Each todo includes:
- undefinedTitle and Descriptionundefined
- undefinedStatus: Pending | Todo | In Progress | Completed
- undefinedCategory: Bug | Feature | Docs | Improvement | Refactor
- undefinedPriority: Minor | Normal | Important | Critical
- undefinedVisual Badges: Color-coded badges for quick identification
๐ Offline-First Architecture
- undefinedInstant Updates: Optimistic UI for immediate feedback
- undefinedLocalStorage Caching: Persistent offline data storage
- undefinedSmart Sync: Automatic synchronization when online
- undefinedNo Loading Flash: Skeleton loaders during hydration
- undefinedConflict Resolution: Intelligent merge strategy for sync conflicts
๐จ Premium User Experience
- undefinedDark Mode: System, light, and dark theme support
- undefinedSmooth Transitions: No jarring UI changes
- undefinedModern Design: Clean interface with shadcn/ui components
- undefinedResponsive Layout: Works on all screen sizes
- undefinedAccessible: ARIA labels and keyboard navigation
๐ ๏ธ Tech Stack
- undefinedFrontend: Next.js 15 (App Router), React 19, TypeScript
- undefinedState Management: Zustand with localStorage persistence
- undefinedStyling: Tailwind CSS, shadcn/ui components
- undefinedBackend: Next.js API Routes
- undefinedDatabase: MongoDB with Mongoose ODM
- undefinedAuthentication: JWT with jose, HTTP-only cookies
- undefinedTheme: next-themes for dark mode support
๐ Prerequisites
- Node.js 18+ and npm
- MongoDB instance (local or cloud like MongoDB Atlas)
- Git
๐ Installation
1. Clone the repository
git clone https://github.com/yourusername/fasttodo.git
cd fasttodo
2. Install dependencies
npm install
3. Environment Setup
Create a .env.local file in the root directory:
# MongoDB Connection String
MONGODB_URI=mongodb://localhost:27017/fasttodo
# OR for MongoDB Atlas:
# MONGODB_URI=mongodb+srv://username:password@cluster.mongodb.net/fasttodo
# JWT Secret (use a strong random string)
JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
undefinedGenerate a secure JWT secret:undefined
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
4. Run the development server
npm run dev
Open http://localhost:3000 in your browser.
๐ Usage
First Time Setup
- Navigate to
http://localhost:3000
- Youโll be redirected to
/login
- Click โSign Upโ and create an account
- After signup, youโll be automatically logged in
Creating Your First List
- Click the โCreate Listโ button
- Enter a list name (e.g., โWork Tasksโ)
- Click โDoneโundefined
Adding Todos
- Make sure a list is selected (shown in the dropdown)
- Click โCreate Todoโundefined
- Fill in the details:
- undefinedTitle (required)
- undefinedDescription (optional)
- undefinedStatus (default: Todo)
- undefinedCategory (default: Feature)
- undefinedPriority (default: Normal)
- Click โSave changesโundefined
Managing Lists
- undefinedSwitch Lists: Click the list dropdown, select a different list
- undefinedRename List: Click the โฎ menu next to the list dropdown โ โRename listโ
- undefinedDelete List: Click the โฎ menu โ โDelete listโ (deletes all todos in the list)
Offline Usage
The app works perfectly offline:
- undefinedGo Offline: Disconnect from the internet
- undefinedCreate/Edit: Make changes to todos and lists
- undefinedLocal Storage: Changes are saved immediately to localStorage
- undefinedReload: Page reloads show cached data with no flash
- undefinedReconnect: Automatic sync to server when back online
Theme Switching
Click the Sun/Moon icon in the header to toggle between:
- Light mode
- Dark mode
- System preference
๐๏ธ Architecture
Data Flow
User Action
โ
Zustand Store (Optimistic Update)
โ
LocalStorage (Offline Persistence)
โ
API Route (if online)
โ
MongoDB (Server Persistence)
โ
Sync & Merge (on reconnect)
Project Structure
fasttodo/
โโโ src/
โ โโโ app/
โ โ โโโ api/
โ โ โ โโโ auth/[...path]/ # Auth endpoints
โ โ โ โโโ lists/ # List CRUD
โ โ โ โโโ todos/ # Todo CRUD
โ โ โโโ login/ # Login page
โ โ โโโ signup/ # Signup page
โ โ โโโ layout.tsx # Root layout with ThemeProvider
โ โ โโโ page.tsx # Main dashboard
โ โโโ components/
โ โ โโโ ui/ # shadcn/ui components
โ โ โโโ header.tsx # App header with theme toggle
โ โ โโโ todo-list.tsx # Main todo list view
โ โ โโโ todo-card.tsx # Individual todo card
โ โ โโโ todo-dialog.tsx # Create/edit dialog
โ โ โโโ create-list-dialog.tsx # List creation
โ โ โโโ ...
โ โโโ lib/
โ โ โโโ db.ts # MongoDB connection
โ โ โโโ auth.ts # JWT utilities
โ โโโ models/
โ โ โโโ Todo.ts # Todo Mongoose schema
โ โ โโโ List.ts # List Mongoose schema
โ โ โโโ User.ts # User Mongoose schema
โ โโโ store/
โ โ โโโ use-todo-store.ts # Zustand store with sync logic
โ โโโ proxy.ts # Route protection middleware
โโโ package.json
Key Features Implementation
Offline-First Sync
The app uses a sophisticated sync engine in use-todo-store.ts:
- undefinedPush Deletions: Sync deleted items to server
- undefinedPush Updates: Sync created/modified items
- undefinedPull & Merge: Fetch server data and merge with local changes
- undefinedConflict Resolution: Unsynced local changes always take precedence
Authentication Flow
- Login โ JWT signed โ HTTP-only cookie set
- Every API request โ Cookie validated โ User identified
- Protected routes โ
proxy.ts checks auth โ Redirect if needed
๐งช Testing
Manual Testing Checklist
๐ Troubleshooting
MongoDB Connection Issues
If you get connection errors:
- Ensure MongoDB is running:
mongod --version
- Check your
MONGODB_URI in .env.local
- For MongoDB Atlas, ensure IP whitelist includes your IP
JWT Errors
If you see JWT-related errors:
- Verify
JWT_SECRET is set in .env.local
- Clear cookies and try logging in again
- Regenerate JWT_SECRET with a strong random string
Hydration Errors
If you see hydration warnings:
- Check that
suppressHydrationWarning is on <html> tag
- Ensure ThemeProvider is wrapping the app
- Clear browser cache and reload
๐ค Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature)
- Commit your changes (
git commit -m 'Add some AmazingFeature')
- Push to the branch (
git push origin feature/AmazingFeature)
- Open a Pull Request
๐ License
This project is licensed under the MIT License.
๐ Acknowledgments
undefinedBuilt with โค๏ธ using Next.js and TypeScriptundefined