Enterprise-grade user management microservice for the xshopai e-commerce platform
Getting Started β’ Documentation β’ API Reference β’ Contributing
The User Service is a foundational microservice responsible for comprehensive user profile management, address and payment method storage, wishlist management, and role-based access control across the xshopai platform. Built with scalability and reliability in mind, it supports multi-cloud deployments and integrates seamlessly with the broader microservices ecosystem.
|
|
|
|
- Node.js 20+
- MongoDB 8.0+
- Docker & Docker Compose (optional)
- Dapr CLI (for production-like setup)
# Clone the repository
git clone https://github.com/xshopai/user-service.git
cd user-service
# Start all services (MongoDB, service, etc.)
docker-compose up -d
# Verify the service is healthy
curl http://localhost:8002/healthπ§ Without Dapr (Simple Setup)
# Install dependencies
npm install
# Set up environment variables
cp .env.example .env
# Edit .env with your configuration
# Start MongoDB (Docker)
docker run -d --name user-mongodb -p 27018:27017 mongo:8
# Start the service
npm run devπ See Local Development Guide for detailed instructions.
β‘ With Dapr (Production-like)
# Ensure Dapr is initialized
dapr init
# Start with Dapr sidecar
npm run dev:dapr
# Or use platform-specific scripts
./run.sh # Linux/Mac
.\run.ps1 # Windowsπ See Dapr Development Guide for detailed instructions.
| Document | Description |
|---|---|
| π Local Development | Step-by-step local setup without Dapr |
| β‘ Local Development with Dapr | Local setup with full Dapr integration |
| βοΈ Azure Container Apps | Deploy to serverless containers with built-in Dapr |
| π Product Requirements | Complete API specification and business requirements |
| ποΈ Architecture | System design, patterns, and data flows |
| π Security | Security policies and vulnerability reporting |
We maintain high code quality standards with comprehensive test coverage.
# Run all tests
npm test
# Run unit tests only
npm run test:unit
# Run integration tests
npm run test:integration
# Run with coverage report
npm run test:coverage
# Run tests in watch mode
npm run test:watch| Metric | Status |
|---|---|
| Unit Tests | β Passing |
| Code Coverage | β Target 80%+ |
| Security Scan | β 0 vulnerabilities |
user-service/
βββ π src/ # Application source code
β βββ π controllers/ # REST API endpoints
β βββ π services/ # Business logic layer
β βββ π models/ # Mongoose models
β βββ π schemas/ # Reusable subdocuments
β βββ π events/ # Event publishing (Dapr)
β βββ π middlewares/ # Authentication, logging, tracing
β βββ π validators/ # Input validation
β βββ π routes/ # Route definitions
β βββ π core/ # Config, logger, errors
β βββ π database/ # MongoDB connection setup
βββ π tests/ # Test suite
β βββ π unit/ # Unit tests
β βββ π integration/ # Integration tests
β βββ π e2e/ # End-to-end tests
βββ π .dapr/ # Dapr configuration
β βββ π components/ # Pub/sub, secrets, state stores
β βββ π config.yaml # Dapr runtime configuration
βββ π docs/ # Documentation
βββ π docker-compose.yml # Local containerized environment
βββ π Dockerfile # Production container image
βββ π package.json # Node.js dependencies
| Category | Technology |
|---|---|
| π’ Runtime | Node.js 20+ |
| π Framework | Express 5.1+ |
| ποΈ Database | MongoDB 8.0+ with Mongoose ODM |
| π¨ Messaging | Dapr Pub/Sub (RabbitMQ backend) |
| π Event Format | CloudEvents 1.0 Specification |
| π Authentication | JWT Tokens + bcrypt password hashing |
| π§ͺ Testing | Jest with coverage reporting |
| π Observability | Winston structured logging |
# π³ Docker Compose
docker-compose up -d # Start all services
docker-compose down # Stop all services
docker-compose logs -f user # View logs
# π’ Local Development
npm run dev # Run without Dapr
npm run dev:dapr # Run with Dapr sidecar
npm run debug:dapr # Debug with Dapr
# π§ͺ Testing
npm test # Run all tests
npm run test:unit # Run unit tests
npm run test:coverage # Run with coverage
# π Health Check
curl http://localhost:8002/health
curl http://localhost:8002/health/readyWe welcome contributions! Please follow these steps:
- Fork the repository
- Create a feature branch
git checkout -b feature/amazing-feature
- Write tests for your changes
- Run the test suite
npm test && npm run lint
- Commit your changes
git commit -m 'feat: add amazing feature' - Push to your branch
git push origin feature/amazing-feature
- Open a Pull Request
Please ensure your PR:
- β Passes all existing tests
- β Includes tests for new functionality
- β Follows the existing code style
- β Updates documentation as needed
| Resource | Link |
|---|---|
| π Bug Reports | GitHub Issues |
| π Documentation | docs/ |
| π API Reference | docs/PRD.md |
| π¬ Discussions | GitHub Discussions |
This project is part of the xshopai e-commerce platform.
Licensed under the MIT License - see LICENSE for details.
Made with β€οΈ by the xshopai team