A RESTful User Management API built with Litestar and PostgreSQL.
- Python 3.12+
- Poetry for Python package management
- PostgreSQL (for local development)
- Docker and Docker Compose (for containerized deployment)
-
Install Poetry (Python package manager):
pip install poetry
-
Install project dependencies:
poetry install
-
Set up your environment variables by copying the example .env file:
cp .env.example .env
Then edit the
.envfile with your database credentials. -
Run the application:
poetry run python -m granian --interface asgi --host 0.0.0.0 --port 8000 src.app:app
The API will be available at http://localhost:8000
-
Make sure Docker and Docker Compose are installed on your system.
-
Build and start the containers:
docker-compose up -d
This will:
- Start a PostgreSQL database container
- Build and start the application container
- Set up the necessary networking between containers
The API will be available at http://localhost:8000
Automatically generated OpenAPI-based documentation at:
http://localhost:8000/schema (for ReDoc),
http://localhost:8000/schema/swagger (for Swagger UI),
http://localhost:8000/schema/elements (for Stoplight Elements)
http://localhost:8000/schema/rapidoc (for RapiDoc)
POST /users/- Create a new userGET /users/- List all usersGET /users/{user_id}- Get a specific userPATCH /users/{user_id}- Update a userDELETE /users/{user_id}- Delete a user
The application uses PostgreSQL as its database. In the Docker setup:
- Database host:
db - Port:
5432 - Database name:
userdb - Username:
postgres - Password:
postgres
For local development, you can modify these settings in your .env file.