A robust todo list application built with Angular for the frontend and Node.js with MongoDB for the backend. This app allows users to manage tasks efficiently with a secure and intuitive interface.
- Create Todo List: Add new tasks with details like title, description, status, and due date.
- CRUD Operations: Perform Create, Read, Update, and Delete operations on todos.
- Filter Todos: Filter tasks by status (e.g., completed, pending) or due date.
- Fields Validation: Ensure valid input data for todo fields (e.g., required fields, data formats) on the backend.
- MongoDB Integration: Store and manage todos in a MongoDB database for persistent data storage.
- Security Layer:
- ETag Disabled: Prevents caching-related vulnerabilities by disabling ETag headers.
- Helmet: Enhances API security by setting secure HTTP headers.
- Rate Limiting: Limits each IP to 100 requests per 15-minute window to prevent abuse.
angular-node-todo-app/
├── frontend/ # Angular frontend
│ ├── Dockerfile.frontend # Dockerfile for frontend
│ ├── src/ # Angular source code
│ ├── package.json # Frontend dependencies
│ └── angular.json # Angular configuration
├── backend/ # Node.js backend
│ ├── Dockerfile # Dockerfile for backend
│ ├── server.js # Backend entry point
│ ├── package.json # Backend dependencies
│ └── (other backend files)
├── docker-compose.yml # Docker Compose configuration (optional)
└── README.md # This file
- Node.js (v18 or later)
- Angular CLI (v17 or later)
- MongoDB (local or cloud instance, e.g., MongoDB Atlas)
- Docker (optional, for containerization)
- Docker Compose (optional, for multi-container setup)
-
Clone the Repository:
git clone https://github.com/roybarak80/angular-node-todo-app.git cd angular-node-todo-app
-
Set Up the Frontend:
cd frontend npm install npm run build
-
Set Up the Backend:
cd ../backend npm install
Ensure MongoDB is running (local or cloud). Set the MongoDB connection string in your environment variables (e.g.,
.env
file):MONGODB_URI=mongodb://localhost:27017/todo-app
Install additional backend dependencies for security:
npm install helmet express-rate-limit
-
Run the App Locally:
- Frontend: From the
frontend/
directory:Openng serve
http://localhost:4200
in your browser. - Backend: From the
backend/
directory:The backend API runs onnode server.js
http://localhost:3000
(adjust port if customized).
- Frontend: From the
The backend includes the following security measures in server.js
:
const express = require('express');
const helmet = require('helmet');
const rateLimit = require('express-rate-limit');
const app = express();
// Disable ETag
app.disable('etag');
// Apply Helmet for secure headers
app.use(helmet());
// Apply rate limiting
app.use(rateLimit({
windowMs: 15 * 60 * 1000, // 15 minutes
max: 100, // 100 requests per IP
message: { error: 'Too many requests, please try again later.' }
}));
-
Build Docker Images: From the
frontend/
directory:docker build -t roybarak1/angular-todo-frontend:latest -f Dockerfile.frontend .
From the
backend/
directory:docker build -t roybarak1/node-todo-backend:latest .
-
Run with Docker Compose (if
docker-compose.yml
is set up):docker-compose up --build
Access the app at
http://localhost
(frontend) andhttp://localhost:3000
(backend API). Ensure MongoDB is accessible to the backend container (e.g., viaMONGODB_URI
environment variable). -
Push to Docker Hub:
docker login docker push roybarak1/angular-todo-frontend:latest docker push roybarak1/node-todo-backend:latest
- Add a Todo: Enter task details (title, description, status, due date) in the frontend. The backend validates fields before saving to MongoDB.
- Edit/Delete: Modify or remove tasks using the edit/delete buttons.
- Filter Tasks: Use filter options to view tasks by status or sort by due date.
- Security: The backend enforces rate limits and secure headers to protect the API.
Contributions are welcome! Please fork the repository and submit a pull request.
- Fork the repo.
- Create a new branch (
git checkout -b feature/your-feature
). - Commit your changes (
git commit -m 'Add your feature'
). - Push to the branch (
git push origin feature/your-feature
). - Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.
For questions or feedback, reach out via GitHub Issues.