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 simple api written in python/fastapi that serves movies from a cassandra table.

A simple api written in python/fastapi that serves movies from a cassandra table. 1)clone the repo 2)rename sample_global_config_.py to global_config.

Sreeraj 1 Aug 26, 2021
[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
A Python pickling decompiler and static analyzer

Fickling Fickling is a decompiler, static analyzer, and bytecode rewriter for Python pickle object serializations. Pickled Python objects are in fact

Trail of Bits 162 Dec 13, 2022
Python supercharged for the fastai library

Welcome to fastcore Python goodies to make your coding faster, easier, and more maintainable Python is a powerful, dynamic language. Rather than bake

fast.ai 810 Jan 06, 2023
FastAPI Admin Dashboard based on FastAPI and Tortoise ORM.

FastAPI ADMIN 中文文档 Introduction FastAPI-Admin is a admin dashboard based on fastapi and tortoise-orm. FastAPI-Admin provide crud feature out-of-the-bo

long2ice 1.6k Dec 31, 2022
All of the ad-hoc things you're doing to manage incidents today, done for you, and much more!

About What's Dispatch? Put simply, Dispatch is: All of the ad-hoc things you’re doing to manage incidents today, done for you, and a bunch of other th

Netflix, Inc. 3.7k Jan 05, 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
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
📦 Autowiring dependency injection container for python 3

Lagom - Dependency injection container What Lagom is a dependency injection container designed to give you "just enough" help with building your depen

Steve B 146 Dec 29, 2022
asgi-server-timing-middleware

ASGI Server-Timing middleware An ASGI middleware that wraps the excellent yappi profiler to let you measure the execution time of any function or coro

33 Dec 15, 2022
A complete end-to-end machine learning portal that covers processes starting from model training to the model predicting results using FastAPI.

Machine Learning Portal Goal Application Workflow Process Design Live Project Goal A complete end-to-end machine learning portal that covers processes

Shreyas K 39 Nov 24, 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
Fastapi practice project

todo-list-fastapi practice project How to run Install dependencies npm, yarn: standard-version, husky make: script for lint, test pipenv: virtualenv +

Deo Kim 10 Nov 30, 2022
A Prometheus Python client library for asyncio-based applications

aioprometheus aioprometheus is a Prometheus Python client library for asyncio-based applications. It provides metrics collection and serving capabilit

132 Dec 28, 2022
更新 2.0 版本,使用 Python WEB 高性能异步框架 FastAPI 制作的抖音无水印解析下载,采用前后端分离思想!

前言 这个是 2.0 版本,使用现在流行的前后端分离思想重构。 体验网址:https://douyin.bigdataboy.cn 更新日志 2020.05.30:使用 FastAPI 前后端分离重构 2020.05.02:已更新,正常使用 2020.04.27:抖音结构更新,已修复视频有水印。(失

64 Nov 25, 2022
FastAPI on Google Cloud Run

cloudrun-fastapi Boilerplate for running FastAPI on Google Cloud Run with Google Cloud Build for deployment. For all documentation visit the docs fold

Anthony Corletti 139 Dec 27, 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
Backend logic implementation for realworld with awesome FastAPI

Backend logic implementation for realworld with awesome FastAPI

Nik 2.2k Jan 08, 2023
sample web application built with FastAPI + uvicorn

SPARKY Sample web application built with FastAPI & Python 3.8 shows simple Flask-like structure with a Bootstrap template index.html also has a backgr

mrx 21 Jan 03, 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