
Varad Ramesh Nikharage
Todo Webapp using NextJs and MongoDB
The TodoApp project is divided into two main parts: the backend and the frontend.
Tags: NextJs, MongoDB, Nodejs
Overview of the TodoApp Project
The TodoApp project is a full-stack application divided into two main parts: the backend and the frontend.
- Backend: Handles server-side logic, including database interactions, user authentication, and API endpoints.
- Frontend: Manages client-side logic, providing a user-friendly interface for seamless interaction.
Technologies Used
Backend
- Node.js: JavaScript runtime for building the backend server.
- Express.js: Web framework for creating APIs and handling server-side logic.
- MongoDB: NoSQL database for storing todos and user information.
- Mongoose: Object Data Modeling (ODM) library for MongoDB to define schemas and interact with the database.
- JWT (JSON Web Tokens): For user authentication and securing API endpoints.
- Nodemailer: For sending email reminders.
- Cron: For scheduling automated email reminders based on due dates.
- dotenv: For managing environment variables.
Frontend
- React.js: JavaScript library for building the user interface.
- React Router: For client-side routing and navigation between pages.
- Axios: For making HTTP requests to the backend API.
- Context API: For global state management (e.g., authentication state).
- CSS: For styling the application and ensuring a consistent design.
Backend Overview
Directory Structure
- index.js: Entry point of the server. Initializes the Express app, connects to MongoDB, sets up middleware, routes, and a reminder cron job.
- db/dbConnect.js: Handles MongoDB connection using Mongoose with the URI from environment variables.
- models/: Defines Mongoose schemas and models.
- Todo.js: Schema for todo items.
- User.js: Schema for users.
- routers/: Defines API routes.
- todoRoutes.js: Routes for CRUD operations on todos with authentication middleware.
- userRoutes.js: Routes for user registration, login, and profile management.
- utils/: Contains utility functions.
- reminderCron.js: Sets up cron jobs to send reminders for pending todos.
- sendEmail.js: Handles email sending via Nodemailer.
- auth.js: Middleware for authenticating users with JWT.
- .env: Stores environment variables (e.g., database URI, JWT secret, email credentials).
- package.json: Lists backend dependencies (e.g., Express, Mongoose, JWT, Nodemailer).
Key Functionalities
- Server Initialization:
- Middleware for CORS and body parsing.
- Routes for todos and users.
- Cron job for email reminders.
- Database Connection: Manages MongoDB interactions via Mongoose.
- Authentication: JWT-based authentication to secure protected routes.
- CRUD Operations: APIs for creating, reading, updating, and deleting todos and users.
- Email Reminders: Automated reminder emails using cron jobs and Nodemailer.
Frontend Overview
Directory Structure
- public/: Contains static assets (HTML template, images).
- index.html: Main HTML file for the React app.
- src/: Source code directory.
- components/: Reusable React components.
- TodoItem.js: Displays individual todos.
- TodoList.js: Displays lists of todos.
- Header.js: Application header.
- Login.js: Login form.
- Register.js: Registration form.
- pages/: Page components for routing.
- HomePage.js: Home page.
- LoginPage.js: Login page.
- RegisterPage.js: Registration page.
- App.js: Main component that manages routing and renders pages.
- index.js: Entry point for rendering the React app.
- api/: Functions for API calls using Axios.
- todoApi.js: Handles todos API requests.
- userApi.js: Handles user-related API requests.
- context/: Global state management.
- AuthContext.js: Manages authentication state.
- styles/: CSS files for consistent design.
- App.css: Main styling file.
- package.json: Lists frontend dependencies (React, React Router, Axios).
Key Functionalities
- User Interface:
- Components for todos, forms, and navigation.
- Routing: React Router for navigating between pages (home, login, register).
- API Integration: Axios-based functions for communicating with the backend.
- State Management: AuthContext provides global state for authentication.
- Styling: Ensures a consistent and responsive design.
Video Demo
Todo Webapp using NextJs and MongoDB