GithubHelp home page GithubHelp logo

conduktor / scala-api-template Goto Github PK

View Code? Open in Web Editor NEW
56.0 12.0 10.0 369 KB

Example Scala API to bootstrap new projects

Home Page: https://www.conduktor.io

License: Apache License 2.0

Scala 100.00%
scala zio best-practices template kafka

scala-api-template's Introduction

Conduktor's Scala API template

A template for writing Restful APIs we use at Conduktor.

Requirements

The requirements are:

  • store data into Postgres
  • handle Postgres schema and schema migration programmatically
  • expose domain logic via a RESTful API
  • describe the RESTful API using OpenAPI standard
  • secure the RESTful API with JWT using auth0 service (https://auth0.com) but avoid vendor lock-in
  • use only non-blocking technologies and implement only stateless services to handle high-scale workload
  • leverage Scala type-system and hexagonal architecture to minimize the testing requirements
  • enable testing at every layer: domain logic, end-to-end, data-access, RESTful API, integration of various layer combinations
  • enforce green tests and style conformance using Github actions
  • generate a docker image using Github actions and push it to a repository
  • allows developing proprietary software

Tech

This is the list of technologies we chose to implement our requirements:

Development flow

  • create branches from main
  • merge into main to release Staging via Github action
  • tag main to release Prod via Github action

The stack is deployed on Google Cloud (Cloud Run + Cloud SQL)

Migration

Database provisioning / migration is done via flyway

The migrations are applied at application start to ensure the database is up-to-date with current running code.

Auth

Auth is a JWT validation + data extraction, against an auth0 tenant.

We retrieve the exposed public key from auth0, and use it to validate and decode the bearer token provided in the authorization header

ISSUES

  • Intellij can't type properly skunk's "sql" StringOps macro, using Metals is therefore recommended when dealing with repositories

TODOS

  • use domain-specific errors
  • add streaming endpoints examples (paginated, websocket)

scala-api-template's People

Contributors

dependabot[bot] avatar gaspb avatar guizmaii avatar mbaechler avatar rolang avatar sderosiaux avatar strokyl avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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.