This project provides the backend infrastructure for the Educart platform. It handles user authentication, data storage, and API endpoints for various functionalities.
- Express.js: Web application framework for Node.js, used for building the backend services.
- TypeScript: A superset of JavaScript that adds static typing, enhancing code quality and maintainability.
- MongoDB: NoSQL database used for storing user data, course information, and other relevant data.
- Zod: TypeScript-first schema declaration and validation library for ensuring data integrity and validation.
- User Authentication: Securely manages user login and registration using JWT (JSON Web Tokens).
- Data Storage: Utilizes a database (likely MongoDB based on file names) to store user data, course information, and other relevant data.
- API Endpoints: Exposes APIs for accessing and manipulating data, including user management, course management, and other platform-specific features.
- Admin Management: Implements functionalities for managing administrative users and roles.
- Validation: Implements robust validation logic for user input and data using Zod, ensuring data integrity.
- Middleware: Utilizes middleware for handling common tasks such as authentication and authorization, as well as custom validations for different user types.
This project uses npm for package management. To set up the project:
- Prerequisites: Ensure you have Node.js and npm installed on your system.
- Clone the repository:
git clone https://github.com/abhijeet141/EduCart-Backend
- Navigate to the project directory:
cd educart-backend
- Install dependencies:
npm install
- Start the server:
npm start
- Access API endpoints: Once the server is running, you can access the API endpoints using tools like Postman or curl.
- Endpoint:
POST /admin/signup
- Description: Creates a new admin account.
- Input Body:
{ "name": "name", "adminEmail": "adminEmail", "password": "pass" }
- Output Body:
{ "message": "Admin created successfully" }
- Validation: Zod for Input Validation.
- Endpoint:
POST /admin/signin
- Description: Logs in an admin account.
- Input Body:
{ "adminEmail": "adminEmail", "password": "pass" }
- Output Body:
{ "token": "your-token" }
- Endpoint:
POST /admin/courses
- Description: Creates a new course.
- Input Headers:
{ "Authorization": "Bearer <token>" }
- Input Body:
{ "title": "course title", "description": "course description", "price": 100, "imageLink": "https://linktoimage.com" }
- Output Body:
{ "message": "Course created successfully" }
- Endpoint:
GET /admin/courses
- Description: Returns all the courses.
- Input Headers:
{ "Authorization": "Bearer <token>" }
- Output Body:
{ "courses": [ { "id": 1, "title": "course title", "description": "course description", "price": 100, "imageLink": "https://linktoimage.com" } ] }
- Endpoint:
POST /user/signup
- Description: Creates a new user account.
- Input Body:
{ "name": "name", "userEmail": "userEmail", "password": "pass" }
- Output Body:
{ "message": "User created successfully" }
- Validation: Zod for Input Validation.
- Endpoint:
POST /user/signin
- Description: Logs in an user account.
- Input Body:
{ "userEmail": "userEmail", "password": "pass" }
- Output Body:
{ "token": "your-token" }
- Endpoint:
POST /user/courses
- Description: Purchases a course. courseId in the URL path should be replaced with the ID of the course to be purchased.
- Input Headers:
{ "Authorization": "Bearer <token>" }
- Output Body:
{ "message": "Course purchased successfully" }
- Endpoint:
POST /user/purchasedCourses
- Description: Lists all the courses purchased by the user.
- Input Headers:
{ "Authorization": "Bearer <token>" }
- Output Body:
{ "courses": [ { "id": 1, "title": "course title", "description": "course description", "price": 100, "imageLink": "https://linktoimage.com" } ] }
For any inquiries or issues, please contact the project maintainers: