The BoardWise frontend/backend. https://www.boardwise.gg
 
 
 
 
 
 
Go to file
Joshua Potter 0c7d2b5932 Have contact refer to github repo. 2023-12-12 08:30:20 -07:00
.githooks Discourage dev dependencies. 2023-12-04 06:06:54 -07:00
assets Have contact refer to github repo. 2023-12-12 08:30:20 -07:00
config Add a coach context. 2023-12-04 07:27:02 -07:00
lib Add a random order for initial page load. 2023-12-07 08:12:32 -07:00
priv Add a random order for initial page load. 2023-12-07 08:12:32 -07:00
test Allow searching languages. Prefer profiles with images/names. 2023-12-06 16:48:53 -07:00
.envrc Add a formatting pre-commit hook. 2023-11-29 10:01:06 -07:00
.formatter.exs Initial commit. 2023-11-28 10:50:13 -07:00
.gitignore Use `db` for local database instance. 2023-12-01 11:00:43 -07:00
README.md Write out the flake template README content. 2023-12-03 16:08:31 -07:00
default.nix Initial commit. 2023-11-28 10:50:13 -07:00
deps.nix Initial commit. 2023-11-28 10:50:13 -07:00
flake.lock Update flake.lock. 2023-12-08 12:36:54 -07:00
flake.nix Discourage dev dependencies. 2023-12-04 06:06:54 -07:00
mix.exs Rename module to `boardwise`. 2023-11-30 10:25:00 -07:00
mix.lock Initial commit. 2023-11-28 10:50:13 -07:00
package-lock.json Migrate filter modal. 2023-12-04 16:04:30 -07:00

README.md

BoardWise Website

This is the repository containing both the Phoenix backend and React frontend of boardwise.gg. We use nix for both development and release.

Quickstart

direnv can be used to launch a dev shell upon entering this directory (refer to .envrc). Otherwise run via:

$ nix develop

Once you have a nix development shell open, create a new Postgres cluster at /db:

$ pg_ctl -D db init

To start the database, run the following:

$ pg_ctl -D db -l db/logfile -o --unix_socket_directories=@boardwise start

In the above command, @boardwise refers to an abstract socket name. Rename to whatever is appropriate for your use case. To then connect to this database instance, run:

$ psql -h @boardwise

To later shut the database down, run:

$ pg_ctl -D db stop

Once the database is running, you can invoke the following Phoenix setup commands:

$ mix ecto.setup
$ mix assets.setup
$ cd assets && npm install

Afterward start the local server:

$ mix phx.server

Release

To create a new Mix release, run nix build (after updating dependencies as outlined in the below sections). You can test the release is functional by running:

$ export DATABASE_URL=ecto://<username>:<password>@<host>/<db_name>
$ export SECRET_KEY_BASE=$(mix phx.gen.secret)
$ result/bin/boardwise start

Backend

Mix dependencies are packaged using mix2nix. After updating your mix.lock file, make sure to re-run the following:

$ mix2nix > deps.nix

As of now, mix2nix cannot handle git dependencies found inside the mix.lock file. If you have git dependencies, add them manually or use FODs.

Frontend

Frontend dependencies (i.e. assets found in the /assets folder) are packaged using node2nix. You can generate the relevant nix files for import using the following sequence of commands:

$ cd assets
$ rm -r node_modules
$ node2nix -l

In the above, we must remove node_modules (if it exists). Otherwise the node packages will be included in the Nix build, influencing the outcome of node2nix. The above generates three files:

  • node-packages.nix
    • Captures the packages that can be deployed (including all its required dependencies)
  • node-env.nix
    • Contains build logic
  • default.nix
    • A composition expression allowing users to deploy the package. For an example of this deployment, refer to flake.nix

NOTE: Do not update the lock version used in assets. node2nix currently only supports lock versions 1 and 2.

Development

It's strongly advised to use nix develop when performing local development. Doing so automatically includes the following features:

Language Server

The elixir-ls LSP (version 0.17.10) and typescript-language-server (version 4.1.2) is included in this flake.

Formatting

Formatting depends on prettier (version 3.1.0) and the mix format task. A pre-commit hook is included in .githooks that can be used to format all *.exs?, *.jsx?, and *.tsx? files prior to commit. Install via:

$ git config --local core.hooksPath .githooks/

If running direnv, this hook is installed automatically when entering the directory.