API GraphQL for Catalog System written with Python using FastAPI, SQL Alchemy, Strawberry.
The project this deployed in http://18.217.21.15:8000/graphql
- Language: Python 3
- Technologies: FastAPI, SQL Alchemy, Strawberry
- Database: SQLite
-
Docker installed
-
Remember to copy the env.test to .env ( in folder app ) to add environment variables to the application.
Clone or Fork the project.
Run docker-compose
command inside docker-python folder.
-
Building the containers:
docker-compose build
-
Starting the services:
docker-compose up -d
-
Stoping the services:
docker-compose stop
By default the service will run under the following port:
- my_store_service: 8000
The following diagram describe the project structure used for this API
my_store
β .gitignore
β README.md
β docker-compose.yml
β .pre-commit-config.yaml
β .flake8
β
ββββapp
β β .env.test
β β main.py
β β
β ββββconfig Contains system settings
β β β
β β ββββaws.py Functions to manage aws (ses)
β β β
β β ββββconstants.py Constants used in the project
β β
β β ββββdatabase.py Functions and constants for manage database
β β
β β ββββexceptions.py Contains the custom exceptions for project
β β
β β ββββenvironment.py Environment variables
β β
β ββββgql Contains the definition of the mutations and queries of the Graphql
β β
β β ...
β β
β ββββmodels Contains the models for database
β β
β β ...
β β
β ββββschemas Contains the most complex data structures.
β β β
β β ββββgraphql Contains data structures for graphql
β β β
β β β ...
β β β
β β ββββpydantic Contains pydantic data structures used in the project
β β
β β ...
β β
β ββββservices The application service layer
β β
β β ...
β β
β ββββutils Functions utils
β β
β β ...
β β
β ββββtest
β
βββββββββββββ
...
In graphql the documentation is in the same console so if you want to review the doc, just go to the endpoint http://localhost:8000/graphql
But there is a documentation on Postman if you want to check it out. Remember to add the environment variables in postman ( {{session-token}}, {{base_url_graphql}} )
This project will use jwt authentication with permission class in strawberry (Framework of GraphQL)
For authentication:
With the access token, you just put in the headers in the query to the graphql endpoint:
There is already a user created for the admin with the credentials:
email: "steve.matos.1998@gmail.com"
password: test
Requeriments:
- pipenv installed
If you want to run the project to develop , you can run the following commands:
cd app
pipenv install --dev
pipenv shell
Run with uvicorn in the app folder:
uvicorn main:app --reload
If you want to contribute to the project, Remember that pre-commit is used for uniform code styling, so you'll need to install the pre-commit.
To run the tests:
cd app
pipenv install --dev
pipenv shell
python -m pytest
This project is deployed in aws with ECS (Elastic Container Service).
Application architecture is as follows:
For sending mail, the sandbox version of SES is being used in the deploy, so it can only be sent to manually verified users in the identities,
for the moment the only user verified in SES is steve.matos.1998@gmail .com
- Author: Steve Matos, steve.matos.1998@gmail.com