//vibe-coded-todo-appbyimran-baitham

vibe-coded-todo-app

Offline First Todo Application

1
0
1
TypeScript

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.

Next.js
TypeScript
MongoDB
License

โœจ 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

โœ… Rich Todo Metadata

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

  1. Navigate to http://localhost:3000
  2. Youโ€™ll be redirected to /login
  3. Click โ€œSign Upโ€ and create an account
  4. After signup, youโ€™ll be automatically logged in

Creating Your First List

  1. Click the โ€œCreate Listโ€ button
  2. Enter a list name (e.g., โ€œWork Tasksโ€)
  3. Click โ€œDoneโ€undefined

Adding Todos

  1. Make sure a list is selected (shown in the dropdown)
  2. Click โ€œCreate Todoโ€undefined
  3. Fill in the details:
    • undefinedTitle (required)
    • undefinedDescription (optional)
    • undefinedStatus (default: Todo)
    • undefinedCategory (default: Feature)
    • undefinedPriority (default: Normal)
  4. 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:

  1. undefinedGo Offline: Disconnect from the internet
  2. undefinedCreate/Edit: Make changes to todos and lists
  3. undefinedLocal Storage: Changes are saved immediately to localStorage
  4. undefinedReload: Page reloads show cached data with no flash
  5. 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:

  1. undefinedPush Deletions: Sync deleted items to server
  2. undefinedPush Updates: Sync created/modified items
  3. undefinedPull & Merge: Fetch server data and merge with local changes
  4. 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:

  1. Ensure MongoDB is running: mongod --version
  2. Check your MONGODB_URI in .env.local
  3. For MongoDB Atlas, ensure IP whitelist includes your IP

JWT Errors

If you see JWT-related errors:

  1. Verify JWT_SECRET is set in .env.local
  2. Clear cookies and try logging in again
  3. Regenerate JWT_SECRET with a strong random string

Hydration Errors

If you see hydration warnings:

  1. Check that suppressHydrationWarning is on <html> tag
  2. Ensure ThemeProvider is wrapping the app
  3. Clear browser cache and reload

๐Ÿค Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

๐Ÿ“ License

This project is licensed under the MIT License.

๐Ÿ™ Acknowledgments


undefinedBuilt with โค๏ธ using Next.js and TypeScriptundefined

[beta]v0.20.0