How ricardocasares/elm-against-humanity works
Project Type and Purpose
• This is a single‐page front‐end application template built with Elm, TypeScript, Vite, TailwindCSS (plus DaisyUI), and Bun as the package/runtime manager.
• It compiles Elm code (src/*.elm) and TS/CSS into a static bundle, serves static JSON “decks” from public/, and runs entirely in the browser.
Top‐Level Components
• Source Code
– src/ directory: Elm modules (Main.elm, InteropDefinitions.elm, Translations.elm, etc.) plus supporting main.ts and main.css.
– public/: static JSON assets (deck-*.json) and index.html template.
– tests/: Elm specs for validating logic.
• Configuration
– elm.json, elm-tooling.json: Elm compiler and tooling settings.
– package.json & bun.lockb: JS/TS dependencies.
– vite.config.ts: Vite plugins (Elm, Tailwind/DaisyUI).
• Build & Dev Tools
– Bun: runtime for scripts (bunx, bun dev).
– Vite: dev server, HMR, production build.
– Tailwind/DaisyUI: CSS utility frameworks (driven by main.css).
• CI/CD
– .github/workflows/ci.yml: run Elm tests, linting, build.
– .github/workflows/deploy.yml: publish static bundles to your hosting.
System Interactions & Data Flow
a. Developer Workflow
• Code changes in src/ or public/ → Bun/Vite dev server (HMR).
• Elm compiler + Tailwind/DaisyUI plugin produce in‐memory JS + CSS bundle.
• Browser loads index.html → initializes Elm app via JS wrapper (main.ts).
• Elm ports (InteropPorts.elm, InteropDefinitions.elm) bridge Elm ↔ JavaScript for tasks like DOM APIs or localStorage.
• Elm code fetches localized deck JSON from public/ to render content in different languages.
b. Production Build
• Vite uses elm‐plugin and tailwind plugin to compile Elm, TS & CSS → dist/ (static assets).
• CI pipeline runs Elm tests (tests/MainSpec.elm) → If green, triggers deploy.
• Deploy workflow uploads dist/ to static hosting (e.g., Netlify, GitHub Pages).
Architectural Patterns & Principles
• Elm Architecture (Model-View-Update) as the core application pattern.
• Ports for well‐defined Elm ↔ JS interop, keeping Elm code pure.
• Single page application: a single index.html loading a self-contained bundle.
• Separation of concerns:
• src/Elm for pure UI logic
• src/TS for bootstrap & interop
• src/CSS + Tailwind for styling
• public/ for static data