Git Product home page Git Product logo

realworld-tapir-zio's Introduction

RealWorld Example App

Scala+ZIO+Quill+tapir codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API.

This codebase was created to demonstrate a backend application built with Scala, ZIO, Quill and tapir including CRUD operations, authentication, routing, pagination, and more.

We've gone to great lengths to adhere to the Scala's & ZIO's community styleguides & best practices.

For more information on how to this works with other frontends/backends, head over to the RealWorld repo.

How it works

Aplication stack

This application uses:

  • Scala, a functional & object-oriented JVM programming language
  • ZIO, a type-safe, composable asynchronous and concurrent programming library for Scala
  • tapir, a declarative, type-safe web endpoints libarry
  • Quill, compile-time language integrated queries for Scala
  • Json Web Token for authorization
  • SQLite as the database
  • HikariCP to manage the database connection pool
  • Flyway for database migrations
  • Swagger to expose API documentation
  • sbt-revolver for hot reloading when code changes while the app is running

Additionally, executing Realworld Postman collection is part of CI acceptance tests.

Architecture

The application has been divided by functionalities into the following packages:

  • common
  • db
  • auth
  • articles
  • users

The common package contains auxiliary structures that are used in the project. The db package has the necessary data to operate the database. The auth package contains the tools needed to authorize the user.

The articles package consist of 3 smaller submodules: core, comments and users. Each of them has a similar structure. They contain specific endpoints, service them using services and communicate with the database using repositories. These packages include domain classes and clearly separated api layer that contains "the contract", i.e. the endpoint descriptions, without logic.

Project ASCII tree:

articles
├── comments
│   ├── api
│   │   ├── CommentCreateData 
│   │   ├── CommentCreateRequest
│   │   ├── CommentResponse
│   │   ├── CommentsEndpoints
│   │   └── CommentsListResponse
│   ├── Comment
│   ├── CommentAuthor
│   ├── CommentsRepository
│   ├── CommentsServerEndpoints
│   └── CommentsService
├── core
│   ├── api
│   │   ├── ArticleCreateData
│   │   ├── ArticleCreateRequest
│   │   ├── ArticleResponse
│   │   ├── ArticlesEndpoints
│   │   ├── ArticlesListResponse
│   │   ├── ArticleUpdateData
│   │   └── ArticleUpdateRequest
│   ├── Article
│   ├── ArticleAuthor
│   ├── ArticlesFilters
│   ├── ArticlesRepository
│   ├── ArticlesServerEndpoints
│   └── ArticlesService
└── tags
    ├── api
    │   ├── TagsEndpoints
    │   └── TagsListResponse
    ├── TagsRepository
    ├── TagsService
    └── TagsServerEndpoints
auth
└── AuthService    
common
├── BaseEndpoints
├── Configuration
├── CustomDecodeFailureHandler 
├── DefectHandler
├── ErrorInfo
├── ErrorMapper
├── Exceptions
├── NoneAsNullOptionEncoder
└── Pagination
db
├── Db
├── DbConfig
└── DbMigrator
users
├── api
│   ├── ProfileResponse
│   ├── UserLoginData
│   ├── UserLoginRequest
│   ├── UserRegisterData
│   ├── UserRegisterRequest
│   ├── UserResponse
│   ├── UsersEndpoints
│   ├── UserUpdateData
│   └── UserUpdateRequest
├── Profile
├── User
├── UsersRepository
├── UsersServerEndpoints
├── UsersService
└── UserWithPassword
Endpoints
Main

Getting started

If you don't have sbt installed already, you can use the provided wrapper script, sbtx:

./sbtx -h # shows an usage of a wrapper script
./sbtx compile # build the project
./sbtx test # run the tests
./sbtx run # run the application (Main)

For more details check the sbtx usage page.

Otherwise, if sbt is already installed, you can use the standard commands:

sbt compile # build the project
sbt test # run the tests
sbt run # run the application (Main)

Swagger documentation by default is available at URL: http://localhost:8080/docs

realworld-tapir-zio's People

Contributors

wydra98 avatar ericsimons avatar mergify[bot] avatar tpacuszkapl avatar jelinski avatar bartma11 avatar fawnpug avatar github-actions[bot] avatar geromegrignon avatar adamw avatar alonski avatar kciesielski avatar nob13 avatar esakkiraj avatar optikfluffel avatar segmentationfaulter avatar softwaremill-ci 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.