A simple Company Management System built with Express.js and MongoDB. This system allows for basic functionalities like user authentication, employee management, and more. It provides an API for managing employees and authenticating users.
company-management-system/
│
├── config/
│ └── db.js # MongoDB connection configuration
├── controllers/ # API logic for different routes
│ └── employeeController.js
├── models/ # Mongoose models for database
│ └── Employee.js
│ └── User.js # User model for authentication
├── routes/ # Route definitions
│ └── employeeRoutes.js
│ └── authRoutes.js # Authentication routes (login/signup)
├── .env # Environment variables
├── server.js # Main Express server file
└── package.json- Clone the repository:
git clone https://github.com/mscbuild/CHMS_expressJS.git cd CHMS_expressJS- Install dependencies:
Run the following command to install the necessary dependencies:
npm install- Set up environment variables:
Create a .env file in the root directory and define the following environment variables:
MONGO_URI=mongodb://localhost:27017/companyDB
JWT_SECRET=your_jwt_secret_key
PORT=5000MONGO_URI: Your MongoDB connection string. If you're using MongoDB Atlas, use the connection string provided by Atlas.
JWT_SECRET: A secret key for JWT encoding.
PORT: The port the application will run on (default is 5000).
To start the development server, use:
npx nodemon server.jsThe server will run at http://localhost:5000 by default.
{
"name": "John Doe",
"role": "Software Engineer",
"department": "Engineering",
"contact": "[email protected]",
"salary": 70000
}