Before getting started, ensure the following prerequisites are installed:
-
MongoDB Shell Server: Ensure that MongoDB is installed and the server is running to support the data storage needs of the application.
-
Node.js: Make sure Node.js is installed to execute the server-side code and manage dependencies.
-
Visual Studio Code (VSCode) Editor: It is recommended to use VSCode for code editing and debugging. Install necessary extensions for Node.js and MongoDB support.
-
Java (for MongoDB): MongoDB might require Java for certain operations. Ensure that Java is installed on your machine.
This project is an Asset Management System designed using MongoDB, ExpressJS, and NodeJS. It allows users to perform CRUD operations on assets and performance metrics through RESTful APIs. The system incorporates user authentication using the passport-local package for login, logout, and signup functionalities.
-
Clone the Repository:
git clone https://github.com/rishisrivastava07/internProject.git cd internProject -
Install Node Modules:
npm install
-
Initialize the Database:
cd init node assetInit.js node performanceInit.js cd ..
- Navigate to the
initfolder and set up the initial data for assets and performance metrics.
- Navigate to the
-
Run the Server:
- If
nodemonis installed:nodemon index.js
- Else, use
nodeinstead ofnodemon:node index.js
- If
-
Access the Server: Open your browser and go to
http://localhost:8080/. -
Login Credentials: First, sign up with an email username and password, then perform the following operations.
-
Perform CRUD Operations: Utilize the provided RESTful APIs to perform Create, Read, Update, and Delete operations on assets and performance metrics.
-
MongoDB:
- Utilized for storing data in collections such as assets, performance metrics, and users. Documentation
-
ExpressJS:
- Framework used for building the web application, handling HTTP requests, and defining API routes. Documentation
-
NodeJS:
- JavaScript runtime used for executing server-side code. Documentation
-
Passport-local:
- Package used for user authentication, including login, logout, and signup functionalities. Documentation1 Documentation2
-
EJS Templates:
- Employed for creating and rendering web pages with dynamic content. Documentation
-
Bootstrap:
- Library used for basic styling and responsiveness of the web pages. Documentation
-
Mongoose:
- ODM (Object-Document Mapper) for MongoDB, facilitating the interaction between the application and the database. Documentation
-
Assets Collection:
- Fields include Asset ID, Asset Name, Asset Type, Location, Purchase Date, Initial Cost, Operational Status.
-
PerformanceMetrics Collection:
- Fields include Asset ID (linking to assets), Uptime, Downtime, Maintenance Costs, Failure Rate, Efficiency.
-
User Collection:
- Handles user authentication with fields like username, password, etc.
-
CRUD Operations:
- Create, Read, Update, Delete operations for both Assets and PerformanceMetrics.
-
Endpoints for Aggregating Data:
- Calculate average downtime.
- Calculate total maintenance costs.
- Identify assets with high failure rates.
-
Authentication:
- Passport-local package is used for user authentication (login, logout, signup).
-
Average Downtime:
- Endpoint to calculate and return the average downtime across all assets.
-
Total Maintenance Costs:
- Endpoint to calculate and return the total maintenance costs across all assets.
-
High Failure Rates:
- Endpoint to identify and return assets with high failure rates.
-
Clean and Efficient Code:
- Followed best practices for code organization, readability, and performance.
-
Thorough Documentation:
- Provided comprehensive documentation for setup, usage, and details of each API endpoint.
-
Testing:
- Included unit tests and integration tests to ensure the functionality of CRUD operations and endpoint logic.
-
Scalability:
- Designed the system with scalability in mind, considering potential future growth in data volume.
-
Error Handling:
- Implemented robust error handling mechanisms to provide meaningful error messages.
-
Security:
- Ensured security by using passport-local for user authentication, validating user inputs, and keeping dependencies up-to-date.
This Asset Management System provides a robust solution for managing assets, performance metrics, and user authentication. It demonstrates proficiency in MongoDB, ExpressJS, NodeJS, and various other technologies, adhering to best practices in development.