This README describes how our backend application interacts with frontend application(Allumni Management app) including API endpoints. It also supports CRUD (Create, Read, Update, Delete) operations.
Deployed on: render.com
Check Api status @ 👉 https://igit-mca-backend.onrender.com
This backend application provides an API for performing CRUD operations on a set of things, such as users, batch & branch. The API allows clients to Create, Read, Update, and Delete records related to the specified resource.
- Node.js: JavaScript runtime environment
- Express.js: Web application framework for Node.js
- MongoDB: A NoSQL database used for data storage
- Mongoose: MongoDB object modeling for Node.js
- firebase: Uploading image files.
- RESTful API: For implementing CRUD operations
-
Clone the repository:
git clone https://github.com/satyadalei/igit-mca-backend.git cd igit-mca-backend
-
Install dependencies:
npm install
-
Set up the environment variables: Create a
.env
file in the root of the project and define the following variables:MONGO_DB_URL= JWT_SECRET_CODE= DEFAULT_ADMIN_EMAIL= DEFAULT_ADMIN_PASSWORD= FIREBASE_AUTHDOMAIN= FIREBASE_PROJECTID= FIREBASE_STORAGEBUCKET= FIREBASE_MESSAGINGSENDERID= FIREBASE_APPID= FIREBASE_MEASUREMENTID= FIREBASE_APIKEY= FIREBASE_ADMIN_ACC_TYPE = FIREBASE_ADMIN_PROJ_ID = FIREBASE_ADMIN_PRVT_KEY_ID = FIREBASE_ADMIN_PRVT_KEY = FIREBASE_ADMIN_CLIENT_EMAIL = FIREBASE_ADMIN_CLIENT_ID = FIREBASE_ADMIN_AUTH_URI = FIREBASE_ADMIN_TOKEN_URI = FIREBASE_ADMIN_AUTH_PROVIDER = FIREBASE_ADMIN_CLIENT_CERT_URL = FIREBASE_ADMIN_UNIVERSE_DOMAIN =
-
Start the server:
node server.js (Or nodemon server.js)
The project structure follows a typical Express.js application structure:
project-root/
|-- database/
|-- createDefaultAdminUser.js #Creating default admin
|-- database.js #Connecting to database
|-- firebase/
|-- firebaseAdminSdk.js #To catch signedin token
|-- firebaseConfig.js #To upload image to firebase
|-- middlewares/
|-- authorizeuser.js # verifies user auth status
|-- models/
|-- batchModel.js #Batch schema
|-- branchModel.js #Branch schema
|-- userModel.js #user schema
|-- routes/
|-- batchRoute.js # handles batch CRUD
|-- branchModel.js
|-- userModel.js # handles user's CRUD
|-- .env # Environment variable configuration
|-- .gitignore # ignores the file
|-- package-lock.json
|-- package.json
|-- README.md # Project documentation
|-- server.js # Server initialization and entry point
The API supports the following CRUD operations for the specified resource:
#User APIS /api/user/[action]
-
Create a new user:
- Endpoint:
/api/user/createUser
- HTTP Method: POST
- Request Body: JSON object containing resource data
- Endpoint:
-
Login user (Via Google):
- Endpoint:
/api/user/loginViaGoogle
- HTTP Method: POST
- Request Body: uid token provided by google
- Endpoint:
-
Login user (Manual login):
- Endpoint:
/api/user/loginManually
- HTTP Method: POST
- Request Body: JSON object containing
email
&password
- Endpoint:
#Batch APIS /api/batch/[action]
-
Create a batch:
- Endpoint:
/api/batch/createNewBatch
- HTTP Method: POST
- Request HEADERS: JWT token added as token : "token value"
- Note: user has to be
admin
to create a new batch
- Endpoint:
-
Fetch all existing batch:(User auth required)
- Purpose: Showing existing batches in batch page
- Endpoint:
/api/batch/fetchAllBatch
- HTTP Method: GET
- Request HEADERS:
JWT token
added astoken : "token value"
-
Fetch all batch lists:(User auth not required)
- Purpose: Selecting batch for registration
- Endpoint:
/api/batch/fetchAllBatch
- HTTP Method: GET
-
Fetch students of batch:(User auth required)
- Purpose: Showing students of particular batch
- Endpoint:
/api/batch/:batchId/fetchStudents
- HTTP Method: GET
- Request HEADERS:
JWT added
as token : "token value"
#Coordinator APIS:(User auth not required) /api/coordinators/[id_of_batch]
- Purpose: Fetches the coordinators of final year students
- Endpoint:
/api/coordinators/:batchId
- HTTP Method: GET