git clone https://github.com/itsanand/user-service.git
git clone https://github.com/itsanand/user-interaction-service.git
git clone https://github.com/itsanand/content-service.git
docker-compose build
docker-compose up
or
docker-compose up --build
http://localhost:7000/user-interaction-service/docs
http://localhost:8000/user-service/docs
http://localhost:9000/content-service/docs
class User:
"""User model"""
__tablename__ = "User"
id: Column = Column(String, primary_key=True) # auto generated id
firstName: Column = Column(String)
lastName: Column = Column(String)
phoneNumber: Column = Column(String, unique=True)
emailID: Column = Column(String, unique=True)
class Interaction:
"""User model"""
__tablename__ = "Interaction"
userID: Column = Column(String)
contentTitle: Column = Column(String)
operationType: Column = Column(Enum(OperationType))
__table_args__ = (PrimaryKeyConstraint("userID", "contentTitle", "operationType"),)
class Content:
"""Content model"""
__tablename__ = "Content"
title: Column = Column(String, primary_key=True)
story: Column = Column(String)
publishedDate: Column = Column(DateTime)
The UserService
class provides asynchronous methods for handling user-related operations in the database using Starlette.
Creates a new user entity, generates a unique ID, and stores the record in the User
table.
- Input:
payload
: A dictionary containing user details.
- Output:
- Returns the created user payload.
Updates user details in the database.
- Input:
payload
: A dictionary containing updated user details.
- Output:
- Returns the updated user payload.
Retrieves user details based on the user ID.
- Input:
user_id
: ID of the user to fetch.
- Output:
- Returns a dictionary containing user details.
Deletes a user record from the database.
- Input:
user_id
: ID of the user to delete.
The Starlette application exposes the following endpoints for user-related operations:
POST /user
: Creates a new user.PATCH /user/{id}
: Updates user details.GET /user/{id}
: Retrieves user details.DELETE /user/{id}
: Deletes a user.