API Rest written with Python using Flask and SQLAlchemy.
- Language: Python 3.9
- Technologies: Flask, SQL Alchemy, Marshmallow, Flasgger.
- Database: PostgreSQL 15
-
Docker installed
-
Remember to copy the env.test to .env ( in folder app ) to add environment variables to the application. ( for development )
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:
- test_kuantaz: 5000
The following diagram describe the project structure used for this API
test_kuantaz
β .gitignore
β README.md
β docker-compose.yml
β .pre-commit-config.yaml
β
ββββapp
β β .env.docker
β β .env.test
β β .entrypoint.sh
β β Dockerfile
β β requirements.txt
β β requirements-docker.txt
β β .dockerignore
β β
β β main.py
β β
β ββββconfig Contains system settings
β β β
β β ββββhttp_status_code.py Contains constants for HTTP_CODE for endpoint.
β β β
β β ββββ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
β β
β ββββmodels Contains the models for database
β β
β β ...
β β
β ββββqueries Functions for manage database with models
β β
β β ...
β β
β ββββschemas Contains the schematics (marshmallow) used in the project
β β
β β ...
β β
β ββββservices The application service layer
β β
β β ...
β β
β ββββutils Functions utils
β β
β β ...
β β
β ββββswagger_docs
β β
β ββββtests
β
βββββββββββββ
...
The documentation is in postman and swagger.
swagger : http://localhost:5000/graphql (execute for dev or docker)
postman : documentation on Postman. Remember to add the environment variables in postman ( {{base_url}} )
To use test data, make a Get request for endpoint "/dummy"
Requirements:
- virtualenv
- python3.9
If you want to run the project to develop , you can run the following commands:
cd app
virtualenv -p python3.9 env
source env/bin/activate # in linux or macos
pip install -r requirements
Run with env activated:
python main.py
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.
Requirements: Follow the instructions it says in Development
To run the tests:
cd app
source env/bin/activate
python -m pytest
- Author: Steve Matos, steve.matos.1998@gmail.com