Giter VIP home page Giter VIP logo

fastclean's Introduction

FastAPI Template

The purpose of this project is to be used as base boiler plate for future web application built with Fast API

Development

Requirements

  • Pyenv: Tool to allow live together multiple python installations at the same time, install
  • Virtualenv: Bring us the possibility of create multiple isolated group of requirements to avoid clash between projects modules.
  • Poetry: Package manager, it comes with some utilities out of the box that are pretty good for projects
  • Docker: Platform to deploy containers straightaway

Launch docker containers

In order to work properly the project needs some satellital applications for this we are using docker (the standar way).

Firstly create .env file from the example .env.dist it should works without a modification but feel free if you need to do adjustments

cp .env.dist .env

Once we have the .env ready we should launch our docker containers

make up

Once inside container you should run init (just if is the first time) and then up

dev init
dev up

Now all the changes that you have in your host machine will be reflected on container code

Extra: work with VS Code

If as me you love Visual Studio code this project is configured to work with, just need one extension:

Once you have it installed just need to launch (with make up) the core project and then select the container in vs code with this you can go to debug menu and click in green button to launch project.

When you are inside the container you could go to VS Code test section and you can appreciate that test discovery is active.

Continuous integration

Requirements

  • Circle CI Account
  • Github account (for tasks)
  • Docker hub account (but you can adapt it for aws or gcp)

Circle CI You need to connect your Github account with Circle CI in order to get the task progress.

Once all is connected every time you push to a branch will run:

  • main, develop:

    • lint
    • test
    • sonarqube gate
    • build image
    • push image
  • any other branch:

    • lint
    • test
    • sonarqube gate

Locally

To activate pre-commit in local environments just need to install pre-commit

pre-commit install

Those will take some time until ends, once has finished every time you create a commit first will validate if match with code requirements and will fail if not

Build and Push image In order to show how the build process should work the project will build and push a code image to Docker hub, for this you need some env vars in circle ci:

  • TAG: Image tag (ex. latest)
  • IMAGE_OWNER: Your docker hub user
  • CORE_IMAGE_NAME: Identifier for core image (ex. fastapi-template-core)
  • CELERY_IMAGE_NAME: Identifier for celery image (ex. fastapi-template-celery)
  • DOCKERHUB_PASS: Docker hub pass for push image
  • DOCKERHUB_USERNAME: Docker hub user for push image

Monitoring

In order to use this project as a base for common projects it must have a way to monitor how the things are in prod environments for this it has a basic integration with Sentry (I love it) to track unhandled errors and verify all the path of it, and new relic in order to track app performance.

this is an optional feature that I recommend to consider but if don't want it you can skip this configuration.

For Sentry we need next env vars:

  • SENTRY_DSN: You can obtain it in your sentry account

For New Relic we need next env vars:

  • NEW_RELIC_CONFIG_FILE: This is almost a constant, usually will have newrelic.ini as value, but you can change it for something that fits you.
  • NEW_RELIC_LICENSE_KEY: Seriously?
  • NEW_RELIC_ENVIRONMENT: This var indicates in what environment is happening the things, and is used for custom configurations.

Additionally you can use Slack to receive some alerts from both services.

Deployment

Important, this project should be considered as an initial template, depending on your business necessities you will need to update a lot of things, so, although I want to create 360 project the deployment section should be coped by you.

fastclean's People

Contributors

hherrera avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.