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
The template for building scalable web APIs based on FastAPI, Tortoise ORM and other.

FastAPI and Tortoise ORM. Powerful but simple template for web APIs w/ FastAPI (as web framework) and Tortoise-ORM (for working via database without h

prostomarkeloff 95 Jan 8, 2023
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

null 132 Dec 28, 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

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

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

null 64 Nov 25, 2022
📦 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
Monitor Python applications using Spring Boot Admin

Pyctuator Monitor Python web apps using Spring Boot Admin. Pyctuator supports Flask, FastAPI, aiohttp and Tornado. Django support is planned as well.

SolarEdge Technologies 145 Dec 28, 2022
TODO aplication made with Python's FastAPI framework and Hexagonal Architecture

FastAPI Todolist Description Todolist aplication made with Python's FastAPI framework and Hexagonal Architecture. This is a test repository for the pu

Giovanni Armane 91 Dec 31, 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
A Python command-line utility for validating that the outputs of a given Declarative Form Azure Portal UI JSON template map to the input parameters of a given ARM Deployment Template JSON template

A Python command-line utility for validating that the outputs of a given Declarative Form Azure Portal UI JSON template map to the input parameters of a given ARM Deployment Template JSON template

Glenn Musa 1 Feb 3, 2022
Generic template for python service

Cookie cutter template example Technology stack Flask Gevent UWSGI Poetry Docker Docker-compose Installation pip install cookiecutter cookiecutter git

Churkin Oleg 11 Oct 22, 2022