The User Service is responsible for user registration, authentication, and profile management and update within our microservices architecture.
- User registration
- JWT-based authentication
- Profile management and Profile Update
- Event emission for user-related actions
- Node.js
- Express.js
- MongoDB
- Kafka for event streaming
- JWT for authentication
-
Navigate to the user-service directory:
cd user-service
-
Install dependencies:
npm install
-
Set up environment variables: Create a
.env
file in the user-service directory and add:PORT=5000 MONGO_URL=mongodb://localhost:27017/user-db KAFKA_BROKER=localhost:29092 JWT_SECRET=your_jwt_secret_here
-
Start the service:
npm start
The service is automatically deployed when you run docker-compose up
from the root directory. It will be available at http://localhost:5000
.
POST /api/users/register
: Register a new userPOST /api/users/login
: Authenticate a user and receive a JWTGET /api/users/find/:userId
: Get user profile by IDPUT /api/users/update/:userId
: Update user profile by IDGET /api/users/allusers
: Get all users
This service emits the following Kafka events:
- "user-registered": When a new user is registered
- "user-updated": When a user's profile is updated