Git Product home page Git Product logo

fullstack-reason's Introduction

Fullstack Reason Demo

This project shows a minimal fullstack ReasonML application. It has a

  • Backend web server that compiles to a native binary using the Esy/dune compilation toolchain
  • Frontend ReasonReact component that compiles to JavaScript using the BuckleScript toolchain
  • Shared business logic used by both of the above

This is a proof-of-concept; you can customize it to your needs.

Try it out

Development mode

Follow these steps:

  1. Install NodeJS (one-time setup)
  2. Install Esy (one-time setup): npm install --global esy@latest
  3. Set up the backend project: esy install (one-time setup but will take a while to compile dependencies like SSL so grab your favourite beverage)
  4. Run npm install (or use pnpm to save some disk space)
  5. Run the services defined in Procfile either manually on different terminals, or using a process manager like Foreman/Overmind/Hivemind
  6. Browse the frontend: http://localhost:5200/

Production mode

You can also try out the app without the Webpack dev server:

  1. Assuming the above builds have already been done
  2. Put production assets in the dist directory: npm run dist
  3. Run the backend app: esy b dune exec backend/App.exe
  4. Browse the frontend (note, different port than above, this is being served directly from the backend app): http://localhost:8080/

Correctly caches the JS bundle–with cache busting!

How it works

This project pulls together:

Project layout

These are the significant parts of the project:

  • backend/: contains the sources for the backend executable
  • esy.lock/: a lock directory used by Esy to capture precise dependency information
  • frontend/: contains the sources for the frontend ReasonReact app
  • shared/: contains sources shared between the backend and frontend
  • bsconfig.json: BuckleScript project configuration
  • dune-project: Dune project configuration (for the native build)
  • esy.json: Esy project configuration (native package management)
  • fullstack-reason.opam: OPAM project configuration (empty but needed for backward-compatibility with OPAM)
  • package.json: Npm project configuration
  • webpack.config.js: Webpack bundler configuration for the frontend

Honourable mention: build outputs are in the .gitignore.

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.