GithubHelp home page GithubHelp logo

anthrax3 / scala-play-realworld-example-app Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gothinkster/scala-play-realworld-example-app

0.0 2.0 0.0 1.56 MB

Exemplary real world application built with Scala & Play

Home Page: https://realworld.io

License: MIT License

Scala 100.00%

scala-play-realworld-example-app's Introduction

RealWorld Example App using Scala and Play Framework

Scala & Play Framework codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the RealWorld spec and API.

Build Status Coverage Status

Demo with current state of backend implementation and with complete frontend

Referential demo

This codebase was created to demonstrate a fully fledged fullstack application built with Scala & Play Framework including CRUD operations, authentication, routing, pagination, and more.

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

Getting started

You need installed:

  • Java >= 8,
  • sbt.

Then:

  • sbt test -- to run tests,
  • sbt run -- to run server in dev mode.

Project's structure

Application is divided into three main modules: commons, authentication and core.

For simplification they are not represented as sbt's subprojects/submodules. Module is represented as single class with Components suffix, for instance AuthenticationComponents or ArticleComponents.

Core module contains main business logic which is also divided into articles and users (and other) modules. Class RealWorldApplicationLoader contains "description" of whole application, it combines all modules together and set up things like logging, evolutions (db migrations), etc.

Compile time dependency injection is used.

Security

Pack4j is used to simplify JWT authentication implementation. Generally authentication is implemented as external module implementing core's API's (core.authentication.api). The idea behind it was to allow replacing module's implementation without touching core's code.

Database

Project uses a H2 in memory database by default, it can be changed in the application.conf. Tests override that properties to use H2 nevertheless, H2 is used for convenience and can be changed easily as well in the TestUtils.config.

Proper JDBC driver needs to be added as dependency in build.sbt.

Additionally to avoid Slick's dependent types all over the place, static imports to concrete Slick's profile are used. For instance import slick.jdbc.H2Profile.api.{DBIO => _, MappedTo => _, Rep => _, TableQuery => _, _}. They should be changed as well in case of changing underlying database. It looks ugly but imho still better than usage of dynamic import through dependent types (check out Slick examples to see that).

Slick was used to implement data access layer mainly because it is supported by Lightbend. It also looks more "scalish" and gives perspective for JPA standard in Java ecosystem.

======

Feel free to comment and improve current implementation!

scala-play-realworld-example-app's People

Contributors

alonski avatar ericsimons avatar esakkiraj avatar optikfluffel 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.