Lookup is a lightweight course management platform built with Node.js, Express, and MongoDB. This project serves as a practical exercise in backend development, covering essential concepts like RESTful APIs, user authentication, and database management.
- User Authentication: Secure user registration and login with JWT.
- Admin Dashboard: Admins can create, update, and manage courses.
- Course Catalog: Users can browse all available courses.
- Course Enrollment: Users can purchase/enroll in courses.
- Secure & Validated: Uses
bcryptfor password hashing andzodfor robust input validation. - Simple Frontend: A clean, responsive frontend built with vanilla HTML, CSS, and JavaScript.
- Backend: Node.js, Express.js
- Database: MongoDB with Mongoose
- Authentication: JSON Web Tokens (JWT)
- Validation: Zod
- Security: bcrypt
- Development: Nodemon
- Node.js (v14 or higher)
- npm
- MongoDB (A connection string from MongoDB Atlas is recommended)
-
Clone the repository:
git clone https://github.com/TalibMushtaq/lookup.git cd lookup -
Install dependencies:
npm install
-
Set up environment variables: Create a
.envfile in the root directory and add the following variables. You can use the.env.examplefile as a template.# Database Configuration MONGODB_URI=your_mongodb_connection_string # Server Configuration PORT=3000 # JWT Secrets JWT_Admin=your_admin_secret_key JWT_User=your_user_secret_key
-
Development Mode (with auto-reloading):
npm run dev
-
Production Mode:
npm start
The server will be running at http://localhost:3000.
lookup/
├── .env # Environment variables
├── database.js # MongoDB connection and schemas
├── index.js # Main server entry point
├── package.json
├── middlewares/
│ └── auth.js # Authentication middleware (JWT)
├── public/ # Frontend static files
│ ├── index.html
│ ├── script.js
│ └── styles.css
├── routes/
│ ├── admin.js # Admin-specific routes
│ ├── course.js # Course-related routes
│ └── user.js # User-specific routes
└── validators/
└── schemas.js # Zod validation schemas
All endpoints are prefixed with /api.
| Method | Endpoint | Description | Access |
|---|---|---|---|
POST |
/admin/signup |
Register a new admin account. | Public |
POST |
/admin/signin |
Log in as an admin. | Public |
POST |
/admin/course |
Create a new course. | Admin |
PUT |
/admin/course/:courseId |
Update an existing course. | Admin |
GET |
/admin/course/bulk |
Get all courses created by admin. | Admin |
POST |
/user/signup |
Register a new user account. | Public |
POST |
/user/signin |
Log in as a user. | Public |
GET |
/user/purchased |
Get all purchased courses. | User |
GET |
/course/preview |
Get a preview of all courses. | Public |
POST |
/course/purchase/:courseId |
Purchase a course. | User |
This project is licensed under the MIT License - see LICENSE