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 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
FastAPI Boilerplate

FastAPI Boilerplate Features SQlAlchemy session Custom user class Top-level dependency Dependencies for specific permissions Celery SQLAlchemy for asy

Hide 417 Jan 07, 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
Piccolo Admin provides a simple yet powerful admin interface on top of Piccolo tables

Piccolo Admin Piccolo Admin provides a simple yet powerful admin interface on top of Piccolo tables - allowing you to easily add / edit / filter your

188 Jan 09, 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
An extension for GINO to support Starlette server.

gino-starlette Introduction An extension for GINO to support starlette server. Usage The common usage looks like this: from starlette.applications imp

GINO Community 75 Dec 08, 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
Recommend recipes based on what ingredients you have at home

🌱 MyChef 📦 Overview MyChef is an application that helps you decide what meal to make based on what you have at home. Simply enter in ingredients you

Logan Connolly 44 Nov 08, 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
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
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
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
更新 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
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
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
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
Twitter API with fastAPI

Twitter API with fastAPI Content Forms Cookies and headers management Files edition Status codes HTTPExceptions Docstrings or documentation Deprecate

Juan Agustin Di Pasquo 1 Dec 21, 2021
Deploy an inference API on AWS (EC2) using FastAPI Docker and Github Actions

Deploy an inference API on AWS (EC2) using FastAPI Docker and Github Actions To learn more about this project: medium blog post The goal of this proje

Ahmed BESBES 60 Dec 17, 2022
Online Repo Browser

MSYS2 Web Interface A simple web interface for browsing the MSYS2 repos. Rebuild CSS/JS (optional): cd frontend npm install npm run build Run for Dev

MSYS2 64 Dec 30, 2022