A template webserver written in Haskell
| application | ||
| database | ||
| documentation | ||
| nix | ||
| static | ||
| .env.development | ||
| .envrc | ||
| .gitignore | ||
| fourmolu.yaml | ||
| justfile | ||
| mprocs.log | ||
| mprocs.yaml | ||
| README.md | ||
| shell.nix | ||
| sqitch.conf | ||
| stylish-haskell.yaml | ||
| webserver.cabal | ||
A template webserver for Haskell.
Tooling
- Uses nix to manage nix developer environment, building, etc.
- Uses podman to manage containerization.
- Uses
dotenvxto manage secure environment keys. - Uses
sqitchto manage database upgrades. - Uses
justfor managing bash/amber commands. - Uses
mprocsas a command runner host.
It also uses BulmaCSS. Explore a bit. Have fun with it.
Directory Structure
application/ <- The Haskell part
├ Webserver/
| ├ Control/ <- Typeclasses, "services", and non-datatype structure stuff
| ├ Data/ <- Datatypes and misc related
| ├ Routes/ <- Route organization, split off from Routes.hs and go here
| ├ Middlewares.hs <- Middleware handlers
| ├ Routes.hs <- Routes starting point
| └ Utils.hs <- Various utils
├ justfile <- just file
├ Main.hs <- Well, Main
└ Prelude.hs <- Overridden Prelude. Observe, augment, replace, whatever
database/ <- The sqitch/Postgres part
├ deploy/ <- Upgrading SQL
├ revert/ <- Downgrading SQL
├ verify/ <- Testing that revisions were successful
├ docker-compose.yml <- For running Postgres locally
├ Dockerfile <- For running Postgres locally
├ justfile <- just file
├ sqitch.plan <- sqitch file
└ uuid.txt <- The UID manager for the revision files. See the justfile above, the "migration" recipe
documentation/ <- Empty, but intended for use for documenting things
nix/ <- Nix stuff
static/ <- Statically served assets. HTML, CSS, Javascript, images, etc.
The rest is configuration files and stuff you can figure out, hopefully.
Getting Started
- Get familiar with the tools I've outlined.
- Optional: Change all references to "Webserver" and "webserver" to whatever your application's name will be before running anything the first time. Can be done later, you'll just need to change the database stuff.
- You don't need nix, but everything that's used here is already in there. So if you decide not to use devenv, make sure you install/handle all the parts you need yourself.
- You'll need to get
dotenvxsituated. It needs to make a.env.keysfile for you, and also put the public key value in.env.development.- When you get more situated, also make a
.env.production, so you can differentiate values and stuff - If development/production file differentiation doesn't matter to you, make just a
.envfile and just use that. Be sure to change references to.env.development
- When you get more situated, also make a
just db startorjust db runwill get initial Postgres stuff set up for you locally if you used that. Otherwise, you'll need to set that up yourself- After (and while) Postgres is running, you need to run
just db migrateto invokesqitchto apply the two current migrations - While Postgres is running, run the app with
just app run.