Code Monkey home page Code Monkey logo

frux-app-server's Introduction

frux-app-server

Frux app server, for the asignature 'Taller de Programación II, FIUBA'

Logo

MIT License GitHub tag (latest SemVer) CoverageTestsLintersBandit

What is Frux?

Frux is the newest crowdfunding app in town.

Before reading this repo, you should probably visit our homepage, with lots of info on the development, latest news, and lots (lots) of documentation.

If you are only interested in the source code, check out the different repos!

Frux is currently being developed by

Installing the project

This project was built with poetry in mind as the means to manage dependencies. You can follow their install guide to install it.

Having poetry installed, the following command will install the project into a new environment.

poetry install

Keep in mind that this will by default install the base requirements as well as the dev requirements.

To install the testing extras, run:

poetry install -E testing

Remember to commit to the repo the poetry.lock file generated by poetry install.

Dev

Installing pre-commit hooks

We use pre-commit to run several code scans and hooks that make the development cycle easier.

pre-commit install
pre-commit install -t pre-push

Adding new dependencies

Check the full poetry docs, but here goes a quick reminder,

poetry add <dependency> [--dev]

Always remember to commit changes to poetry.lock!

Running nox sessions

In order to bootstrap dependencies and run several actions, we are using nox. This way, dependencies are isolated and you get environment replicability.

To run all sessions,

poetry run nox

To run tests session,

poetry run nox --sessions tests [-- pylint arguments]

To run linting session,

poetry run nox --sessions cop

To run bandit session,

poetry run nox --sessions bandit

To run pyreverse session,

poetry run nox --sessions pyreverse

Adding new migrations

poetry run python frux_app_server/manage.py db migrate -m "migration message"

Remember to review them after creating them.

Style guide

frux-app-server follows PEP8.

If you installed the pre-commit hooks you shouldn't worry too much about style, since they will fix it for you or warn you about styling errors. We use the following hooks:

  • black: An opinionated code formatting tool that ensures consistency across all projects using it
  • flake8: a tool to enforce style guide
  • mypy: a static type checker for Python
  • pylint: a source code, bug and quality checker

Docstrings

We use either numpy style or google style docstring formatting. It's usually good to include the following docstrings:

  • module level docstring giving a general overview of what it does.
  • class dosctrings explaining what it is
  • method/functions to explain what it does and what it's parameters are

Testing

We use the pytest framework to test frux-app-server. The easiest way to run tests it through nox with nox --sessions tests.

Docker

Get everything up and running.

cd docker-compose
docker-compose up --build

Running locally

Create an .env file with the following Firebase admin account credentials:

FIREBASE_PRIVATE_KEY="..."
FIREBASE_CLIENT_EMAIL="..."
FIREBASE_PROJECT_ID="..."

Make sure you have the db up to date, and then run locally.

poetry run python frux_app_server/manage.py db upgrade
FLASK_APP=$(pwd)/frux_app_server/app.py poetry run flask run

Deploy to heroku

You will need to have the heroku cli installed and correctly configured for the following steps.

Prior to the actual deploy, make sure to commit your changes.

heroku create frux-app-server
heroku addons:create heroku-postgresql:hobby-dev
heroku stack:set container
git push heroku master
  1. The first step initializes a new heroku app
  2. The second step provisions a postgres addon
  3. The third step sets the app to use a docker image. Instead of using a Procfile, we will use a heroku.yml. Heroku does not yet support a poetry buildpack and exporting a requirements.txt from poetry is pretty cumbersome.
  4. Deploy 🚀

Diagnosing errors

You can fetch logs from the app using heroku logs --tail.

CD

Go to the app on the Heroku Dashboard. On the deploy tab, select "Connect to github" under the "Deployment method" section. Select your repo and you're good to go. Pushes to master will deploy a new version.

DataDog

The heroku Dockerfile includes the DataDog agent. Create a new DataDog API Key from here. Remember to set the following config vars:

heroku config:set DD_API_KEY=<your_api_key>
heroku config:set DD_DYNO_HOST=false
heroku config:set HEROKU_APP_NAME=frux-app-server
heroku config:set DD_TAGS=service:frux_app_server

GitHub Actions

A few pipelines have been set to run on github actions to ensure code quality.

sessions.yml

This workflow runs linters and tests.

Documentation

Swagger

You can visit the swagger docs at 127.0.0.1:5000.

frux-app-server's People

Contributors

camidvorkin avatar fdelmazo avatar jdsanto avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

dvorkincami

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.