{"id":18993440,"url":"https://github.com/hyperfiddle/electric-v2-starter-app","last_synced_at":"2025-02-23T04:10:58.188Z","repository":{"id":39659914,"uuid":"492509680","full_name":"hyperfiddle/electric-v2-starter-app","owner":"hyperfiddle","description":"A minimal Electric Clojure App","archived":false,"fork":false,"pushed_at":"2024-10-21T10:34:59.000Z","size":537,"stargazers_count":103,"open_issues_count":8,"forks_count":80,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-02-16T02:54:49.536Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Clojure","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hyperfiddle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-15T14:24:57.000Z","updated_at":"2025-02-11T09:14:01.000Z","dependencies_parsed_at":"2023-01-19T18:01:26.018Z","dependency_job_id":"76559caf-3b02-4168-8a8d-ec7db3f02307","html_url":"https://github.com/hyperfiddle/electric-v2-starter-app","commit_stats":null,"previous_names":["hyperfiddle/electric-starter-app"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperfiddle%2Felectric-v2-starter-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperfiddle%2Felectric-v2-starter-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperfiddle%2Felectric-v2-starter-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperfiddle%2Felectric-v2-starter-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hyperfiddle","download_url":"https://codeload.github.com/hyperfiddle/electric-v2-starter-app/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240266889,"owners_count":19774081,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T17:21:24.877Z","updated_at":"2025-02-23T04:10:58.154Z","avatar_url":"https://github.com/hyperfiddle.png","language":"Clojure","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Electric Starter App (Electric v2)\n\nA minimal Electric Clojure app, and instructions on how to integrate it into an existing app.\n\n## Instructions\n\nDev build:\n\n* Shell: `clj -A:dev -X dev/-main`, or repl: `(dev/-main)`\n* http://localhost:8080\n* Electric root function: [src/electric_starter_app/main.cljc](src/electric_starter_app/main.cljc)\n* Hot code reloading works: edit -\u003e save -\u003e see app reload in browser\n\nProd build:\n\n```shell\nclj -X:build:prod build-client\nclj -M:prod -m prod\n```\n\nUberjar (optional):\n```\nclj -X:build:prod uberjar :build/jar-name \"target/app.jar\"\njava -cp target/app.jar clojure.main -m prod\n```\n\nDeployment example:\n- [Dockerfile](Dockerfile)\n- fly.io deployment through github actions: [.github/workflows/deploy.yml](.github/workflows/deploy.yml) \u0026 [fly.toml](fly.toml)\n\n## Integrate it in an existing clojure app\n\n1. Look at [src-prod/prod.cljc](src-prod/prod.cljc). It contains:\n    - server entrypoint\n    - client entrypoint\n    - necessary configuration\n2. Look at [src/electric_starter_app/server_jetty.clj](src/electric_starter_app/server_jetty.clj). It contains:\n   - an example Jetty integration\n   - required ring middlewares\n\n## Build documentation\n\nElectric Clojure programs compile down to separate client and server target programs, which are compiled from the same Electric application source code.\n\n* For an Electric client/server pair to successfully connect, they must be built from matching source code. The server will reject mismatched clients (based on a version number handshake coordinated by the Electric build) and instruct the client to refresh (to get the latest javascript artifact).\n* [src-build/build.cljc](src-build/build.clj bakes the Electric app version into both client and server artifacts.\n  * server Electric app version is baked into `electric-manifest.edn` which is read in [src-prod/prod.cljc](src-prod/prod.cljc).\n  * client Electric app version is baked into the .js artifact as `hyperfiddle.electric-client/ELECTRIC_USER_VERSION`\n\nConsequently, you need **robust cache invalidation** in prod!\n  * In this example, complied js files are fingerprinted with their respective hash, to ensure a new release properly invalidates asset caches. [index.html](resources/public/electric_starter_app/index.html) is templated with the generated js file name.\n  * The generated name comes from shadow-cljs's `manifest.edn` file (in `resources/public/electric_starter_app/js/manifest.edn`), produced by `clj -X:build:prod build-client`. Watch out: this shadow-cljs compilation manifest is not the same manifest as `electric-manifest.edn`!\n  * Notice that [src/electric_starter_app/server_jetty.clj](src/electric_starter_app/server_jetty.clj) -\u003e `wrap-index-page` reads `:manifest-path` from config. The config comes from [src-prod/prod.cljc](src-prod/prod.cljc).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperfiddle%2Felectric-v2-starter-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhyperfiddle%2Felectric-v2-starter-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperfiddle%2Felectric-v2-starter-app/lists"}