Giter Site home page Giter Site logo

voice_pg's Introduction

Python Fastapi Template Project withpoetry and Docker

used frameworks/technologies:

How to use the template

  1. Clone the template (Or use the "Use this template" button in GitHub directly!)
    • git clone https://github.com/Salfiii/fastapi-template.git
  2. remove the ".git"-Folder from the local repository to delete the reference to the template project
  3. create a new git repository locally
  4. (install poetry if you want to run it locally)
  5. Install Docker or use a remote machine if you have one
  6. change the project name from "fastapi-template" to something to your likings (you can also run it directly, if you like so)
  7. Run the dockerfile (you can change "fastapi-template" to whatever you like):
    • docker build -t fastapi-template . && docker run -it -p 50001:8080 fastapi-template
    • If you want to remove the dockerfile after exiting the service automatically, add "--rm" before "-it"
    • You can change the port 50001 to whatever port you want to use on your host
  8. Open http://localhost:50001 in your browser and you should see the OpenAPI docs.

Documentation:

file structure:

Contains the general python application.

  • Configuration:
    • GetConfig.py:
      • central Singleton configuration class
      • read the config.ini and provide the values
    • config.ini:
      • Central configuration elements/settings that are used in the code at x areas.
      • Do not make an ambient-specific (test/product) configuration here, this happens via the helmet chart.
  • dal: -If a database is used as a source or sink, this order includes the Connect class and, if necessary, the Orm models. - For relational databases: SQLALCHEMY - for Mongodb: Pymongo
  • GUI:
    • If the application contains a JavaScript GUI, it will be stored here.
  • Routers:
    • contains the definition of the Fastapi residual endpoints
    • config.py
      • Contains the two standard points:
        • "/Actuator/Health":
          • Kubernets Health Check Endpoint. This is used by Kubernetes to check the health status of the service.
          • All mandatory converter should be checked here without which the app cannot work such as the associated database etc.
          • The return format expected by K8S can be viewed in the end point itself.
        • "/config": delivers the configuration stored in the service, see "Getconfig.py". Passwords etc. are hidden.
    • benchmark.py
      • Test points for benchmark purposes. Should be deleted in the final app.
        • Attention: also remove the reference in main.py and under tests!
  • gunicorn_conf.py
    • Configuration file for the WSGI HTTP Server Gunicorn
    • The file is also included in the base image and can be theoretically removed.
  • main.py
    • Entry point/Main in the application.
    • contains no end points/logic. The end points are defined in the routers.

Place for binaries such as CMD apps called from the Python code like Google Tesseract etc. Often empty and can be removed.

Local location for documentation

Application and ambient-specific (test/consumption) helmet files. Contains the following 3 files that define the environment -specific values for test, consumption and prod. Not all values have to be set, then the above defaults are used.

  • Location for the tests which are created with the pytest framework.
  • Documentation for the creation of tests for Fastapi -To carry out the tests: Right-click on the test folder -> "Run 'Pytests' in tests
  • Test examples are included

[tmp] (tmp)

  1. in -is used for the (temporary) storage of input files for the service, e.g. for file upload etc.
    • The path can be called up via the variable "in_folder" of the [Config class] (app/configuration/getConfig.py).
  2. out
    • is used for the (temporary) storage of output files of the service. So if the service writes something, please put it here.
    • The path can be called up via the variable "Out_Folder" of the [Config-Class] (app/configuration/getConfig.py).
  3. Test
    • Can be used to keep scripts etc. to try things out.

- additional files -

  1. Dockerfile
    • Docker file that orchestrates the creation of the Docker container.
    • A documentation of the commands is in the file itself
  2. version.txt
    • Current version of the application. Is shown in the OpenAPI/Swagger Doc surface at the end and should be up at every change to be counted.
  3. .gitlab-ci.yml
    • Gitlab or the associated pipelines check whether such a file exists. If so, the one listed in it Reference to a CI/CD project used to build and provide the project.
  4. README.md
    • Documentation (this!)
  5. gitignore.
    • includes references to files/folders which are to be ignored by git.
    • Everything contained here is not versioned.
  6. pyproject.toml

voice_pg's People

Contributors

gowthaminti avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.