This project provides RESTful FastAPIs for organization management where an admin can perform the following tasks:
- Create an Organization with some information, including an admin user.
- Retrieve an organization by its name.
- Admin login with JWT token generation.
- Create Organization: Admin can create an organization with email, password, and name. A dynamic database is created for the organization in the backend, and the information is stored in a master database.
- Get Organization: Retrieve organization information by name.
- Admin Login: Admin can log in and get a JWT token for subsequent authenticated requests.
- Install Docker Desktop
- Run below script to set up your system for local development using docker:
./app/scripts/docker-dev.sh # Enter password when askedNow run the below commands to run services in Docker:
# Build container images for api and db
docker-compose build
# Start all services in the background
docker-compose up --detachdocker-compose up will start the following services:
db(PostgreSql)api(FastAPi app)
If you want to access the docker container of a particular service, you can do so by running:
# interactive shell session on an already-running service
docker-compose exec -it <service> bash
# For example, to access `api` service interactive shell
docker-compose exec -it api bash
# Run unit tests
docker-compose exec api bash ./run_tests.shOther useful commands:
# View logs of a specific service/container
docker-compose logs <service>
# Stream container logs on host
docker-compose logs api -f --tail 50
# Start a specific service only instead of all
docker-compose up api --detach
# Stop an already running service
docker-compose down api- Endpoint:
POST /org/create - Description: Create an organization with an admin user.
- Payload:
{ "email": "admin@example.com", "password": "adminpassword", "organization_name": "MyOrganization" }
- Endpoint:
GET /org/get - Description: Retrieve organization information by organization name.
- Query Parameter:
organization_name - Example Request:
GET /org/get?organization_name=MyOrganization
- Endpoint:
POST /admin/login - Description: Admin login to get a JWT token.
- Payload:
{ "email": "admin@example.com", "password": "adminpassword" } - Response:
{ "access_token": "your_jwt_token", "token_type": "bearer" }
We use
- Python ~= 3.9
- pip ~= 24.3.x (https://pypi.org/project/pip/)
Use PyEnv to install and use Python 3.9.x.