This is the backend repository for the User Management Dashboard, built using Node.js, Express, MongoDB, and other technologies.
- Node.js: JavaScript runtime for server-side development.
- Express.js: Web application framework for Node.js.
- MongoDB: NoSQL database for storing user information.
- bcryptjs: Library for hashing passwords securely.
- Cors: Middleware for enabling Cross-Origin Resource Sharing.
- Nodemon: Development dependency for automatically restarting the server.
- dotenv: Zero-dependency module to load environment variables.
The backend project follows a simple structure:
-
server.js: Entry point for the Express application.
-
routes: Contains route handlers for different endpoints.
- adminRoutes.js: Handles Admin-related API routes.
- userRoutes.js: Handles User-related API routes.
-
controllers: Logic for handling business operations.
- adminControllers.js: Functions for Admin-related operations.
- userControllers.js: Functions for User-related operations.
-
models: Defines Mongoose models for interacting with the MongoDB database.
- AdminModel.js: Model for Admin data.
- UserModel.js: Model for User data.
-
config: Configuration files, including database connection setup.
- POST /api/users/create: Create a new user.
- GET /api/users/all: Get all users.
- POST /api/admin/createadmin: Create a new admin.
- GET /api/admin/getadmins: Get all admins.
-
Clone the repository:
git clone <repository_url> cd backend
-
Install dependencies:
npm install
-
Set up environment variables: Create a .env file with the following content:
PORT=5000 DATABASE_URL=<your_mongodb_uri>
-
Run the server :
npm start