A RESTful API backend for a Todoist clone application built with Node.js, Express, and MongoDB.
- User Management: User registration, authentication, and profile management
- Todo Management: Create, read, update, and delete todos with priorities and deadlines
- Project Management: Organize todos into projects with custom colors and favorites
- JWT Authentication: Secure API endpoints with JSON Web Tokens
- Input Validation: Robust input validation using Zod schemas
- Error Handling: Comprehensive error handling and validation
- Security: Helmet.js for security headers and CORS protection
- Runtime: Node.js
- Framework: Express.js
- Database: MongoDB with Mongoose ODM
- Authentication: JWT (JSON Web Tokens)
- Validation: Zod schema validation
- Security: Helmet.js, bcrypt for password hashing
- Development: Nodemon for hot reloading
Before running this project, make sure you have the following installed:
- Node.js (v16 or higher)
- npm or yarn
- MongoDB (local installation or MongoDB Atlas account)
git clone <your-repository-url>
cd todoist-clone/backendnpm install-
Copy the example environment file:
cp env.example .env
-
Edit the
.envfile with your configuration:# Server Configuration PORT=3000 NODE_ENV=development # Database Configuration MONGODB_URI=mongodb://localhost:27017/todoist-clone # JWT Configuration JWT_USER=your-super-secret-jwt-key-here
- Install MongoDB locally
- Start MongoDB service
- Create a database named
todoist-clone
- Create a MongoDB Atlas account
- Create a new cluster
- Get your connection string
- Update
MONGODB_URIin your.envfile
npm startNODE_ENV=production npm startThe server will start on http://localhost:3000
POST /users/signup- User registrationPOST /users/signin- User loginGET /users/profile- Get user profile (protected)
GET /todos- Get all todos (protected)POST /todos- Create a new todo (protected)GET /todos/:id- Get a specific todo (protected)PUT /todos/:id- Update a todo (protected)DELETE /todos/:id- Delete a todo (protected)
GET /projects- Get all projects (protected)POST /projects- Create a new project (protected)GET /projects/:id- Get a specific project (protected)PUT /projects/:id- Update a project (protected)DELETE /projects/:id- Delete a project (protected)
backend/
├── src/
│ ├── config/ # Database configuration
│ ├── controllers/ # Route controllers
│ ├── middleware/ # Custom middleware (auth)
│ ├── models/ # Mongoose models
│ ├── routes/ # API routes
│ └── utils/ # Utility functions
├── index.js # Main server file
├── package.json # Dependencies and scripts
└── .env # Environment variables
| Variable | Description | Required | Default |
|---|---|---|---|
PORT |
Server port number | Yes | 3000 |
NODE_ENV |
Environment mode | Yes | development |
MONGODB_URI |
MongoDB connection string | Yes | - |
JWT_USER |
JWT secret key | Yes | - |
# Add test script to package.json when tests are implemented
npm test# Add prettier/eslint scripts when configured
npm run format
npm run lint# Add seed script when implemented
npm run seed- Password Hashing: Bcrypt for secure password storage
- JWT Authentication: Secure token-based authentication
- Input Validation: Zod schemas for request validation
- Security Headers: Helmet.js for security headers
- CORS Protection: Configurable CORS settings
The application includes comprehensive error handling:
- Validation errors (400)
- Authentication errors (401)
- Not found errors (404)
- Conflict errors (409)
- Internal server errors (500)
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the ISC License.
For support and questions, please open an issue in the repository.