diff --git a/.env.dist b/.env.dist
new file mode 100644
index 0000000..2ea6e52
--- /dev/null
+++ b/.env.dist
@@ -0,0 +1,4 @@
+export USERNAME="username"
+export PASSWORD="password"
+export PORT=48100
+export SECRET_KEY_BASE="some very long value that would be a good base for a secret key 1234"
diff --git a/backend/.gitignore b/.gitignore
similarity index 100%
rename from backend/.gitignore
rename to .gitignore
diff --git a/backend/src/aurinko/web/router.gleam b/backend/src/aurinko/web/router.gleam
deleted file mode 100644
index 0a992ca..0000000
--- a/backend/src/aurinko/web/router.gleam
+++ /dev/null
@@ -1,9 +0,0 @@
-import wisp.{type Request}
-
-pub fn handle_request(req: Request) {
- use <- wisp.log_request(req)
- use <- wisp.rescue_crashes()
- use _ <- wisp.handle_head(req)
-
- wisp.ok() |> wisp.string_body("Hello.")
-}
diff --git a/backend/src/aurinko/web/ws.gleam b/backend/src/aurinko/web/ws.gleam
deleted file mode 100644
index 14cfea9..0000000
--- a/backend/src/aurinko/web/ws.gleam
+++ /dev/null
@@ -1,89 +0,0 @@
-import aurinko/updater
-import aurinko/updater/messaging
-import aurinko/updater/pubsub
-import aurinko/updater/registry
-import aurinko/web/ws/encoder
-import gleam/erlang/process
-import gleam/json
-import gleam/option
-import gleam/otp/actor
-import glubsub
-import mist
-
-pub type State {
- State(
- updater_pubsub: pubsub.UpdaterPubSub,
- updater_registry: registry.UpdaterRegistry,
- pubsub_subject: process.Subject(pubsub.OutMessage),
- )
-}
-
-pub fn on_init(
- conn: mist.WebsocketConnection,
- updater_pubsub: pubsub.UpdaterPubSub,
- updater_registry: registry.UpdaterRegistry,
-) {
- let pubsub_subject = process.new_subject()
- let assert Ok(_) = glubsub.subscribe(updater_pubsub, pubsub_subject)
-
- send_initial_dataset(conn, updater_registry)
-
- let self_selector =
- process.new_selector() |> process.selecting(pubsub_subject, fn(m) { m })
- let state = State(updater_pubsub, updater_registry, pubsub_subject)
- #(state, option.Some(self_selector))
-}
-
-pub fn on_close(state: State) {
- let _ = glubsub.unsubscribe(state.updater_pubsub, state.pubsub_subject)
- Nil
-}
-
-pub fn handle_message(
- state: State,
- conn: mist.WebsocketConnection,
- message: mist.WebsocketMessage(pubsub.OutMessage),
-) {
- case message {
- mist.Custom(pubsub.NewData(dataset)) -> {
- let dataset = encoder.dataset(dataset)
- let output =
- json.object([
- #("type", json.string("data_update")),
- #("dataset", dataset),
- ])
- |> json.to_string()
- let assert Ok(_) = mist.send_text_frame(conn, output)
- actor.continue(state)
- }
- mist.Closed | mist.Shutdown -> actor.Stop(process.Normal)
- _ -> actor.continue(state)
- }
-}
-
-fn send_initial_dataset(
- conn: mist.WebsocketConnection,
- updater_registry: registry.UpdaterRegistry,
-) {
- let updater_subject = registry.get(updater_registry)
- case updater_subject {
- Ok(sub) -> {
- let messaging.GetDataResponse(initial_data) = updater.get_data(sub)
- let dataset = case initial_data {
- option.Some(dataset) -> encoder.dataset(dataset)
- option.None -> json.null()
- }
-
- let output =
- json.object([
- #("type", json.string("initial_data")),
- #("dataset", dataset),
- ])
- |> json.to_string()
-
- let assert Ok(_) = mist.send_text_frame(conn, output)
- Nil
- }
- Error(_) -> Nil
- }
-}
diff --git a/common/.gitignore b/common/.gitignore
deleted file mode 100644
index 599be4e..0000000
--- a/common/.gitignore
+++ /dev/null
@@ -1,4 +0,0 @@
-*.beam
-*.ez
-/build
-erl_crash.dump
diff --git a/common/gleam.toml b/common/gleam.toml
deleted file mode 100644
index c0e6b2c..0000000
--- a/common/gleam.toml
+++ /dev/null
@@ -1,18 +0,0 @@
-name = "aurinko_common"
-version = "1.0.0"
-
-# Fill out these fields if you intend to generate HTML documentation or publish
-# your project to the Hex package manager.
-#
-# description = ""
-# licences = ["Apache-2.0"]
-# repository = { type = "github", user = "username", repo = "project" }
-# links = [{ title = "Website", href = "https://gleam.run" }]
-#
-# For a full reference of all the available options, you can have a look at
-# https://gleam.run/writing-gleam/gleam-toml/.
-
-[dependencies]
-gleam_stdlib = ">= 0.34.0 and < 2.0.0"
-
-[dev-dependencies]
diff --git a/common/manifest.toml b/common/manifest.toml
deleted file mode 100644
index 3a65da5..0000000
--- a/common/manifest.toml
+++ /dev/null
@@ -1,9 +0,0 @@
-# This file was generated by Gleam
-# You typically do not need to edit this file
-
-packages = [
- { name = "gleam_stdlib", version = "0.38.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "663CF11861179AF415A625307447775C09404E752FF99A24E2057C835319F1BE" },
-]
-
-[requirements]
-gleam_stdlib = { version = ">= 0.34.0 and < 2.0.0" }
diff --git a/frontend/.gitignore b/frontend/.gitignore
deleted file mode 100644
index 1d87233..0000000
--- a/frontend/.gitignore
+++ /dev/null
@@ -1,6 +0,0 @@
-*.beam
-*.ez
-/build
-erl_crash.dump
-priv/static/aurinko_frontend.css
-priv/static/aurinko_frontend.mjs
diff --git a/frontend/gleam.toml b/frontend/gleam.toml
deleted file mode 100644
index 026dde0..0000000
--- a/frontend/gleam.toml
+++ /dev/null
@@ -1,23 +0,0 @@
-name = "aurinko_frontend"
-version = "1.0.0"
-target = "javascript"
-
-# Fill out these fields if you intend to generate HTML documentation or publish
-# your project to the Hex package manager.
-#
-# description = ""
-# licences = ["Apache-2.0"]
-# repository = { type = "github", user = "username", repo = "project" }
-# links = [{ title = "Website", href = "https://gleam.run" }]
-#
-# For a full reference of all the available options, you can have a look at
-# https://gleam.run/writing-gleam/gleam-toml/.
-
-[dependencies]
-gleam_stdlib = ">= 0.34.0 and < 2.0.0"
-aurinko_common = { path = "../common" }
-lustre = ">= 4.3.0 and < 5.0.0"
-lustre_ui = ">= 0.6.0 and < 1.0.0"
-
-[dev-dependencies]
-lustre_dev_tools = ">= 1.3.4 and < 2.0.0"
diff --git a/frontend/index.html b/frontend/index.html
deleted file mode 100644
index 8d4a6ca..0000000
--- a/frontend/index.html
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
-
-
- Aurinko
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/frontend/manifest.toml b/frontend/manifest.toml
deleted file mode 100644
index f2dd907..0000000
--- a/frontend/manifest.toml
+++ /dev/null
@@ -1,48 +0,0 @@
-# This file was generated by Gleam
-# You typically do not need to edit this file
-
-packages = [
- { name = "argv", version = "1.0.2", build_tools = ["gleam"], requirements = [], otp_app = "argv", source = "hex", outer_checksum = "BA1FF0929525DEBA1CE67256E5ADF77A7CDDFE729E3E3F57A5BDCAA031DED09D" },
- { name = "aurinko_common", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], source = "local", path = "../common" },
- { name = "birl", version = "1.7.1", build_tools = ["gleam"], requirements = ["gleam_stdlib", "ranger"], otp_app = "birl", source = "hex", outer_checksum = "5C66647D62BCB11FE327E7A6024907C4A17954EF22865FE0940B54A852446D01" },
- { name = "exception", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "exception", source = "hex", outer_checksum = "F5580D584F16A20B7FCDCABF9E9BE9A2C1F6AC4F9176FA6DD0B63E3B20D450AA" },
- { name = "filepath", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "EFB6FF65C98B2A16378ABC3EE2B14124168C0CE5201553DE652E2644DCFDB594" },
- { name = "fs", version = "8.6.1", build_tools = ["rebar3"], requirements = [], otp_app = "fs", source = "hex", outer_checksum = "61EA2BDAEDAE4E2024D0D25C63E44DCCF65622D4402DB4A2DF12868D1546503F" },
- { name = "gleam_community_ansi", version = "1.4.0", build_tools = ["gleam"], requirements = ["gleam_community_colour", "gleam_stdlib"], otp_app = "gleam_community_ansi", source = "hex", outer_checksum = "FE79E08BF97009729259B6357EC058315B6FBB916FAD1C2FF9355115FEB0D3A4" },
- { name = "gleam_community_colour", version = "1.4.0", build_tools = ["gleam"], requirements = ["gleam_json", "gleam_stdlib"], otp_app = "gleam_community_colour", source = "hex", outer_checksum = "795964217EBEDB3DA656F5EB8F67D7AD22872EB95182042D3E7AFEF32D3FD2FE" },
- { name = "gleam_crypto", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_crypto", source = "hex", outer_checksum = "ADD058DEDE8F0341F1ADE3AAC492A224F15700829D9A3A3F9ADF370F875C51B7" },
- { name = "gleam_erlang", version = "0.25.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "054D571A7092D2A9727B3E5D183B7507DAB0DA41556EC9133606F09C15497373" },
- { name = "gleam_http", version = "3.6.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "8C07DF9DF8CC7F054C650839A51C30A7D3C26482AC241C899C1CEA86B22DBE51" },
- { name = "gleam_httpc", version = "2.2.0", build_tools = ["gleam"], requirements = ["gleam_http", "gleam_stdlib"], otp_app = "gleam_httpc", source = "hex", outer_checksum = "CF76C71002DEECF6DC5D9CA83D962728FAE166B57926BE442D827004D3C7DF1B" },
- { name = "gleam_json", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib", "thoas"], otp_app = "gleam_json", source = "hex", outer_checksum = "9063D14D25406326C0255BDA0021541E797D8A7A12573D849462CAFED459F6EB" },
- { name = "gleam_otp", version = "0.10.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_stdlib"], otp_app = "gleam_otp", source = "hex", outer_checksum = "0B04FE915ACECE539B317F9652CAADBBC0F000184D586AAAF2D94C100945D72B" },
- { name = "gleam_package_interface", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_json", "gleam_stdlib"], otp_app = "gleam_package_interface", source = "hex", outer_checksum = "CF3BFC5D0997750D9550D8D73A90F4B8D71C6C081B20ED4E70FFBE1E99AFC3C2" },
- { name = "gleam_stdlib", version = "0.38.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "663CF11861179AF415A625307447775C09404E752FF99A24E2057C835319F1BE" },
- { name = "glearray", version = "0.2.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "glearray", source = "hex", outer_checksum = "9C207E05F38D724F464FA921378DB3ABC2B0A2F5821116D8BC8B2CACC68930D5" },
- { name = "glint", version = "0.18.1", build_tools = ["gleam"], requirements = ["gleam_community_ansi", "gleam_community_colour", "gleam_stdlib", "snag"], otp_app = "glint", source = "hex", outer_checksum = "5FB54D7732B4105E4AF4D89A7EE6D5E8CF33DA13A3575D0C6ECE470B97958454" },
- { name = "glisten", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_otp", "gleam_stdlib"], otp_app = "glisten", source = "hex", outer_checksum = "CF3A9383E9BA4A8CBAF2F7B799716290D02F2AC34E7A77556B49376B662B9314" },
- { name = "gramps", version = "2.0.3", build_tools = ["gleam"], requirements = ["gleam_crypto", "gleam_erlang", "gleam_http", "gleam_stdlib"], otp_app = "gramps", source = "hex", outer_checksum = "3CCAA6E081225180D95C79679D383BBF51C8D1FDC1B84DA1DA444F628C373793" },
- { name = "hpack_erl", version = "0.3.0", build_tools = ["rebar3"], requirements = [], otp_app = "hpack", source = "hex", outer_checksum = "D6137D7079169D8C485C6962DFE261AF5B9EF60FBC557344511C1E65E3D95FB0" },
- { name = "logging", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "logging", source = "hex", outer_checksum = "FCB111401BDB4703A440A94FF8CC7DA521112269C065F219C2766998333E7738" },
- { name = "lustre", version = "4.3.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_json", "gleam_otp", "gleam_stdlib"], otp_app = "lustre", source = "hex", outer_checksum = "43642C0602D3E2D6FEC3E24173D68A1F8E646969B53A2B0A5EB61238DDA739C4" },
- { name = "lustre_dev_tools", version = "1.3.4", build_tools = ["gleam"], requirements = ["argv", "filepath", "fs", "gleam_community_ansi", "gleam_erlang", "gleam_http", "gleam_httpc", "gleam_json", "gleam_otp", "gleam_package_interface", "gleam_stdlib", "glint", "glisten", "mist", "simplifile", "spinner", "term_size", "tom", "wisp"], otp_app = "lustre_dev_tools", source = "hex", outer_checksum = "FB056F18870EA7FE2A070264A598CFCDB8F6F24D65FF989F18F3F46C9ABEEE31" },
- { name = "lustre_ui", version = "0.6.0", build_tools = ["gleam"], requirements = ["gleam_community_colour", "gleam_json", "gleam_stdlib", "lustre"], otp_app = "lustre_ui", source = "hex", outer_checksum = "FA1F9E89D89CDD5DF376ED86ABA8A38441CB2E664CD4D402F22A49DA4D7BB56D" },
- { name = "marceau", version = "1.2.0", build_tools = ["gleam"], requirements = [], otp_app = "marceau", source = "hex", outer_checksum = "5188D643C181EE350D8A20A3BDBD63AF7B6C505DE333CFBE05EF642ADD88A59B" },
- { name = "mist", version = "1.2.0", build_tools = ["gleam"], requirements = ["birl", "gleam_erlang", "gleam_http", "gleam_otp", "gleam_stdlib", "glisten", "gramps", "hpack_erl", "logging"], otp_app = "mist", source = "hex", outer_checksum = "109B4D64E68C104CC23BB3CC5441ECD479DD7444889DA01113B75C6AF0F0E17B" },
- { name = "ranger", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "ranger", source = "hex", outer_checksum = "1566C272B1D141B3BBA38B25CB761EF56E312E79EC0E2DFD4D3C19FB0CC1F98C" },
- { name = "repeatedly", version = "2.1.1", build_tools = ["gleam"], requirements = [], otp_app = "repeatedly", source = "hex", outer_checksum = "38808C3EC382B0CD981336D5879C24ECB37FCB9C1D1BD128F7A80B0F74404D79" },
- { name = "simplifile", version = "1.7.0", build_tools = ["gleam"], requirements = ["filepath", "gleam_stdlib"], otp_app = "simplifile", source = "hex", outer_checksum = "1D5DFA3A2F9319EC85825F6ED88B8E449F381B0D55A62F5E61424E748E7DDEB0" },
- { name = "snag", version = "0.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "snag", source = "hex", outer_checksum = "54D32E16E33655346AA3E66CBA7E191DE0A8793D2C05284E3EFB90AD2CE92BCC" },
- { name = "spinner", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_community_ansi", "gleam_erlang", "gleam_stdlib", "glearray", "repeatedly"], otp_app = "spinner", source = "hex", outer_checksum = "200BA3D4A04D468898E63C0D316E23F526E02514BC46454091975CB5BAE41E8F" },
- { name = "term_size", version = "1.0.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "term_size", source = "hex", outer_checksum = "D00BD2BC8FB3EBB7E6AE076F3F1FF2AC9D5ED1805F004D0896C784D06C6645F1" },
- { name = "thoas", version = "1.2.1", build_tools = ["rebar3"], requirements = [], otp_app = "thoas", source = "hex", outer_checksum = "E38697EDFFD6E91BD12CEA41B155115282630075C2A727E7A6B2947F5408B86A" },
- { name = "tom", version = "0.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "tom", source = "hex", outer_checksum = "0831C73E45405A2153091226BF98FB485ED16376988602CC01A5FD086B82D577" },
- { name = "wisp", version = "0.14.0", build_tools = ["gleam"], requirements = ["exception", "gleam_crypto", "gleam_erlang", "gleam_http", "gleam_json", "gleam_stdlib", "logging", "marceau", "mist", "simplifile"], otp_app = "wisp", source = "hex", outer_checksum = "9F5453AF1F9275E6F8707BC815D6A6A9DF41551921B16FBDBA52883773BAE684" },
-]
-
-[requirements]
-aurinko_common = { path = "../common" }
-gleam_stdlib = { version = ">= 0.34.0 and < 2.0.0" }
-lustre = { version = ">= 4.3.0 and < 5.0.0" }
-lustre_dev_tools = { version = ">= 1.3.4 and < 2.0.0"}
-lustre_ui = { version = ">= 0.6.0 and < 1.0.0" }
diff --git a/frontend/src/aurinko_frontend.gleam b/frontend/src/aurinko_frontend.gleam
deleted file mode 100644
index 3cffedf..0000000
--- a/frontend/src/aurinko_frontend.gleam
+++ /dev/null
@@ -1,38 +0,0 @@
-import gleam/int
-import lustre
-import lustre/element.{text}
-import lustre/element/html.{button, div, p}
-import lustre/event.{on_click}
-
-pub fn main() {
- let app = lustre.simple(init, update, view)
- let assert Ok(_) = lustre.start(app, "#app", Nil)
-
- Nil
-}
-
-fn init(_flags) {
- 0
-}
-
-type Msg {
- Incr
- Decr
-}
-
-fn update(model, msg) {
- case msg {
- Incr -> model + 1
- Decr -> model - 1
- }
-}
-
-fn view(model) {
- let count = int.to_string(model)
-
- div([], [
- button([on_click(Incr)], [text(" + ")]),
- p([], [text(count)]),
- button([on_click(Decr)], [text(" - ")]),
- ])
-}
diff --git a/frontend/tailwind.config.js b/frontend/tailwind.config.js
deleted file mode 100644
index 1da1ec9..0000000
--- a/frontend/tailwind.config.js
+++ /dev/null
@@ -1,7 +0,0 @@
-module.exports = {
- content: ["./index.html", "./src/**/*.{gleam,mjs}"],
- theme: {
- extend: {},
- },
- plugins: [],
-};
diff --git a/backend/gleam.toml b/gleam.toml
similarity index 94%
rename from backend/gleam.toml
rename to gleam.toml
index b704edd..63a7dc2 100644
--- a/backend/gleam.toml
+++ b/gleam.toml
@@ -1,4 +1,4 @@
-name = "aurinko_backend"
+name = "aurinko"
version = "1.0.0"
target = "erlang"
@@ -28,10 +28,10 @@ form_coder = ">= 0.3.0 and < 1.0.0"
birl = ">= 1.7.1 and < 2.0.0"
gleam_json = ">= 1.0.1 and < 2.0.0"
mist = ">= 1.2.0 and < 2.0.0"
-aurinko_common = { path = "../common" }
gleamy_structures = ">= 1.0.0 and < 2.0.0"
glubsub = ">= 1.0.1 and < 2.0.0"
dot_env = ">= 1.0.0 and < 2.0.0"
chip = ">= 0.7.5 and < 1.0.0"
+lustre_ui = ">= 0.6.0 and < 1.0.0"
[dev-dependencies]
diff --git a/backend/manifest.toml b/manifest.toml
similarity index 92%
rename from backend/manifest.toml
rename to manifest.toml
index 2131461..c29bb55 100644
--- a/backend/manifest.toml
+++ b/manifest.toml
@@ -2,7 +2,6 @@
# You typically do not need to edit this file
packages = [
- { name = "aurinko_common", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], source = "local", path = "../common" },
{ name = "birl", version = "1.7.1", build_tools = ["gleam"], requirements = ["gleam_stdlib", "ranger"], otp_app = "birl", source = "hex", outer_checksum = "5C66647D62BCB11FE327E7A6024907C4A17954EF22865FE0940B54A852446D01" },
{ name = "biscotto", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_http", "gleam_stdlib"], otp_app = "biscotto", source = "hex", outer_checksum = "A1CFEA1686FA8ABDE90B76E22775FF29EE8156A64DAC327F48141A68951D662C" },
{ name = "chip", version = "0.7.5", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_otp", "gleam_stdlib"], otp_app = "chip", source = "hex", outer_checksum = "1C50EB65CE8617D64FBCCE9A3EA7E6C7BF3E646D8E39B92EA74F68B67476F59D" },
@@ -11,6 +10,7 @@ packages = [
{ name = "exception", version = "2.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "exception", source = "hex", outer_checksum = "F5580D584F16A20B7FCDCABF9E9BE9A2C1F6AC4F9176FA6DD0B63E3B20D450AA" },
{ name = "filepath", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "filepath", source = "hex", outer_checksum = "EFB6FF65C98B2A16378ABC3EE2B14124168C0CE5201553DE652E2644DCFDB594" },
{ name = "form_coder", version = "0.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "form_coder", source = "hex", outer_checksum = "FA27C97AADF66A79E4EEE78D30A50C18660A9FAFD91C27A5BC780DBC753CB8AF" },
+ { name = "gleam_community_colour", version = "1.4.0", build_tools = ["gleam"], requirements = ["gleam_json", "gleam_stdlib"], otp_app = "gleam_community_colour", source = "hex", outer_checksum = "795964217EBEDB3DA656F5EB8F67D7AD22872EB95182042D3E7AFEF32D3FD2FE" },
{ name = "gleam_crypto", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_crypto", source = "hex", outer_checksum = "ADD058DEDE8F0341F1ADE3AAC492A224F15700829D9A3A3F9ADF370F875C51B7" },
{ name = "gleam_erlang", version = "0.25.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_erlang", source = "hex", outer_checksum = "054D571A7092D2A9727B3E5D183B7507DAB0DA41556EC9133606F09C15497373" },
{ name = "gleam_http", version = "3.6.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "8C07DF9DF8CC7F054C650839A51C30A7D3C26482AC241C899C1CEA86B22DBE51" },
@@ -27,6 +27,7 @@ packages = [
{ name = "htmgrrrl", version = "0.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "htmerl"], otp_app = "htmgrrrl", source = "hex", outer_checksum = "983492567967DAA64776E005B9E70353368B14E6F87D543E01308B48A7A0398F" },
{ name = "logging", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "logging", source = "hex", outer_checksum = "FCB111401BDB4703A440A94FF8CC7DA521112269C065F219C2766998333E7738" },
{ name = "lustre", version = "4.3.0", build_tools = ["gleam"], requirements = ["gleam_erlang", "gleam_json", "gleam_otp", "gleam_stdlib"], otp_app = "lustre", source = "hex", outer_checksum = "43642C0602D3E2D6FEC3E24173D68A1F8E646969B53A2B0A5EB61238DDA739C4" },
+ { name = "lustre_ui", version = "0.6.0", build_tools = ["gleam"], requirements = ["gleam_community_colour", "gleam_json", "gleam_stdlib", "lustre"], otp_app = "lustre_ui", source = "hex", outer_checksum = "FA1F9E89D89CDD5DF376ED86ABA8A38441CB2E664CD4D402F22A49DA4D7BB56D" },
{ name = "marceau", version = "1.2.0", build_tools = ["gleam"], requirements = [], otp_app = "marceau", source = "hex", outer_checksum = "5188D643C181EE350D8A20A3BDBD63AF7B6C505DE333CFBE05EF642ADD88A59B" },
{ name = "mist", version = "1.2.0", build_tools = ["gleam"], requirements = ["birl", "gleam_erlang", "gleam_http", "gleam_otp", "gleam_stdlib", "glisten", "gramps", "hpack_erl", "logging"], otp_app = "mist", source = "hex", outer_checksum = "109B4D64E68C104CC23BB3CC5441ECD479DD7444889DA01113B75C6AF0F0E17B" },
{ name = "ranger", version = "1.2.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "ranger", source = "hex", outer_checksum = "1566C272B1D141B3BBA38B25CB761EF56E312E79EC0E2DFD4D3C19FB0CC1F98C" },
@@ -37,10 +38,9 @@ packages = [
]
[requirements]
-aurinko_common = { path = "../common" }
birl = { version = ">= 1.7.1 and < 2.0.0" }
biscotto = { version = ">= 1.0.0 and < 2.0.0" }
-chip = { version = ">= 0.7.5 and < 1.0.0"}
+chip = { version = ">= 0.7.5 and < 1.0.0" }
dot_env = { version = ">= 1.0.0 and < 2.0.0" }
form_coder = { version = ">= 0.3.0 and < 1.0.0" }
gleam_erlang = { version = ">= 0.25.0 and < 1.0.0" }
@@ -53,6 +53,7 @@ gleamy_structures = { version = ">= 1.0.0 and < 2.0.0" }
glubsub = { version = ">= 1.0.1 and < 2.0.0" }
htmgrrrl = { version = ">= 0.3.0 and < 1.0.0" }
lustre = { version = ">= 4.3.0 and < 5.0.0" }
+lustre_ui = { version = ">= 0.6.0 and < 1.0.0" }
mist = { version = ">= 1.2.0 and < 2.0.0" }
sqlight = { version = ">= 0.9.0 and < 1.0.0" }
wisp = { version = ">= 0.15.0 and < 1.0.0" }
diff --git a/backend/priv/sql/0000_init.sql b/priv/sql/0000_init.sql
similarity index 100%
rename from backend/priv/sql/0000_init.sql
rename to priv/sql/0000_init.sql
diff --git a/backend/priv/sql/init_migrations.sql b/priv/sql/init_migrations.sql
similarity index 100%
rename from backend/priv/sql/init_migrations.sql
rename to priv/sql/init_migrations.sql
diff --git a/priv/static/lustre-server-component.mjs b/priv/static/lustre-server-component.mjs
new file mode 120000
index 0000000..bfc9862
--- /dev/null
+++ b/priv/static/lustre-server-component.mjs
@@ -0,0 +1 @@
+../../build/packages/lustre/priv/static/lustre-server-component.mjs
\ No newline at end of file
diff --git a/frontend/priv/static/lustre-ui.css b/priv/static/lustre-ui.css
similarity index 100%
rename from frontend/priv/static/lustre-ui.css
rename to priv/static/lustre-ui.css
diff --git a/backend/src/ap_systems/api.gleam b/src/ap_systems/api.gleam
similarity index 100%
rename from backend/src/ap_systems/api.gleam
rename to src/ap_systems/api.gleam
diff --git a/backend/src/ap_systems/module_power.gleam b/src/ap_systems/module_power.gleam
similarity index 100%
rename from backend/src/ap_systems/module_power.gleam
rename to src/ap_systems/module_power.gleam
diff --git a/backend/src/aurinko_backend.gleam b/src/aurinko.gleam
similarity index 100%
rename from backend/src/aurinko_backend.gleam
rename to src/aurinko.gleam
diff --git a/backend/src/aurinko/pubsub.gleam b/src/aurinko/pubsub.gleam
similarity index 100%
rename from backend/src/aurinko/pubsub.gleam
rename to src/aurinko/pubsub.gleam
diff --git a/backend/src/aurinko/registry.gleam b/src/aurinko/registry.gleam
similarity index 100%
rename from backend/src/aurinko/registry.gleam
rename to src/aurinko/registry.gleam
diff --git a/backend/src/aurinko/storage/modules.gleam b/src/aurinko/storage/modules.gleam
similarity index 100%
rename from backend/src/aurinko/storage/modules.gleam
rename to src/aurinko/storage/modules.gleam
diff --git a/backend/src/aurinko/updater.gleam b/src/aurinko/updater.gleam
similarity index 100%
rename from backend/src/aurinko/updater.gleam
rename to src/aurinko/updater.gleam
diff --git a/backend/src/aurinko/updater/messaging.gleam b/src/aurinko/updater/messaging.gleam
similarity index 100%
rename from backend/src/aurinko/updater/messaging.gleam
rename to src/aurinko/updater/messaging.gleam
diff --git a/backend/src/aurinko/updater/pubsub.gleam b/src/aurinko/updater/pubsub.gleam
similarity index 100%
rename from backend/src/aurinko/updater/pubsub.gleam
rename to src/aurinko/updater/pubsub.gleam
diff --git a/backend/src/aurinko/updater/registry.gleam b/src/aurinko/updater/registry.gleam
similarity index 100%
rename from backend/src/aurinko/updater/registry.gleam
rename to src/aurinko/updater/registry.gleam
diff --git a/backend/src/aurinko/updater/types.gleam b/src/aurinko/updater/types.gleam
similarity index 100%
rename from backend/src/aurinko/updater/types.gleam
rename to src/aurinko/updater/types.gleam
diff --git a/backend/src/aurinko/web.gleam b/src/aurinko/web.gleam
similarity index 85%
rename from backend/src/aurinko/web.gleam
rename to src/aurinko/web.gleam
index 85ce10d..ba8e5f6 100644
--- a/backend/src/aurinko/web.gleam
+++ b/src/aurinko/web.gleam
@@ -16,8 +16,10 @@ pub fn init(
updater_registry: registry.UpdaterRegistry,
) {
wisp.configure_logger()
+ let assert Ok(priv) = wisp.priv_directory("aurinko")
- let wisp_side = wisp.mist_handler(router.handle_request, secret_key_base)
+ let wisp_side =
+ wisp.mist_handler(router.handle_request(_, priv), secret_key_base)
fn(req) {
case request.path_segments(req) {
diff --git a/src/aurinko/web/components/main.gleam b/src/aurinko/web/components/main.gleam
new file mode 100644
index 0000000..e0440ed
--- /dev/null
+++ b/src/aurinko/web/components/main.gleam
@@ -0,0 +1,84 @@
+import gleam/int
+import lustre
+import lustre/attribute
+import lustre/element.{type Element}
+import lustre/element/html
+import lustre/event
+import lustre/ui
+
+// MAIN ------------------------------------------------------------------------
+
+pub fn app(_updater_pubsub, _updater_registry) {
+ lustre.simple(init, update, view)
+}
+
+// MODEL -----------------------------------------------------------------------
+
+type Model =
+ Int
+
+fn init(initial_count: Int) -> Model {
+ case initial_count < 0 {
+ True -> 0
+ False -> initial_count
+ }
+}
+
+// UPDATE ----------------------------------------------------------------------
+
+pub opaque type Msg {
+ Incr
+ Decr
+}
+
+fn update(model: Model, msg: Msg) -> Model {
+ case msg {
+ Incr -> model + 1
+ Decr -> model - 1
+ }
+}
+
+// VIEW ------------------------------------------------------------------------
+
+fn view(model: Model) -> Element(Msg) {
+ let styles = [#("width", "100vw"), #("height", "100vh"), #("padding", "1rem")]
+ let count = int.to_string(model)
+
+ ui.centre(
+ [attribute.style(styles)],
+ ui.stack([], [
+ ui.button([event.on_click(Incr)], [element.text("+")]),
+ html.slot([]),
+ html.p([attribute.style([#("text-align", "center")])], [
+ element.text(count),
+ ]),
+ ui.button([event.on_click(Decr)], [element.text("-")]),
+ ]),
+ )
+}
+// fn send_initial_dataset(
+// conn: mist.WebsocketConnection,
+// updater_registry: registry.UpdaterRegistry,
+// ) {
+// let updater_subject = registry.get(updater_registry)
+// case updater_subject {
+// Ok(sub) -> {
+// let messaging.GetDataResponse(initial_data) = updater.get_data(sub)
+// let dataset = case initial_data {
+// option.Some(dataset) -> encoder.dataset(dataset)
+// option.None -> json.null()
+// }
+
+// let output =
+// json.object([
+// #("type", json.string("initial_data")),
+// #("dataset", dataset),
+// ])
+// |> json.to_string()
+
+// let assert Ok(_) = mist.send_text_frame(conn, output)
+// Nil
+// }
+// Error(_) -> Nil
+// }
+// }
diff --git a/src/aurinko/web/index.gleam b/src/aurinko/web/index.gleam
new file mode 100644
index 0000000..9dcc10f
--- /dev/null
+++ b/src/aurinko/web/index.gleam
@@ -0,0 +1,30 @@
+import lustre/attribute
+import lustre/element
+import lustre/element/html
+import lustre/server_component
+
+pub fn view() {
+ html.html([], [
+ html.head([], [
+ html.link([
+ attribute.rel("stylesheet"),
+ attribute.href("./static/lustre-ui.css"),
+ ]),
+ html.title([], "Aurinko"),
+ ]),
+ html.body([], [
+ element.element(
+ "lustre-server-component",
+ [server_component.route("/ws")],
+ [],
+ ),
+ html.script(
+ [
+ attribute.type_("module"),
+ attribute.src("./static/lustre-server-component.mjs"),
+ ],
+ "",
+ ),
+ ]),
+ ])
+}
diff --git a/src/aurinko/web/router.gleam b/src/aurinko/web/router.gleam
new file mode 100644
index 0000000..8488113
--- /dev/null
+++ b/src/aurinko/web/router.gleam
@@ -0,0 +1,19 @@
+import aurinko/web/index
+import lustre/element
+import wisp.{type Request}
+
+pub fn handle_request(req: Request, priv_dir: String) {
+ use <- wisp.log_request(req)
+ use <- wisp.rescue_crashes()
+ use _ <- wisp.handle_head(req)
+ use <- wisp.serve_static(req, under: "/static", from: priv_dir <> "/static")
+
+ case wisp.path_segments(req) {
+ [] ->
+ wisp.html_response(
+ index.view() |> element.to_document_string_builder(),
+ 200,
+ )
+ _ -> wisp.not_found()
+ }
+}
diff --git a/src/aurinko/web/ws.gleam b/src/aurinko/web/ws.gleam
new file mode 100644
index 0000000..8ace651
--- /dev/null
+++ b/src/aurinko/web/ws.gleam
@@ -0,0 +1,71 @@
+import aurinko/updater/pubsub
+import aurinko/updater/registry
+import aurinko/web/components/main
+import gleam/erlang/process
+import gleam/json
+import gleam/option
+import gleam/otp/actor
+import lustre
+import lustre/server_component
+import mist
+
+type Main =
+ process.Subject(lustre.Action(main.Msg, lustre.ServerComponent))
+
+pub type State {
+ State(component: Main)
+}
+
+pub fn on_init(
+ _conn: mist.WebsocketConnection,
+ updater_pubsub: pubsub.UpdaterPubSub,
+ updater_registry: registry.UpdaterRegistry,
+) {
+ let self = process.new_subject()
+ let app = main.app(updater_pubsub, updater_registry)
+ let assert Ok(main_subject) = lustre.start_actor(app, 0)
+
+ process.send(
+ main_subject,
+ server_component.subscribe("ws", process.send(self, _)),
+ )
+
+ let state = State(main_subject)
+ let selector = process.new_selector() |> process.selecting(self, fn(m) { m })
+ #(state, option.Some(selector))
+}
+
+pub fn on_close(state: State) {
+ process.send(state.component, lustre.shutdown())
+ Nil
+}
+
+pub fn handle_message(
+ state: State,
+ conn: mist.WebsocketConnection,
+ message: mist.WebsocketMessage(lustre.Patch(main.Msg)),
+) {
+ case message {
+ mist.Text(json) -> {
+ let action = json.decode(json, server_component.decode_action)
+
+ case action {
+ Ok(action) -> process.send(state.component, action)
+ Error(_) -> Nil
+ }
+
+ actor.continue(state)
+ }
+ mist.Custom(patch) -> {
+ let assert Ok(_) =
+ patch
+ |> server_component.encode_patch
+ |> json.to_string
+ |> mist.send_text_frame(conn, _)
+
+ actor.continue(state)
+ }
+ mist.Closed | mist.Shutdown -> actor.Stop(process.Normal)
+ _ -> actor.continue(state)
+ }
+}
diff --git a/backend/src/aurinko/web/ws/encoder.gleam b/src/aurinko/web/ws/encoder.gleam
similarity index 100%
rename from backend/src/aurinko/web/ws/encoder.gleam
rename to src/aurinko/web/ws/encoder.gleam