<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: ilyazonov</title>
    <description>The latest articles on DEV Community by ilyazonov (@ilyazonov).</description>
    <link>https://dev.to/ilyazonov</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F830892%2Fd45937b7-90d0-4236-adef-e4512c7667e6.png</url>
      <title>DEV Community: ilyazonov</title>
      <link>https://dev.to/ilyazonov</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/ilyazonov"/>
    <language>en</language>
    <item>
      <title>"Ask a friend" with no backend: comparing two people's ratings through a URL</title>
      <dc:creator>ilyazonov</dc:creator>
      <pubDate>Sun, 22 Nov 2026 20:17:44 +0000</pubDate>
      <link>https://dev.to/ilyazonov/ask-a-friend-with-no-backend-comparing-two-peoples-ratings-through-a-url-5hie</link>
      <guid>https://dev.to/ilyazonov/ask-a-friend-with-no-backend-comparing-two-peoples-ratings-through-a-url-5hie</guid>
      <description>&lt;p&gt;Weigh is a small web app for one job: helping you choose between two or more options (two job offers, staying or moving, and so on). You rate each option on the same 7 questions, and it shows a weighted score. There is no account, no server and no AI. Decisions live in &lt;code&gt;localStorage&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The feature I wanted most was &lt;strong&gt;Ask a friend&lt;/strong&gt;: a friend rates the same options &lt;em&gt;blind&lt;/em&gt;, then you see where you agree and where you differ. Usually that needs a database. Here is how it works with nothing but links.&lt;/p&gt;

&lt;h2&gt;
  
  
  The round trip
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;You finish a decision and tap &lt;strong&gt;Ask a friend&lt;/strong&gt;. The app builds a link that contains the decision title and the option names, but &lt;strong&gt;not your ratings&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Your friend opens it, answers the same 7 questions, and gets their own result.&lt;/li&gt;
&lt;li&gt;Their result screen gives them a link back to you. That link contains their answers. You open it and see "you vs friend": whether the winner matches and which question you disagree on most.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Nothing is stored anywhere except the two browsers.&lt;/p&gt;

&lt;h2&gt;
  
  
  Encoding state into the URL
&lt;/h2&gt;

&lt;p&gt;The payload is JSON, UTF-8 encoded, then base64, then URL-encoded:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;encodeBase64&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;unknown&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;obj&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;bytes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;TextEncoder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;encode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;binary&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromCharCode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;b&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;""&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nf"&gt;encodeURIComponent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;btoa&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;binary&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;TextEncoder&lt;/code&gt; matters: plain &lt;code&gt;btoa&lt;/code&gt; throws on non-Latin-1 characters, and people name their options in every language.&lt;/p&gt;

&lt;h2&gt;
  
  
  Making the links ~5x shorter
&lt;/h2&gt;

&lt;p&gt;The first version put the whole decision in the link, including the full text of all 7 questions. That made links long enough to look like spam in WhatsApp.&lt;/p&gt;

&lt;p&gt;The fix was to send only what the receiver can't rebuild. The questions are fixed templates in the app, so a link carries a &lt;code&gt;templateId&lt;/code&gt; and the receiver looks the text up locally:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;FriendV2&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;v&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;templateId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;options&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// no ratings&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The version field keeps old links working: if &lt;code&gt;v&lt;/code&gt; isn't 2, the app decodes the old full format.&lt;/p&gt;

&lt;p&gt;When the friend's answers come back, the app checks whether this browser holds a decision with the same option ids. If it does, you are the owner and you get the comparison. If not, it's the friend's own device and they just see their result.&lt;/p&gt;

&lt;h2&gt;
  
  
  Scoring
&lt;/h2&gt;

&lt;p&gt;The score is a plain weighted average on a 1-5 scale. When two options tie exactly, the one that wins on the highest-weighted question goes first. That uses the user's own priorities instead of a random pick:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;raw&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;decision&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;criteria&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sum&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;sum&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;option&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;answers&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;??&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;weight&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;score&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;raw&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="n"&gt;totalWeight&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  SEO for a client-side app
&lt;/h2&gt;

&lt;p&gt;An SPA that renders in the browser is nearly invisible to crawlers. I didn't want SSR for a tiny app, so:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;guide pages ("how to choose between two job offers" and similar) are generated as static HTML at build time. They import the &lt;strong&gt;same&lt;/strong&gt; scoring code as the app, so the worked examples on the page always match what the app would compute;&lt;/li&gt;
&lt;li&gt;each guide's button opens the app with the example pre-filled (&lt;code&gt;/new?title=...&amp;amp;o=...&amp;amp;o=...&lt;/code&gt;);&lt;/li&gt;
&lt;li&gt;the home page ships a small static block inside &lt;code&gt;#root&lt;/code&gt; that React replaces on load.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why no AI
&lt;/h2&gt;

&lt;p&gt;A chatbot can give you a confident answer about your life from one paragraph of context. I wanted the opposite: the answer comes from your own honest ratings, and you can see exactly why an option won. The questions are inspired by Schwartz's research on basic human values and by regret minimization. The weights are the app's defaults and I'm open about that.&lt;/p&gt;

&lt;p&gt;You can try it here: &lt;a href="https://weigh-pwa.web.app/?ref=devto" rel="noopener noreferrer"&gt;https://weigh-pwa.web.app/?ref=devto&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'd love feedback on two things. Did the result match your gut feeling? And which of the 7 questions felt wrong for your decision?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This post was written with AI assistance and reviewed against the app's source code.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>react</category>
      <category>javascript</category>
      <category>showdev</category>
    </item>
  </channel>
</rss>
