gpellis / fulcro-rad-demo

A demo for Fulcro RAD using either SQL or Datomic databases.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fulcro RAD Demo

This is a demo repository for Fulcro RAD. It includes a shared source directory of files that would be common to any project, and then separate source directories that have specific files that would be needed to work with specific back-end technologies (currently SQL and Datomic).

Building the SPA

You must compile the CLJS source to run the client. If you want to be able to edit it, just start a shadow-cljs watch:

$ yarn
$ shadow-cljs watch main

Running an SQL-based Server

The example code should work with most SQL databases, and the data source is configured in the defaults.edn config file in the sql source directory. See the HikariCP connection pool documentation.

The SQL example has a custom development namespace in the src/sql source folder, along with components needed to run that server.

You can start the server-side version for SQL using the deps aliases that set up the proper classpath:

$ clj -A:dev:sql
user=> (require 'development)
user=> (development/go)

Running a Datomic-based Server

The example code for Datomic components is in the src/datomic folder, along with a custom development.clj.

Install Datomic, either Pro or Free. Configure Pro for either a PostgreSQL or MySQL storage engine, then update the config parameters in defaults.edn in the src/datomic/config directory to have the correct connection parameters.

For example, something like:

 :com.fulcrologic.rad.database-adapters.datomic/databases
    {:main {:datomic/schema           :production
            :datomic/driver           :postgresql ;; OR :mysql :free :mem
            :datomic/database         "example"
            :datomic/prevent-changes? true
            :postgresql/host          "localhost"
            :postgresql/port          5432
            :postgresql/user          "datomic"
            :postgresql/password      "datomic"
            :postgresql/database      "datomic"
            :free/host                "localhost"
            :free/port                4334}}

Then you can run it with the :datomic alias and the chosen storage driver alias:

For Postgresql:

$ clj -A:dev:datomic:postgresql
user=> (require 'development)
user=> (development/go)

Alternatively, for Mysql, Free, or Mem:

$ clj -A:dev:datomic:mysql
# OR
$ clj -A:dev:datomic:free
# OR
$ clj -A:dev:datomic:mem

Restarting

The development/restart will stop the server, reload source, and start the server.

Note
This demo uses CSRF, so you will have to reload the client to get the new CSRF key on server restarts.

About

A demo for Fulcro RAD using either SQL or Datomic databases.


Languages

Language:Clojure 99.2%Language:HTML 0.5%Language:PLSQL 0.3%Language:Makefile 0.1%