python template private service

Overview

Template for private python service

This is a cookiecutter template for an internal REST API service, written in Python, inspired by layout-golang. The stack is based on FastAPI and uvicorn and runs on docker and docker-compose.

Service layout

Below is the 1000ft structure of project's modules. Here, red ones are private, green ones are public. Package consists of both public and private sources.

We have some modules:

  • Package. Publish to pypi registry
  • Server. Server has some submodules for configuration handlers, logging and exceptions. Server has all business logic.
  • Integration tests. Integration tests communicate with server as black box. You can read differences between unit and integration tests here

Notice. Bad practice to import any function from server module.

Read more on the project's main principles here. you can also read more on our approach here.

Service

Our service has built-in:

  • prometheus endpoint
  • vault-client
  • healthcheck
  • docker and docker-compose for local development and deploying
  • isolated docker development
  • loguru for logging
  • autogeneration of README.md for your service
  • swagger from FastAPI /docs
  • FastAPI as service
  • Uvicorn as asgi server
  • console server
  • templates for unit and integration tests
  • interface for control your service via makefile
  • completely to publishing package (private pypi-registry)
  • completely to publishing dockerfile (private docker-registry)
  • basic token (api-key) authentication

Usage

To use this project, you need to install cookiecutter:

pip install cookiecutter
cookiecutter https://github.com/U-Company/python-private-service-layout.git

Next, you need to have docker and docker-compose:

sudo apt-get install make docker.io docker-compose

Here you cand find all available commands for communicate with service with a command line.

If you have any errors, you can read about in documentary after project generation. You can communicate with Egor Urvanov by [email protected] or in telegram (@egor_urvanov)

For the full tutorial of service generation you can read here.

Execution and infrastructure

To deploy service WITHOUT dependencies, just run the docker-compose from the root via make:

make run

To deploy service WITH dependencies, just run the docker-compose from the root via make:

make run-full

(Default deployment is based on infrastructure)

That's it! Enjoy

You might also like...
Template for a Dataflow Flex Template in Python

Dataflow Flex Template in Python This repository contains a template for a Dataflow Flex Template written in Python that can easily be used to build D

Discord.py-Bot-Template - Discord Bot Template with Python 3.x

Discord Bot Template with Python 3.x This is a template for creating a custom Di

Fastapi-ml-template - Fastapi ml template with python

FastAPI ML Template Run Web API Local $ sh run.sh # poetry run uvicorn app.mai

IP Denial of Service Vulnerability
IP Denial of Service Vulnerability ")A proof of concept for CVE-2021-24086 ("Windows TCP/IP Denial of Service Vulnerability ")

CVE-2021-24086 This is a proof of concept for CVE-2021-24086 ("Windows TCP/IP Denial of Service Vulnerability "), a NULL dereference in tcpip.sys patc

Flask Project Template A full feature Flask project template.

Flask Project Template A full feature Flask project template. See also Python-Project-Template for a lean, low dependency Python app. HOW TO USE THIS

This project uses Template Matching technique for object detecting by detection of template image over base image.
This project uses Template Matching technique for object detecting by detection of template image over base image.

Object Detection Project Using OpenCV This project uses Template Matching technique for object detecting by detection the template image over base ima

This project uses Template Matching technique for object detecting by detection of template image over base image
This project uses Template Matching technique for object detecting by detection of template image over base image

Object Detection Project Using OpenCV This project uses Template Matching technique for object detecting by detection the template image over base ima

Streamlit-template - A streamlit app template based on streamlit-option-menu
Streamlit-template - A streamlit app template based on streamlit-option-menu

streamlit-template A streamlit app template for geospatial applications based on

Pincer-bot-template - A template for a Discord bot created using the Pincer library

Pincer Discord Bot Template (Python) WARNING: Pincer is still in its alpha/plann

Flask-template - A simple template for make an flask api

flask-template By GaGoU :3 a simple template for make an flask api notes: you ca

Official python API for Phish.AI public and private API to detect zero-day phishing websites

phish-ai-api Summary Official python API for Phish.AI public and private API to detect zero-day phishing websites How it Works (TLDR) Essentially we h

A Python library to access Instagram's private API.

Instagram Private API A Python wrapper for the Instagram private API with no 3rd party dependencies. Supports both the app and web APIs. Overview I wr

Python script to replace BTC adresses in the clipboard with similar looking ones, whose private key can be retrieved by a netcat listener or similar.

BTCStealer Python script to replace BTC adresses in the clipboard with similar looking ones, whose private key can be retrieved by a netcat listener o

Clash of Clans v6.253 private server written in python

cocps Clash of Clans v6.253 private server written in python how2play download server files download Patched APK run Main.py and play Authors Patched

A Python script to backup all repos (public or private) of a user.
A Python script to backup all repos (public or private) of a user.

GithubBackupAllRepos A Python script to backup all repos (public or private) of a user. Features Clone public and private repos Load specified SSH key

Official implementation of
Official implementation of "GS-WGAN: A Gradient-Sanitized Approach for Learning Differentially Private Generators" (NeurIPS 2020)

GS-WGAN This repository contains the implementation for GS-WGAN: A Gradient-Sanitized Approach for Learning Differentially Private Generators (NeurIPS

Integrating Amazon API Gateway private endpoints with on-premises networks

Integrating Amazon API Gateway private endpoints with on-premises networks Read the blog about this application: Integrating Amazon API Gateway privat

Send notification to your telegram group/channel/private whenever a new video is uploaded on a youtube channel!

YouTube Feeds Bot. Send notification to your telegram group/channel/private whenever a new video is uploaded on a youtube channel! Variables BOT_TOKEN

Lazy airdrop based on private temporary ids

LobsterDAO This uses a modified MerkleDistributor, which allows to issue a lazy airdrop using temporary IDs. In this example it uses Telegram chat_id

Comments
  • Error if there is a

    Error if there is a "-" in the project name.

    If the project name contains a "-" sign, then the launch of the project (make run) ends with an error. This is due to replacing the "-" with "_". In addition, the presence of a “-” in the import list also leads to an error.

    opened by userg3003 0
  • Lightness docker

    Lightness docker

    We want to use lightness docker image with python compiler:

    http://nuitka.net/pages/overview.html https://www.youtube.com/watch?v=2fU0SN4UBY0&feature=youtu.be https://martinheinz.dev/blog/17 https://pythonspeed.com/articles/base-image-python-docker-images/

    opened by Hedgehogues 0
Releases(2.2.0)
  • 2.2.0(Aug 26, 2020)

    [docs]. add docs for new structure [docs]. clean the docs

    [feature]. add asserts classes for server [feature]. move unit tests to server [feature]. remove CLI (fire) [feature]. change structure of project [feature]. remove entry_points for cmd

    [bug]. change package name to {{ cookiecutter.service }} [bug]. swagger's service name: package_name -> service_name [bug]. info method function name -> info_method name [bug]. move openapi.json, docs to __cmd.http module [bug]. /info change returned code [bug]. makefile path to app

    [deps]. msgpack>=1.0.0 [deps]. update all package to loguru>=0.5.1; fastapi>=0.61.0; uvicorn>=0.11.8; vault-client>=0.3.4; prometheus_client>=0.8.0; python-clients>=1.0.3; faker>=4.1.2; pytest-asyncio>=0.14.0; pytest>=6.0.1; fire>=0.3.1

    Source code(tar.gz)
    Source code(zip)
  • 2.1.1(Aug 18, 2020)

  • 2.1.0(Aug 17, 2020)

    [docs]. add image for swagger [docs]. Add docs for swagger [feature]. Separate private and public installation [docs]. Change README.md. [bug]. Add script for uvicorn variables of makefile [feature]. add authorization. [feature]. add routers module. [bug]. remove duplicate logger [feature]. add application info for uvicron starter [feature]. add info method with version and service name [feature]. add logging with app, version and environment [feature]. move description of method to separated variables [feature]. Remove class App to function build_app(allow_origins) [bug]. remove names of docker-compose (makefile) [feature]. parametrize docker-compose by env_file [feature]. Add uvicron into make. Add workers [docs]. change README

    Source code(tar.gz)
    Source code(zip)
  • 2.0.3(Aug 4, 2020)

    • [bug]. In info.py it replaced ' to \'
    • [bug]. rename folder {{ cookiecutter.service }} -> {{ cookiecutter.python_package }}
    • [bug]. docker_image cookiecutter's variable is changed
    • [bug]. It is changed name of environment of Anaconda of make config command
    • [feature]. remove docker login from make file
    • [bug]. rename python_package to python_service
    • [bug]. cookiecutter.python_package -> cookiecutter.python_service
    • [bug]. test_create_answer -> test_health for test_health.py
    • [feature]. swagger in prod works
    Source code(tar.gz)
    Source code(zip)
  • 2.0.2(Jun 29, 2020)

    • [FAQ]. Problem with uninstall
    • [deps]. pytest-asyncio==0.12.0
    • [deps]. pytest==5.4.1
    • [feature]. Add default value for VAULT_ENV_FILE, VAULT_ENV for service
    • [feature]. Add default value for VAULT_ENV_FILE, VAULT_ENV for tests
    • [FAQ]. Vault client not authenticated
    • [FAQ]. Not set environments
    • [BUG]. Docker login in makefile
    • [docs]. Add installing doc
    • [feature]. import servicename in test from info.py
    • [bug]. remove service to python_package cookiecutter's environments in code, paths and description
    Source code(tar.gz)
    Source code(zip)
  • 2.0.1(Jun 12, 2020)

  • 2.0.0(Jun 11, 2020)

    • Stable version with docker-image pushing
    • Stable version with python-package pushing
    • Separate publishing into two stage: python publishing and docker publishing
    • Only private docker and pypi registry (not common pypi)
    • Templates for unit and integration tests
    • Add description for common errors
    • Separate common docs into files
    • Add test folder into ./data
    • Add PIP_CONFIG_FILE for automatically dependency of make deps from private repository
    • Add description of cookiecutter variables
    Source code(tar.gz)
    Source code(zip)
  • 1.0.1(Jun 4, 2020)

  • 1.0.0(May 29, 2020)

  • 0.2.0(May 13, 2020)

  • 0.1.0(May 13, 2020)

Owner
UrvanovCompany
UrvanovCompany
A Jupyter server based on FastAPI (Experimental)

jupyverse is experimental and should not be used in place of jupyter-server, which is the official Jupyter server.

Jupyter Server 122 Dec 27, 2022
A Nepali Dictionary API made using FastAPI.

Nepali Dictionary API A Nepali dictionary api created using Fast API and inspired from https://github.com/nirooj56/Nepdict. You can say this is just t

Nishant Sapkota 4 Mar 18, 2022
Minimal example utilizing fastapi and celery with RabbitMQ for task queue, Redis for celery backend and flower for monitoring the celery tasks.

FastAPI with Celery Minimal example utilizing FastAPI and Celery with RabbitMQ for task queue, Redis for Celery backend and flower for monitoring the

Grega Vrbančič 371 Jan 01, 2023
ASGI middleware for authentication, rate limiting, and building CRUD endpoints.

Piccolo API Utilities for easily exposing Piccolo models as REST endpoints in ASGI apps, such as Starlette and FastAPI. Includes a bunch of useful ASG

81 Dec 09, 2022
Reusable utilities for FastAPI

Reusable utilities for FastAPI Documentation: https://fastapi-utils.davidmontague.xyz Source Code: https://github.com/dmontagu/fastapi-utils FastAPI i

David Montague 1.3k Jan 04, 2023
API & Webapp to answer questions about COVID-19. Using NLP (Question Answering) and trusted data sources.

This open source project serves two purposes. Collection and evaluation of a Question Answering dataset to improve existing QA/search methods - COVID-

deepset 329 Nov 10, 2022
Social Distancing Detector using deep learning and capable to run on edge AI devices such as NVIDIA Jetson, Google Coral, and more.

Smart Social Distancing Smart Social Distancing Introduction Getting Started Prerequisites Usage Processor Optional Parameters Configuring AWS credent

Neuralet 129 Dec 12, 2022
官方文档已经有翻译的人在做了,

FastAPI 框架,高性能,易学,快速编码,随时可供生产 文档:https://fastapi.tiangolo.com 源码:https://github.com/tiangolo/fastapi FastAPI 是一个现代、快速(高性能)的 Web 框架,基于标准 Python 类型提示,使用

ApacheCN 27 Nov 11, 2022
FastAPI Learning Example,对应中文视频学习教程:https://space.bilibili.com/396891097

视频教学地址 中文学习教程 1、本教程每一个案例都可以独立跑,前提是安装好依赖包。 2、本教程并未按照官方教程顺序,而是按照实际使用顺序编排。 Video Teaching Address FastAPI Learning Example 1.Each case in this tutorial c

381 Dec 11, 2022
python fastapi example connection to mysql

Quickstart Then run the following commands to bootstrap your environment with poetry: git clone https://github.com/xiaozl/fastapi-realworld-example-ap

55 Dec 15, 2022
Auth for use with FastAPI

FastAPI Auth Pluggable auth for use with FastAPI Supports OAuth2 Password Flow Uses JWT access and refresh tokens 100% mypy and test coverage Supports

David Montague 95 Jan 02, 2023
Install multiple versions of r2 and its plugins via Pip on any system!

r2env This repository contains the tool available via pip to install and manage multiple versions of radare2 and its plugins. r2-tools doesn't conflic

radare org 18 Oct 11, 2022
MLServer

MLServer An open source inference server to serve your machine learning models. ⚠️ This is a Work in Progress. Overview MLServer aims to provide an ea

Seldon 341 Jan 03, 2023
Htmdf - html to pdf with support for variables using fastApi.

htmdf Converts html to pdf with support for variables using fastApi. Installation Clone this repository. git clone https://github.com/ShreehariVaasish

Shreehari 1 Jan 30, 2022
Lung Segmentation with fastapi

Lung Segmentation with fastapi This app uses FastAPI as backend. Usage for app.py First install required libraries by running: pip install -r requirem

Pejman Samadi 0 Sep 20, 2022
🤪 FastAPI + Vue构建的Mall项目后台管理

Mall项目后台管理 前段时间学习Vue写了一个移动端项目 https://www.charmcode.cn/app/mall/home 然后教程到此就结束了, 我就总感觉少点什么,计划自己着手写一套后台管理。 相关项目 移动端Mall项目源码(Vue构建): https://github.com/

王小右 131 Jan 01, 2023
This is a FastAPI application that provides a RESTful API for the Podcasts from different podcast's RSS feeds

The Podcaster API This is a FastAPI application that provides a RESTful API for the Podcasts from different podcast's RSS feeds. The API response is i

Sagar Giri 2 Nov 07, 2021
FastAPI framework plugins

Plugins for FastAPI framework, high performance, easy to learn, fast to code, ready for production fastapi-plugins FastAPI framework plugins Cache Mem

RES 239 Dec 28, 2022
A simple web to serve data table. It is built with Vuetify, Vue, FastApi.

simple-report-data-table-vuetify A simple web to serve data table. It is built with Vuetify, Vue, FastApi. The main features: RBAC with casbin simple

11 Dec 22, 2022
[rewrite 중] 코로나바이러스감염증-19(COVID-19)의 국내/국외 발생 동향 조회 API | Coronavirus Infectious Disease-19 (COVID-19) outbreak trend inquiry API

COVID-19API 코로나 바이러스 감염증-19(COVID-19, SARS-CoV-2)의 국내/외 발생 동향 조회 API Corona Virus Infectious Disease-19 (COVID-19, SARS-CoV-2) outbreak trend inquiry

Euiseo Cha 28 Oct 29, 2022