• Stars
    star
    166
  • Rank 227,748 (Top 5 %)
  • Language Reason
  • License
    MIT License
  • Created almost 5 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A demo project that shows a fullstack ReasonML/OCaml app–native binary + webapp

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.

More Repositories

1

re-web

Experimental web framework for ReasonML & OCaml
OCaml
263
star
2

scala-modules

Experimental implementations of ML-style modules in Scala
Scala
142
star
3

bucklescript-bindings-cookbook

Task-oriented guide to writing JavaScript bindings for BuckleScript
115
star
4

prometo

A type-safe JavaScript promise library for ReasonML
Reason
31
star
5

fsharp-typeclasses

F#
24
star
6

ggspec

A lightweight, functional-style unit testing framework for Guile/Scheme
Scheme
24
star
7

re-hyperapp

Almost zero-cost bindings for the https://github.com/hyperapp/hyperapp UI library.
OCaml
21
star
8

ocaml_sql_query

PoC of functional-style SQL query
OCaml
21
star
9

ocaml-decimal

Arbitrary-precision floating-point decimals
OCaml
21
star
10

lambdak

Full anonymous functions for Python
Python
19
star
11

dbc

Design-by-contract programming for JavaScript and ReasonML
OCaml
12
star
12

bs-webapi

(WIP) BuckleScript Web API Bindings
OCaml
10
star
13

stubbex

Stub and validate HTTP endpoints with ease.
Elixir
10
star
14

bs-hyperapp

DEPRECATED - see https://github.com/yawaramin/re-hyperapp for a more recent (experimental) attempt
OCaml
8
star
15

dream-html

Generate HTML markup from your Dream backend server
OCaml
6
star
16

bucklescript-cyclejs-test

OCaml
5
star
17

resilient-services

OCaml
5
star
18

learning-tydd-reason

Learning Type-Driven Development with ReasonML
OCaml
5
star
19

reason-workshop

HTML
4
star
20

aoc2020

Advent of Code 2020
OCaml
3
star
21

bs-pouchdb

OCaml
3
star
22

fake-io

A demonstration of controlling and testing the IO effect in Scala
Scala
3
star
23

fsharp-typed-json

JSON for F# using typeclasses.
F#
1
star
24

TDDMoney

My C# interpretation of the `Money' example from Kent Beck's Test-Driven Development by Example
C#
1
star
25

bs-doc-mgr

OCaml
1
star
26

fsharp-cond

Multi-Way Conditional Expression for F#
F#
1
star
27

lightweght-static-capabilities

Paper summary slides. Video:
OCaml
1
star
28

webagent

HTTP request builder using FreePascal/Lazarus
Pascal
1
star
29

letops

OCaml standard library let operators
OCaml
1
star
30

TDDUnit

My interpretation in C# of the unit-testing framework example from Kent Beck's Test-Driven Development
C#
1
star