Web app to display users product complaints based on fastapi and sqlalchemy.
- angular
- python 3.7, 3.8, 3.9
- fastapi
- sqlalchemy (postgreSQL)
- pydantic
cd docker
docker compose up
git clone git@github.com:vyahello/complainer.git
cd complainer
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
python app.py
Please open http://localhost:8000/docs endpoint.
git clone git@github.com:vyahello/complainer.git
cd fe
brew install node
npm install -g @angular/cli
npm install
ng serve --host 0.0.0.0
Please open http://localhost:4200 endpoint.
Please follow /docs
endpoint to see all API endpoints.
-
/register
to register user:- Request sample:
curl -X 'POST' \ 'http://127.0.0.1:8000/register' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "email": "aa@gmail.com", "password": "string", "phone": "string", "first_name": "string", "last_name": "string", "iban": "string" }'
- Response body sample (201 code):
{"token": "XXXXX"}
- Request sample:
-
/login
to login user:- Request sample:
curl -X 'POST' \ 'http://127.0.0.1:8000/login' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -d '{ "email": "aa@gmail.com", "password": "string" }'
- Response body sample (200 code):
{"token": "XXXXX"}
- Request sample:
-
/complaints
(user should be authorized via bearer token):- Get all complaints (
GET
request sample):curl -X 'GET' \ 'http://127.0.0.1:8000/complaints' \ -H 'accept: application/json' \ -H 'Authorization: Bearer XXXX'
- Response body sample (200 code):
[ { "title": "aa@gmail.com", "description": "string", "photo_url": "string", "amount": 20, "id": 1, "created_at": "2022-01-20T11:53:34.532277", "status": "Pending" } ]
- Create complaint (
POST
request sample):curl -X 'POST' \ 'http://127.0.0.1:8000/complaints' \ -H 'accept: application/json' \ -H 'Authorization: Bearer XXXX' \ -H 'Content-Type: application/json' \ -d '{ "title": "aa@gmail.com", "description": "string", "photo_url": "string", "amount": 20 }'
- Response body sample (200 code):
{ "title": "aa@gmail.com", "description": "string", "photo_url": "string", "amount": 20, "id": 1, "created_at": "2022-01-20T11:53:34.532277", "status": "Pending" }
- Get all complaints (
-
/delete
to delete complaint (onlyadmin
user role can delete complaints):- Request sample:
curl -X 'DELETE' \ 'http://127.0.0.1:8000/complaint/2' \ -H 'accept: */*' \ -H 'Authorization: Bearer XXXX'
- Response sample (empty with 204 code)
- Request sample:
-
/users
to get all users (user should be authorized via bearer token):- Request sample:
curl -X 'GET' \ 'http://127.0.0.1:8000/users' \ -H 'accept: application/json' \ -H 'Authorization: Bearer XXXX'
- Response sample (200 code):
[ { "id": 1, "email": "aa@gmail.com", "password": "$2b$12$DiSLHYj54aVrGfQ6BADrAu4/RvJRaiO.eyQsJy08WHuV2HynOKsRe", "first_name": "string", "last_name": "string", "phone": "string", "role": "complainer", "iban": "string" } ]
- Request sample:
-
/users/{user_id}/make-admin
change role to admin (user should be authorized via bearer token):- Request sample:
curl -X 'PUT' \ 'http://127.0.0.1:8000/users/2/make-admin' \ -H 'accept: */*' \ -H 'Authorization: Bearer XXXX'
- Response sample (empty with 204 code)
- Request sample:
-
/users/{user_id}/make-approver
change role to approver (user should be authorized via bearer token):- Request sample:
curl -X 'PUT' \ 'http://127.0.0.1:8000/users/2/make-approver' \ -H 'accept: */*' \ -H 'Authorization: Bearer XXXX'
- Response sample (empty with 204 code)
- Request sample:
-
/complaints/{complaint_id}/approve
approve complaint (user should be authorized via bearer token):- Request sample:
curl -X 'PUT' \ 'http://127.0.0.1:8000/complaints/3/approve' \ -H 'accept: */*' \ -H 'Authorization: Bearer XXXX'
- Response sample (empty with 204 code)
- Request sample:
-
/complaints/{complaint_id}/reject
reject complaint (user should be authorized via bearer token):- Request sample:
curl -X 'PUT' \ 'http://127.0.0.1:8000/complaints/3/reject' \ -H 'accept: */*' \ -H 'Authorization: Bearer XXXX'
- Response sample (empty with 204 code)
- Request sample:
AWS S3 is used to store user complaint photos and get access from the repo. In order to use S3, please fill in the following env vars in your .env file:
AWS_ACCESS_KEY=XXXX
AWS_SECRET_KEY=XXXX
AWS_BUCKET_NAME=XXXX
AWS_REGION=XXXX
AWS SES is used to send email to the recipient in base of complaint approval. In order to use SES, please fill in the following env vars in your .env file:
AWS_ACCESS_KEY=XXXX
AWS_SECRET_KEY=XXXX
SES_REGION=XXXX
create_super_user script is used to create new admin user.
Please make sure that PYTHONPATH
is set to current working directory:
export PYTHONPATH=./
alembic
is used for database migrations (let's say you have added new column to your table).
Init migrations:
alembic init migrations
Generate revision:
alembic revision --autogenerate -m 'Initial'
Set latest db revision:
alembic upgrade head
Please use the following example notes to proceed with docker image provisioning.
Generally, pytest
tool is used to organize testing procedure.
Please follow next command to run unittests:
pytest
Project has Travis CI integration using .travis.yml file thus code analysis (black
, pylint
, flake8
, mypy
and interrogate
) and unittests (pytest
) will be run automatically after every made change to the repository.
To be able to run code analysis, please execute command below:
./analyse-source-code.sh
Note: It is possible to set analyse-source-code.sh
as a pre-commit hook. Please copy shell file to .git/hooks/pre-commit
path.
Please check changelog file to get more details about actual versions and it's release notes.
Author – Volodymyr Yahello. Please check authors file for more details.
Distributed under the MIT
license. See license for more information.
You can reach out me at:
I would highly appreciate any contribution and support. If you are interested to add your ideas into project please follow next simple steps:
- Clone the repository
- Configure
git
for the first time after cloning with yourname
andemail
pip install -r requirements.txt
to install all project dependenciespip install -r requirements-dev.txt
to install all development project dependencies- Create your feature branch (git checkout -b feature/fooBar)
- Commit your changes (git commit -am 'Add some fooBar')
- Push to the branch (git push origin feature/fooBar)
- Create a new Pull Request
All recent activities and ideas are described at project issues page. If you have ideas you want to change/implement please do not hesitate and create an issue.