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
Admin Panel for GinoORM - ready to up & run (just add your models)

Gino-Admin Docs (state: in process): Gino-Admin docs Play with Demo (current master 0.2.3) Gino-Admin demo (login: admin, pass: 1234) Admin

Iuliia Volkova 46 Nov 02, 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
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
Async and Sync wrapper client around httpx, fastapi, date stuff

lazyapi Async and Sync wrapper client around httpx, fastapi, and datetime stuff. Motivation This library is forked from an internal project that works

2 Apr 19, 2022
Adds integration of the Jinja template language to FastAPI.

fastapi-jinja Adds integration of the Jinja template language to FastAPI. This is inspired and based off fastapi-chamelon by Mike Kennedy. Check that

Marc Brooks 58 Nov 29, 2022
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 lightweight web framework based on fastapi

start-fastapi Version 2021, based on FastAPI, an easy-to-use web app developed upon Starlette Framework Version 2020 中文文档 Requirements python 3.6+ (fo

HiKari 71 Dec 30, 2022
Ready-to-use and customizable users management for FastAPI

FastAPI Users Ready-to-use and customizable users management for FastAPI Documentation: https://frankie567.github.io/fastapi-users/ Source Code: https

François Voron 2.4k Jan 01, 2023
python template private service

Template for private python service This is a cookiecutter template for an internal REST API service, written in Python, inspired by layout-golang. Th

UrvanovCompany 15 Oct 02, 2022
A rate limiter for Starlette and FastAPI

SlowApi A rate limiting library for Starlette and FastAPI adapted from flask-limiter. Note: this is alpha quality code still, the API may change, and

Laurent Savaete 565 Jan 02, 2023
Mnist API server w/ FastAPI

Mnist API server w/ FastAPI

Jinwoo Park (Curt) 8 Feb 08, 2022
api versioning for fastapi web applications

fastapi-versioning api versioning for fastapi web applications Installation pip install fastapi-versioning Examples from fastapi import FastAPI from f

Dean Way 472 Jan 02, 2023
Example app using FastAPI and JWT

FastAPI-Auth Example app using FastAPI and JWT virtualenv -p python3 venv source venv/bin/activate pip3 install -r requirements.txt mv config.yaml.exa

Sander 28 Oct 25, 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
🤪 FastAPI + Vue构建的Mall项目后台管理

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

王小右 131 Jan 01, 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

132 Dec 28, 2022
官方文档已经有翻译的人在做了,

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

ApacheCN 27 Nov 11, 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
Publish Xarray Datasets via a REST API.

Xpublish Publish Xarray Datasets via a REST API. Serverside: Publish a Xarray Dataset through a rest API ds.rest.serve(host="0.0.0.0", port=9000) Clie

xarray-contrib 106 Jan 06, 2023
I'm curious if pydantic + fast api can be sensibly used with DDD + hex arch methodology

pydantic-ddd-exploration I'm curious if pydantic + fast api can be sensibly used with DDD + hex arch methodology Prerequisites nix direnv (nix-env -i

Olgierd Kasprowicz 2 Nov 17, 2021