A Python FastAPI Service for password management and language setup
This is a Python based FastAPI service that provides endpoints for user authentication, password management, and language preference modification.
The design decisions of this service have been based on the discussion here.
Project requires python 3.10.8, pyenv, docker, docker-desktop and poetry.
Install pyenv
tool to manage python version.
# install docker
brew install docker
brew link docker # optional
# install docker-compose
brew install docker-compose
# via docker
docker compose up -d
The application is accessible at http://localhost:3000.
You can also access the API definitons at http://localhost:3000/docs
- Start the containers
docker-compose up -d
- Exec into the postgres docker container and connect to the database
docker-compose exec postgres psql -U postgres -d db
3.Run the SQL script in create_table.sql file located in the db folder
- Start the containers
docker-compose up -d
- Exec into the docker container
docker-compose exec app bash
- Change the working directory to
scripts
directory
cd scripts
- Run the python command
python insert_data.py
pytest
will run all unit tests that you specify in your codebase.
As pytest convention, all files matching test_*.py
will be included.
docker-compose exec app bash
poetry run pytest
- create-password
curl --location 'localhost:3000/v1/customer/create-password' \
--header 'client-version: 2.1.1' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer {JWT_TOKEN}' \
--data-raw '{
"email": "[email protected]",
"password": {PASSWORD},
"confirm_password": {PASSWORD}
}'
- login
curl --location 'localhost:3000/v1/customer/login' \
--header 'client-version: 2.1.1' \
--header 'Content-Type: application/json' \
--data-raw '{
"email": "[email protected]",
"password": "123456"
}'
- Insert the data in the database using the compressed file instead of the uncompressed file
- Handle each exception individually during data insertion
- Test what error you will receive when the input language is anything other than en or de
- Research the pool size of the database and what will be ideal in our use-case
- Generate the secure secret key using a cryptographic library or a password manager and also encode it using base64 encoding
- Research what other fields than customer_id we can use for jwt encoding
- Research which would be the best library for the password encryption
- Add rules for the accepted password when creating a new password
- Research which is the best algorithm from encoding jwt key
- Use Enum for the language column in the customer table definition
- Create Makefile for the docker deployment, database set up and data insertion
- Write (more) tests
- Implement git pre-commit hooks (DONE)
- Use alembic for database migration (it's not working at present)
- Set up CI/CD Pipeline
- Set up deployment
- Integrating Github workflows in the repository