A robust backend API for managing visitors, built with Node.js, Express, and MongoDB.
-
🔐 Authentication & Authorization
- JWT-based authentication
- Role-based access control (visitor, admin, super-admin, developer)
- Secure password hashing
- Session management
-
👥 Visitor Management
- Visitor registration and profiles
- Visit scheduling
- QR code generation for check-in/out
- Visit history tracking
- Email notifications
-
📊 Admin Features
- Visitor analytics and reporting
- Real-time visitor tracking
- Custom notification settings
- System configuration management
-
🔒 Security
- Rate limiting
- Input validation
- XSS protection
- CORS enabled
- Secure headers
- Node.js (v14 or higher)
- MongoDB (v4.4 or higher)
- npm or yarn
- Clone the repository:
git clone https://github.com/yourusername/visitor-management-api.git
cd visitor-management-api- Install dependencies:
npm install- Create a
.envfile in the root directory:
NODE_ENV=development
PORT=5000
MONGODB_URI=mongodb://localhost:27017/visitor-management
JWT_SECRET=your_jwt_secret_key
JWT_EXPIRES_IN=24h
EMAIL_SERVICE=gmail
EMAIL_USER=your_email@gmail.com
EMAIL_PASS=your_email_password- Start the development server:
npm run devThe API documentation is available at /api-docs when the server is running.
- Development:
http://localhost:5000 - Production:
https://api.example.com
All protected routes require a JWT token in the Authorization header:
Authorization: Bearer <your_token>
POST /api/auth/register- Register a new userPOST /api/auth/login- Login userGET /api/auth/me- Get current user info
POST /api/visitors- Create new visitGET /api/visitors/my-visits- Get visitor's visitsPOST /api/visitors/check-in/:qrCode- Check in visitorPOST /api/visitors/check-out/:qrCode- Check out visitor
GET /api/admin/visitors- Get all visitorsGET /api/admin/analytics- Get visitor analyticsPATCH /api/admin/settings- Update admin settings
npm run dev- Start development server with hot reloadnpm start- Start production servernpm run lint- Run ESLintnpm test- Run testsnpm run docs- Generate API documentation
src/
├── config/ # Configuration files
├── middleware/ # Custom middleware
├── models/ # Database models
├── routes/ # API routes
├── utils/ # Utility functions
└── server.js # Application entry point
Run the test suite:
npm test- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
If you discover any security-related issues, please email security@example.com instead of using the issue tracker.
This project is licensed under the MIT License - see the LICENSE file for details.
For support, email support@example.com or join our Slack channel.
- Express.js
- MongoDB
- JWT
- Swagger/OpenAPI
- All contributors who have helped shape this project