A minimal Todo app using the MERN stack:
- Frontend: React (Vite) in
src/ - Backend: Node/Express in
server/ - Database: MongoDB
No external URLs/APIs are used.
A minimal, well-documented To‑Do application built with the MERN stack (React + Vite frontend, Express backend, MongoDB database). This repository contains a small, production-ready example you can run locally or deploy.
- Create new todos with a simple input
- List todos (newest first)
- Delete todos
- Persistent storage using MongoDB (via Mongoose)
- Small, focused REST API (
/api/todos) that the React frontend consumes - Fast frontend dev experience powered by Vite + React
- Tiny codebase suitable for learning, demos, and Hacktober contributions
- Frontend: React + Vite + TypeScript
- Styling: Tailwind CSS (configured in the project)
- Backend: Node.js + Express
- Database: MongoDB (Mongoose ODM)
- Dev tools: dotenv, nodemon-like watch via
node --watch
- Node.js 18+ and npm
- A MongoDB connection string (MongoDB Atlas or local)
Follow these steps to run the project locally. There are two parts: the backend API and the frontend app. Both live under the App/ folder.
First, clone the repository and navigate to the project directory:
git clone https://github.com/debugfest/mern-todo-list.git
cd mern-todo-listOpen a terminal and run:
cd App/server
npm install
# Create a .env file in App/server with at least:
# MONGODB_URI='your-mongodb-connection-string'
# PORT=5000 # optional, defaults to 5000
# Start the server in watch mode
npm run devThe API endpoints will be available at http://localhost:5000/api/todos by default.
Available endpoints:
- GET /api/todos — fetch all todos (sorted newest first)
- POST /api/todos — create a todo (body:
{ "text": "..." }) - DELETE /api/todos/:id — delete a todo by id
Open another terminal and run:
cd App
npm install
npm run devVite will print the local dev URL (usually http://localhost:5173). Open it to use the app.
mern-todo-list/
├─ App/ # Frontend + backend (single folder for demo)
│ ├─ src/ # React + TypeScript app (Vite)
│ │ ├─ App.tsx
│ │ ├─ main.tsx
│ │ └─ index.css
│ ├─ server/ # Express API
│ │ ├─ config/db.js # MongoDB connection helper
│ │ ├─ models/Todo.js # Mongoose schema for todos
│ │ └─ server.js # Express routes and server boot
│ └─ package.json # Frontend deps & scripts (Vite)
├─ README.md # <-- this file
├─ LICENSE
└─ CONTRIBUTING.md
The Todo model (see App/server/models/Todo.js) has:
text(String, required) — the task descriptioncreatedAt(Date) — timestamp, defaults to now
- Frontend calls the REST API under
/api/todos. - The backend (Express) uses Mongoose to read/write documents in MongoDB.
- Todos are returned to the client as JSON and rendered in the React UI.
The main server file is App/server/server.js and exposes the routes listed in "Quick Start".
- Keep your MongoDB connection string and other secrets out of version control. Add
App/server/.envto your local environment (it's already listed as local-only in the repo). - Example
.env:
MONGODB_URI='your-mongodb-connection-string'
PORT=5000Local development is covered above. For production you can:
- Build the frontend with
cd App && npm run buildand serve the static files from a static host (Vercel, Netlify, or a simple Express static server). - Deploy the API to a Node host (Render, Railway, DigitalOcean App Platform). Make sure to set
MONGODB_URIin the host's environment settings. - Optionally combine by serving the frontend build from the Express server and running the combined app on a single host.
Contributions are welcome — small improvements, bug fixes, styling, and documentation all help!
How to contribute:
- Fork the repository
- Create a feature branch (
git checkout -b feature/awesome) - Commit your changes (
git commit -m "Add awesome feature") - Push (
git push origin feature/awesome) - Open a Pull Request
Please follow the guidelines in CONTRIBUTING.md.
- Express for the lightweight server framework
- Mongoose for easy MongoDB modeling
- Vite + React for a fast frontend dev experience
- Tailwind CSS for utility-first styling
If you found this project helpful, please give it a star ⭐
Made with ❤️ by the project contributors