This is a solution to the API - CRUD.(Slightly Modifed From Orginal Problem Statement)
The task involves creating a RESTful API to facilitate Alumni Affairs, where alumni can register, log in, update, and delete their information. Additionally, the API allows current college students to view profiles of registered alumni. Try to implement as many of these.
- Alumni Registration (POST)
- Alumni Login (POST)
- Alumni Profile Update (PUT)
- Alumni Deactivation (DELETE)
- View Alumni Profiles (GET)
The main challenge in this problem is the verification of students. Authenticating and authorizing alumni and students is a moderate challenge in this problem.
Apart from Alumni, I created other models for Admin and Student. Admins are like Institute Administrative staff; they can create and deactivate students from the database. Students cannot register by themselves; they can only log in and update their data. Registered and authorized students could get access to all alumni details. Registered and authorized alumni can also get all other alumni details.
There is no registration for Admins. They are already added to the database.
- Admin Login (POST)
- Admin StudentRegister (POST)
- Admin DeleteStudent (DELETE)
- Student Login (POST)
- Student Details Update (PUT)
- All Alumni Details (GET)
- NodeJS A JavaScript Runtime Built on Chrome's V8 JavaScript Engine
- Express.js A Fast, Unopinionated, and Minimalist Web Framework for Node.js
- MongoDB A Source-available and Document-oriented NoSQL Database
- Mongoose An Object Data Modeling (ODM) Library for MongoDB and Node.js
- JsonWebToken An implementation of JSON Web Tokens.
- Lodash A modern JavaScript utility library delivering modularity, performance & extras.
- Bcrypt A library to help you hash passwords.
- Joi The most powerful schema description language and data validator for JavaScript.
- config Node-config organizes hierarchical configurations for your app deployments.
- Add Unit Tests and Integration Tests - Writing tests in programming is crucial for ensuring code quality and functionality. Unit tests help verify individual components function as expected, catching bugs early. Integration tests confirm different parts of the system work together correctly, identifying issues that may arise from their interaction. Tests provide a safety net for future changes, making sure updates or refactoring don't break existing functionality. They also serve as documentation, illustrating how the code is supposed to work. Overall, testing contributes to building reliable, maintainable software.
- Add winston logger - A logger for just about everything.For logging errors, info messages, debug messages etc ...
- Impliment More Validation using Joi - The most powerful schema description language and data validator for JavaScript.
Project is Structured in Industry Standards in Clean and Readable Code. Following good practices like DRY, KISS, YAGNI, etc.
├── config(Contains all configuration files)
│ └── default.json
| └── custom-environment-variables.json
├── middlewares(Contains all middlewares)
│ ├── adminAuth.js
│ ├── alumniAuth.js
│ └── globalCatch.js
| └── studentAuth.js
| └── invalidRoute.js
| └── validateObjectId.js
├── models(Contains all models)
│ ├── admin.js
│ ├── alumni.js
│ └── student.js
├── package.json(Contains all dependencies)
├── routes(Contains all routehandlers)
│ ├── admin.js
│ ├── alumni.js
│ └── student.js
├── startup(Contains all startup files)
│ ├── config.js
│ ├── db.js
│ └── routes.js
├── index.js(Entry Point)
├── README.md(Readme File)
- GitHub - VLM Lokesh
- Twitter - @nothuman2718
- MailMe
- NodeJS A JavaScript Runtime Built on Chrome's V8 JavaScript Engine
- MongoDB connection String A Source-available and Document-oriented NoSQL Database
- Clone the repo
git clone
- Go to the project directory
cd csea-backend-alumni
- Install NPM packages
npm install
- If Linux or Mac
export jwtPrivateKey=yourPrivateKey export port=yourPortNumber export database=yourMongoDBConnectionString
- If Windows
set jwtPrivateKey=yourPrivateKey set port=yourPortNumber set database=yourMongoDBConnectionString
- Run the server
node index.js
- While running the server on your machine you need fake admin data which you can get from here.Password for all fake data of admin is password itself.After setting up the mongoDB connection string, you can add fake admin data to your database by many ways .One way I suuest is to use MongoDB Compass to import the data from JSON file import to your admin database collection.
- You can use Postman to test the API
- You can use MongoDB Compass to view the database