A robust REST API built with Node.js, Express, and MongoDB for managing customer interactions across multiple locations.
- Location Management: Track multiple business locations
- Customer Tracking: Manage customer profiles and their associated locations
- Activity Logging: Record and retrieve customer interactions and activities
- Data Analytics: Group and analyze customer activities by location and date range
- RESTful Architecture: Clean and standardized API endpoints
- Error Handling: Comprehensive error handling and validation
- MongoDB Integration: Efficient data storage and retrieval with Mongoose
- Runtime: Node.js
- Framework: Express.js
- Database: MongoDB
- ODM: Mongoose
- Testing: Jest (planned)
- Documentation: Swagger/OpenAPI (planned)
customer-management-api/
├── config/
│ └── config.js # Configuration variables
├── controllers/
│ ├── customerLogsController.js
│ └── locationController.js
├── middleware/
│ ├── errorHandler.js
│ └── validators.js
├── models/
│ ├── customer.js
│ ├── CustomerLog.js
│ └── location.js
├── routes/
│ ├── customerLogs.js
│ └── locations.js
├── scripts/
│ └── seed.js # Database seeding script
├── .env
├── .gitignore
├── app.js # Application entry point
├── package.json
└── README.md
- Node.js (v14 or higher)
- MongoDB (v4.4 or higher)
- npm or yarn
- Clone the repository
git clone https://github.com/danyroyal/opiniion-test.git
cd opiniion-test
- Install dependencies
npm install
- Create a
.env
file in the root directory
MONGODB_URI=mongodb://localhost:27017/opiniion-test-task
PORT=3000
- Seed the database with sample data
node mock/seed.js
- Start the server
npm start
GET /api/locations
Response:
{
"count": 5,
"locations": [
{
"_id": "65b1234567890abcdef12345",
"name": "Downtown Branch",
"createdDate": "2023-05-15T10:30:00.000Z"
}
]
}
POST /api/customerLogs
Request Body:
{
"locationId": "65b1234567890abcdef12345",
"startDate": "2024-01-01",
"endDate": "2024-01-31"
}
Response:
{
"locationId": "65b1234567890abcdef12345",
"locationName": "Downtown Branch",
"dateRange": {
"start": "2024-01-01",
"end": "2024-01-31"
},
"totalCustomers": 3,
"totalLogs": 12,
"customers": [...]
}
{
name: String,
createdDate: Date
}
{
locationId: ObjectId,
firstName: String,
lastName: String,
email: String,
phone: String,
createdDate: Date
}
{
customerId: ObjectId,
type: String,
text: String,
date: Date
}
# Run tests (coming soon)
npm test
- User authentication and authorization
- Request rate limiting
- API documentation with Swagger
- Comprehensive test coverage
- Docker containerization
- Pagination for large datasets
- Advanced filtering and search capabilities
- Audit logging
- Real-time notifications
- Open a Pull Request
This project is licensed under the MIT License - see the LICENSE.md file for details
- Muhammad Danial - Initial work - (https://github.com/danyroyal)
- Express.js team for the amazing framework
- MongoDB team for the robust database
- All contributors who help to improve this project# opiniion-test