{"slug": "two-front-ends-in-one-rails-8-app-a-turbo-dashboard-and-a-stimulus-only-customer", "title": "Two front ends in one Rails 8 app: a Turbo dashboard and a Stimulus-only customer page", "summary": "A developer building an estimate and invoice app for small trade businesses split a single Rails 8.1 monolith into two front ends: a Turbo-driven PWA dashboard for contractors and a Stimulus-only customer quote page with its own layout and importmap entry point, budgeted under 50 KB of gzipped JavaScript. The customer page skips Turbo, ActionCable and third-party scripts, uses full-page POST/redirect form submissions, lazy-loads the signature controller via dynamic import, and recalculates all totals server-side in integer cents while keeping the customer's selection in sessionStorage across reloads.", "body_md": "*Disclosure: this article was created with the help of AI. AI tools drafted it from my codebase and project notes, and it was edited and checked against the code before publishing. I'm the founder of the app it describes.*\n\nI'm building an estimate and invoice app for small trade businesses: plumbers, painters, handymen, crews of one to five people. The contractor writes an estimate on their phone and texts the customer a link. The customer opens it, picks an option, signs and sees how to pay the deposit.\n\nSo the app has two very different users. One opens it many times a day and has it on their home screen. The other opens it once, from a text message, maybe on one bar of signal in a basement. This post is about how I split the front end between them in one Rails 8 app, and a few choices that came out of designing for phones first.\n\nIt's one Rails 8.1 monolith on Postgres. Hotwire (Turbo and Stimulus) on the front end, Tailwind v4 for styles, importmap instead of a JS bundler. Background jobs run on Solid Queue, and in production Solid Queue runs inside the Puma process through its plugin, so the whole app is one web service plus a database. PDFs come from Prawn. The contractor side is a PWA built on the manifest and service worker that Rails 8 generates.\n\nNothing exotic. The interesting part is what loads where.\n\nThe contractor is signed in, has the app on the home screen and uses it every day. Turbo makes navigation there feel close to a native app, so loading Turbo, dozens of Stimulus controllers and Turbo Streams for live updates is fine.\n\nThe customer has never heard of the app and opens one link. That page has to render fast and work with as little JavaScript as possible.\n\nSo the customer page has its own layout and its own importmap entry point. It loads Stimulus and a handful of controllers. No Turbo, no ActionCable, no third-party scripts. The budget I set for that page is under 50 KB of gzipped JS.\n\nHere is the entry point, trimmed to the controllers this post talks about:\n\n```\n// public_quote.js: Stimulus plus the page's controllers. No Turbo, no ActionCable, no SDKs.\nimport { Application } from \"@hotwired/stimulus\"\nimport QuoteChoiceController from \"controllers/quote_choice_controller\"\nimport CopyController from \"controllers/copy_controller\"\nimport ConnectivityController from \"controllers/connectivity_controller\"\n\nconst application = Application.start()\napplication.register(\"quote-choice\", QuoteChoiceController)\napplication.register(\"copy\", CopyController)\napplication.register(\"connectivity\", ConnectivityController)\n```\n\nWithout Turbo, forms on that page work the old way: POST, redirect, full render. Where the contractor side would answer with a Turbo Stream, the customer side does a normal round trip. On a page someone visits once, a full reload after signing is fine.\n\nThe signature controller is the heaviest one on the page, and some visitors never sign. So it's imported on demand: right away if the page renders a sign block, or on the first tap on Draw.\n\n``` js\nlet signatureLoading\nconst loadSignature = () => signatureLoading ||= import(\"controllers/signature_controller\")\n  .then(({ default: SignatureController }) => application.register(\"signature\", SignatureController))\n\nif (document.querySelector(\"[data-controller~=signature]\")) loadSignature()\n```\n\nImportmap handles the dynamic import without a build step.\n\nWhen the customer picks an option or ticks an extra, the total and the deposit update on the spot. A Stimulus controller does the arithmetic on values the server rendered into the page.\n\nThat number is for display only. When the customer taps Accept & sign, the server recalculates everything from the stored lines. Money is stored as integer cents plus a currency code, never as floats, and every total that counts is computed on the server.\n\nThe customer's choice survives a reload through sessionStorage, so a dropped connection or an accidental refresh doesn't reset their pick.\n\nI wanted the estimate to come from the contractor's own number, one the customer already knows, so the app doesn't send SMS through a gateway. Sending has two steps. First the server records the send and creates the link. Then the phone does its part: it opens the share sheet through the Web Share API where that exists, or opens Messages with an `sms:` URL and the text filled in, or copies the link.\n\nRecording the send first means the estimate status is right even if the user closes Messages without sending.\n\nSMS text has a trap. One character outside the GSM-7 set, like a curly apostrophe or an em dash, switches the whole message to UCS-2, and a single segment drops from 160 characters to 70. A design lint script checks every SMS string for that.\n\nTrade work happens in basements and on roofs. A Stimulus controller listens for the browser's online and offline events, shows a bar, and marks guarded buttons `aria-disabled` with a reason next to them.\n\nNothing that touches signatures or money gets queued while offline. A deferred Accept & sign that fires an hour later is harder to reason about than a disabled button that says why. Safari doesn't support the Background Sync API either, so a queue there would only drain the next time the app is opened.\n\nContractors can describe a job out loud. The recorder is a small Stimulus controller around MediaRecorder: tap to start, tap to stop (never hold), with a visible timer and an automatic stop at a time limit. It only records and dispatches an event with the audio blob. The server transcribes the audio and puts the text into the field the contractor was filling in.\n\nTap to start was deliberate. Holding a button while you talk is awkward in gloves, or with a tape measure in the other hand.\n\nDecide early which pages belong to a signed-in user and which belong to a stranger, and give them separate layouts and entry points. Adding a \"lite\" page later is harder than starting with one.\n\nAnd test on a cheap phone with a bad connection, not only on the laptop you build on.", "url": "https://wpnews.pro/news/two-front-ends-in-one-rails-8-app-a-turbo-dashboard-and-a-stimulus-only-customer", "canonical_source": "https://dev.to/antonchisliuk/two-front-ends-in-one-rails-8-app-a-turbo-dashboard-and-a-stimulus-only-customer-page-3kd7", "published_at": "2026-11-24 10:34:22+00:00", "updated_at": "2026-11-24 10:43:11.531492+00:00", "lang": "en", "topics": ["developer-tools"], "entities": ["Rails", "Hotwire", "Turbo", "Stimulus", "Tailwind", "Solid Queue", "Puma", "Prawn"], "also_reported_by": [], "takeaway": "Splitting a Rails app into a Turbo dashboard and a Stimulus-only customer entry point, with the signature controller lazy-loaded via importmap dynamic import, keeps the one-visit customer page under a 50 KB gzipped JS budget.", "recommendation": {"advice": "Give one-visit public pages their own importmap entry point with Stimulus only, lazy-load heavy controllers like signatures, and recompute money server-side in integer cents.", "playbook": "production-ops", "playbook_url": "https://wpnews.pro/playbooks/production-ops"}, "alternates": {"html": "https://wpnews.pro/news/two-front-ends-in-one-rails-8-app-a-turbo-dashboard-and-a-stimulus-only-customer", "markdown": "https://wpnews.pro/news/two-front-ends-in-one-rails-8-app-a-turbo-dashboard-and-a-stimulus-only-customer.md", "text": "https://wpnews.pro/news/two-front-ends-in-one-rails-8-app-a-turbo-dashboard-and-a-stimulus-only-customer.txt", "jsonld": "https://wpnews.pro/news/two-front-ends-in-one-rails-8-app-a-turbo-dashboard-and-a-stimulus-only-customer.jsonld"}}