The user management microservice for the Babbly platform, handling user profiles, registration, and consuming authentication events from Kafka.
- Backend: ASP.NET Core 9.0
- ORM: Entity Framework Core
- Database: PostgreSQL
- Message Broker: Kafka (Confluent.Kafka client)
- Authentication: Auth0 integration
- User profile management (CRUD operations)
- User search functionality
- Kafka event consumption from Auth Service
- Service-to-service communication
- User data persistence in PostgreSQL
- .NET SDK 9.0 or later
- PostgreSQL 14+
- Apache Kafka (or Docker Compose)
-
Clone the repository:
git clone https://github.com/yourusername/babbly-user-service.git cd babbly-user-service -
Restore dependencies:
dotnet restore
-
Configure the database connection and Kafka:
# Using user secrets for development dotnet user-secrets set "ConnectionStrings:DefaultConnection" "Host=localhost;Database=babbly-users;Username=postgres;Password=your_password" dotnet user-secrets set "Kafka:BootstrapServers" "localhost:9092" dotnet user-secrets set "Kafka:UserTopic" "user-events"
-
Run database migrations:
dotnet ef database update --project babbly-user-service
-
Run the service:
dotnet run --project babbly-user-service/babbly-user-service.csproj
The API will be available at http://localhost:8081.
| Variable | Description | Default |
|---|---|---|
ConnectionStrings__DefaultConnection |
PostgreSQL connection string | - |
KAFKA_BOOTSTRAP_SERVERS |
Kafka broker addresses | localhost:9092 |
KAFKA_USER_TOPIC |
Kafka topic for user events | user-events |
GET /api/users- Get all usersGET /api/users/{id}- Get user by IDGET /api/users/auth0/{auth0Id}- Get user by Auth0 IDGET /api/users/search?term={searchTerm}- Search usersPOST /api/users- Create a new userPUT /api/users/{id}- Update a userDELETE /api/users/{id}- Delete a userGET /api/users/me- Get current authenticated user
POST /api/users/profile- Create or update user profile from Auth0 data
GET /api/health- Service health check
id(PK) - Integer primary keyauth0_id- Unique Auth0 identifierusername- Unique usernameemail- Unique email addressrole- User role (user, admin, etc.)first_name- User's first namelast_name- User's last namecreated_at- Account creation timestampupdated_at- Last update timestamp
id(PK) - Integer primary keyuser_id(FK) - Foreign key to Users tabledisplay_name- Display name for UIprofile_picture- URL to profile picturebio- User biographyaddress- Physical addressphone_number- Contact phone numbercreated_at- Record creation timestampupdated_at- Last update timestamp
Run the service with Docker Compose:
# From the root of the Babbly organization
docker-compose up -d user-serviceOr run with its own Docker Compose (includes PostgreSQL and Kafka):
# From the babbly-user-service directory
docker-compose up -dThe service will be available at http://localhost:8081.
The User Service consumes events from the Auth Service via Kafka:
Event Types:
UserCreated- When a new user registers through Auth0UserUpdated- When a user's profile information is updated
Topic: user-events
The service automatically creates or updates user records based on these events, ensuring user data is synchronized across the system.
- Auth Service: Publishes user authentication events that this service consumes
- API Gateway: Routes user-related requests to this service
- Other Services: Query this service for user information via the API Gateway
This project is licensed under the MIT License - see the LICENSE file for details.