Code Monkey home page Code Monkey logo

marble-backend's Introduction

Introduction

This repo is the Marble backend implementation:

  • 1 single go app
  • Postgres DB

Getting Started

Setup your environment

Install Go on your laptop (see the version in go.mod).

NB: To handle different versions, you can look at Managing Go installations or use a version manager tool like asdf

Create you own .env file based on .env.example. You can fill it with your own values but it should work locally with the default values (except for third-party services functionalities).

Setup the DB

Launch the postgres DB used by the backend:

docker compose up -d

NB: it creates a marble-backend_postgres-db volume to store PG data.

Firebase emulator suite for local development

Install the Firebase tools:

curl -sL firebase.tools | bash

Then start it using (replace GOOGLE_CLOUD_PROJECT with the value from your .env file):

firebase --project GOOGLE_CLOUD_PROJECT emulators:start --import=./firebase-local-data

NB: The --import flag is used to import the local data into the emulator.

Launch the project

Export your .env file and run the root of the project:

go run . --migrations --server

Using VSCode, you can also run the Migrate and Launch (.env) task in the "Run and debug" tab. This will load your env file, migrate the DB and start the server.

Application flags

The application can be run with the following flags:

  • --migrations: run the migrations
  • --server: run the server
    • in development, it also runs the SeedZorgOrganization usecase script from usecases/seed_usecase
  • --scheduler: run the scenario scheduling job
  • --scheduled-executer: execute scheduled scenario job
  • --data-ingestion: run data ingestion job

NB: .vscode/launch.json contains the configuration to run the app with these flags.

API

The rooting of the application is defined inside api/routes.go.

For further information on the API, you can also refer to the following resources:

  • our API docs for public facing reference
  • the Open API Specification defined in the frontend repository here.

DB Seed and migrations

The application uses goose to manage migrations.

Migrations are located in the repositories/migrations folder.

Execute the program with flags -migrations to run migrations

FAQ

How to update firebase local data ?

  • Run firebase emulator with paramater: --export-on-exit
  • Add user, change options...
  • Exit the emulator
  • commit

How to reset the DB ?

docker volume rm marble-backend_postgres-db deletes the PG volume, useful to reset the app to a known state

In practice, this single-line will delete the stack and create a new one: docker compose down && docker volume rm marble-backend_postgres-db && docker compose up -d

marble-backend's People

Contributors

pascal-delange avatar vivien-marble avatar pascaldelange avatar balzdur avatar roukii avatar github-zoe-cade avatar augustin-marble avatar dependabot[bot] avatar

Stargazers

Grégoire Marabout avatar  avatar Niranjan Anandkumar avatar rorosan avatar  avatar  avatar  avatar

Watchers

Johann Saunier avatar rorosan avatar

marble-backend's Issues

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.