<?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: Jesee Jackson Kuya</title>
    <description>The latest articles on DEV Community by Jesee Jackson Kuya (@jeseekuya).</description>
    <link>https://dev.to/jeseekuya</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%2F1794282%2F748f861f-b1cb-4823-8e81-5457e7b37338.png</url>
      <title>DEV Community: Jesee Jackson Kuya</title>
      <link>https://dev.to/jeseekuya</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jeseekuya"/>
    <language>en</language>
    <item>
      <title>Building Buddy: A Full-Stack Travel App Powered by AWS Aurora PostgreSQL and Vercel</title>
      <dc:creator>Jesee Jackson Kuya</dc:creator>
      <pubDate>Mon, 29 Jun 2026 11:41:19 +0000</pubDate>
      <link>https://dev.to/jeseekuya/building-buddy-a-full-stack-travel-app-powered-by-aws-aurora-postgresql-and-vercel-499l</link>
      <guid>https://dev.to/jeseekuya/building-buddy-a-full-stack-travel-app-powered-by-aws-aurora-postgresql-and-vercel-499l</guid>
      <description>&lt;p&gt;&lt;strong&gt;Hackathon submission:&lt;/strong&gt; This post was written as part of my entry for the &lt;a href="https://h01.devpost.com/" rel="noopener noreferrer"&gt;H0: Hack the Zero Stack with Vercel v0 and AWS Databases&lt;/a&gt; hackathon, sponsored by AWS and Vercel. I used &lt;strong&gt;Amazon Aurora PostgreSQL&lt;/strong&gt; as my database and deployed the entire application on &lt;strong&gt;Vercel&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Is Buddy?
&lt;/h2&gt;

&lt;p&gt;Travel is chaotic. You book a flight, then separately hunt for a hotel, then figure out how you're getting from the airport to your room. Three tabs, three confirmation emails, three things that can go wrong. &lt;strong&gt;Buddy&lt;/strong&gt; is a travel management app that pulls all of it into one place — flights, hotels, and airport transport, coordinated under a single trip.&lt;/p&gt;

&lt;p&gt;It's the kind of tool I would have wanted the last time I was scrambling to rearrange bookings after a delayed connection. So I built it.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Stack at a Glance
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Layer&lt;/th&gt;
&lt;th&gt;Technology&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Frontend &amp;amp; Backend&lt;/td&gt;
&lt;td&gt;Next.js 15 (App Router)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Auth&lt;/td&gt;
&lt;td&gt;NextAuth v5 (JWT, Credentials)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;ORM&lt;/td&gt;
&lt;td&gt;Prisma 5 with &lt;code&gt;driverAdapters&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Database&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Amazon Aurora PostgreSQL&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;DB Connection&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;pg&lt;/code&gt; pool + &lt;code&gt;@prisma/adapter-pg&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;IAM Auth&lt;/td&gt;
&lt;td&gt;&lt;code&gt;@aws-sdk/rds-signer&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Hosting&lt;/td&gt;
&lt;td&gt;&lt;strong&gt;Vercel&lt;/strong&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;UI&lt;/td&gt;
&lt;td&gt;Tailwind CSS + shadcn/ui + Framer Motion&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Data fetching&lt;/td&gt;
&lt;td&gt;TanStack Query + React Hook Form&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  Why Aurora PostgreSQL?
&lt;/h2&gt;

&lt;p&gt;When the hackathon gave three database options — Aurora PostgreSQL, Aurora DSQL, and DynamoDB — the choice for a travel booking app was straightforward: relational data all the way.&lt;/p&gt;

&lt;p&gt;Trips, flights, hotels, and transport bookings are deeply relational. A trip has many bookings. A booking references a specific flight, which belongs to an airline, which operates between two airports. A payment is tied to a booking. Notifications reference trips and users. Trying to model this in a document store would mean either deeply nested documents or endless manual joins in application code. A proper relational schema handles it cleanly.&lt;/p&gt;

&lt;p&gt;Aurora PostgreSQL gave me everything I needed:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Full PostgreSQL compatibility&lt;/strong&gt; — Prisma works with it out of the box.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;High availability&lt;/strong&gt; — Multi-AZ replication without managing it myself.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;IAM authentication&lt;/strong&gt; — Token-based DB auth without embedding a static password anywhere.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Scalable&lt;/strong&gt; — Aurora scales read capacity independently; important for a search-heavy app like this.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Extensions&lt;/strong&gt; — I used &lt;code&gt;uuid-ossp&lt;/code&gt;, &lt;code&gt;citext&lt;/code&gt;, and &lt;code&gt;pg_stat_statements&lt;/code&gt; for UUIDs, case-insensitive text matching on emails, and query performance monitoring.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Designing the Database Schema
&lt;/h2&gt;

&lt;p&gt;The schema covers seven main domains:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Users &amp;amp; Profiles
Trips
Flights → Flight Bookings
Hotels → Hotel Bookings
Transport Providers → Transport Bookings
Payments
Notifications
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A few design decisions worth calling out:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Soft deletes everywhere.&lt;/strong&gt; Every user-facing model has a &lt;code&gt;deletedAt&lt;/code&gt; field. Booking history and audit trails matter in a travel context — you can't just hard-delete a payment record.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;citext&lt;/code&gt; for emails.&lt;/strong&gt; Email addresses are case-insensitive by convention but not by default in PostgreSQL. Using the &lt;code&gt;citext&lt;/code&gt; extension means &lt;code&gt;User@Example.com&lt;/code&gt; and &lt;code&gt;user@example.com&lt;/code&gt; are treated as the same value at the database level, not in application code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;UUID primary keys.&lt;/strong&gt; All IDs are &lt;code&gt;uuid_generate_v4()&lt;/code&gt; defaults. No sequential integers that could be enumerated or guessed via the API.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Enum types.&lt;/strong&gt; Booking statuses, payment statuses, trip types, and user roles are all PostgreSQL enums. The database enforces valid state values — the application layer can't accidentally insert a typo.&lt;/p&gt;




&lt;h2&gt;
  
  
  Connecting to Aurora: IAM Authentication
&lt;/h2&gt;

&lt;p&gt;This was the most interesting engineering challenge. Rather than embedding a static database password, I wanted to use AWS IAM token authentication — Aurora generates a short-lived signed token that acts as the password, which is refreshed every 15 minutes.&lt;/p&gt;

&lt;p&gt;Here's the core of how it works in &lt;code&gt;lib/prisma.ts&lt;/code&gt;:&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="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;createIamClient&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="nb"&gt;Promise&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;PrismaClient&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;signer&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;Signer&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;region&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;AWS_REGION&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;hostname&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DB_HOST&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DB_PORT&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="na"&gt;username&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DB_USER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;credentials&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;accessKeyId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;AWS_ACCESS_KEY_ID&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;secretAccessKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;AWS_SECRET_ACCESS_KEY&lt;/span&gt;&lt;span class="o"&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;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;signer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getAuthToken&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;pool&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;Pool&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
    &lt;span class="na"&gt;host&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DB_HOST&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;port&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Number&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DB_PORT&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
    &lt;span class="na"&gt;user&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DB_USER&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;           &lt;span class="c1"&gt;// IAM token used as the password&lt;/span&gt;
    &lt;span class="na"&gt;database&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;process&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;env&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DB_NAME&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;ssl&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;rejectUnauthorized&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;false&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="nx"&gt;adapter&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;PrismaPg&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;pool&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;PrismaClient&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;adapter&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;The client is cached on the global object with a 14-minute expiry — just under the 15-minute token TTL — and recreated automatically before it expires:&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="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;g&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;__prismaClient&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;now&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;g&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;__prismaExpiry&lt;/span&gt; &lt;span class="o"&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="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;g&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;__prismaClient&lt;/span&gt;   &lt;span class="c1"&gt;// reuse cached client&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c1"&gt;// otherwise: generate a new IAM token and reconnect&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The exported &lt;code&gt;prisma&lt;/code&gt; is a &lt;code&gt;Proxy&lt;/code&gt; object that transparently awaits the async client on every call, so the rest of the codebase uses it like a normal synchronous Prisma instance.&lt;/p&gt;

&lt;p&gt;If you're running without IAM auth (local dev with a direct connection string), you just set &lt;code&gt;DB_IAM_AUTH=false&lt;/code&gt; and it falls back to a standard &lt;code&gt;PrismaClient&lt;/code&gt; backed by &lt;code&gt;DATABASE_URL&lt;/code&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  The API Layer
&lt;/h2&gt;

&lt;p&gt;The app exposes a clean set of REST endpoints under &lt;code&gt;/api&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight http"&gt;&lt;code&gt;&lt;span class="err"&gt;POST  /api/auth/register
GET   /api/flights/search
GET   /api/flights/[id]
POST  /api/flights/[id]/book
GET   /api/flights/bookings
GET   /api/hotels/search
GET   /api/hotels/[id]
POST  /api/hotels/[id]/book
GET   /api/hotels/bookings
GET   /api/trips
POST  /api/trips
GET   /api/trips/[id]
GET   /api/trips/[id]/timeline
GET   /api/transport
POST  /api/transport
POST  /api/payments
GET   /api/notifications
PATCH /api/notifications/[id]/read
GET   /api/airports
POST  /api/promotions/validate
GET   /api/profile
PUT   /api/profile
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each route is a thin handler that validates input with Zod and delegates to a domain service (&lt;code&gt;flight.service.ts&lt;/code&gt;, &lt;code&gt;hotel.service.ts&lt;/code&gt;, etc.) which executes Prisma queries. This keeps route files small and makes the business logic testable in isolation.&lt;/p&gt;




&lt;h2&gt;
  
  
  Authentication with NextAuth v5
&lt;/h2&gt;

&lt;p&gt;Auth runs on NextAuth v5 (beta) with a Credentials provider. On login, the server:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Validates the submitted email/password with Zod.&lt;/li&gt;
&lt;li&gt;Looks up the user in Aurora via Prisma (&lt;code&gt;prisma.user.findFirst&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Compares the submitted password against the stored bcrypt hash.&lt;/li&gt;
&lt;li&gt;Returns a JWT session containing the user's ID and role.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;handlers&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;signIn&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;signOut&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;NextAuth&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;authConfig&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;providers&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="nc"&gt;Credentials&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="nf"&gt;authorize&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;credentials&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="nx"&gt;parsed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;credentialsSchema&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;safeParse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;credentials&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;parsed&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;success&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;

        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;prisma&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findFirst&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
          &lt;span class="na"&gt;where&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;equals&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;parsed&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;mode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;insensitive&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="na"&gt;deletedAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
          &lt;span class="na"&gt;include&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;profile&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
        &lt;span class="p"&gt;})&lt;/span&gt;

        &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;passwordHash&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;valid&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;compare&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;parsed&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;passwordHash&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;valid&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;email&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;role&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;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;Route protection happens in &lt;code&gt;middleware.ts&lt;/code&gt;, which checks the session before any protected path (&lt;code&gt;/dashboard&lt;/code&gt;, &lt;code&gt;/trips&lt;/code&gt;, &lt;code&gt;/flights&lt;/code&gt;, etc.) reaches its page or API handler.&lt;/p&gt;




&lt;h2&gt;
  
  
  Deploying to Vercel
&lt;/h2&gt;

&lt;p&gt;Deploying a Next.js app to Vercel is straightforward, but a Prisma-backed app has one extra requirement: the Prisma client needs to be generated from the schema during the build step. The default &lt;code&gt;next build&lt;/code&gt; script doesn't do this.&lt;/p&gt;

&lt;p&gt;The fix is a one-line change to &lt;code&gt;package.json&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="nl"&gt;"build"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"prisma generate &amp;amp;&amp;amp; next build"&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This ensures Vercel generates the typed Prisma client before the TypeScript compilation starts.&lt;/p&gt;

&lt;p&gt;The environment variables that need to be set in the Vercel dashboard:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight properties"&gt;&lt;code&gt;&lt;span class="err"&gt;DATABASE_URL&lt;/span&gt;
&lt;span class="err"&gt;NEXTAUTH_SECRET&lt;/span&gt;
&lt;span class="err"&gt;NEXTAUTH_URL&lt;/span&gt;
&lt;span class="err"&gt;DB_IAM_AUTH&lt;/span&gt;
&lt;span class="err"&gt;DB_HOST&lt;/span&gt;
&lt;span class="err"&gt;DB_PORT&lt;/span&gt;
&lt;span class="err"&gt;DB_USER&lt;/span&gt;
&lt;span class="err"&gt;DB_NAME&lt;/span&gt;
&lt;span class="err"&gt;AWS_REGION&lt;/span&gt;
&lt;span class="err"&gt;AWS_ACCESS_KEY_ID&lt;/span&gt;
&lt;span class="err"&gt;AWS_SECRET_ACCESS_KEY&lt;/span&gt;
&lt;span class="err"&gt;NEXT_PUBLIC_APP_URL&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  What I Learned
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;IAM token rotation is elegant but has edge cases.&lt;/strong&gt; The 15-minute token TTL meant I had to think carefully about long-lived serverless function instances re-using a stale connection. The 14-minute cache expiry with automatic reconnection handles this cleanly, but it's not something you'd think about with a traditional always-on server.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Prisma adapter approach is worth the setup.&lt;/strong&gt; Using &lt;code&gt;@prisma/adapter-pg&lt;/code&gt; with a &lt;code&gt;pg.Pool&lt;/code&gt; instead of Prisma's built-in connection pooling gives you much more control — especially important when the "password" is a dynamically generated token.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Soft deletes need discipline.&lt;/strong&gt; Once you add &lt;code&gt;deletedAt&lt;/code&gt; to a model, every query that should only return active records needs a &lt;code&gt;where: { deletedAt: null }&lt;/code&gt; clause. I handled this at the service layer so it never leaks into route handlers, but it's easy to miss one.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Aurora PostgreSQL extensions are powerful.&lt;/strong&gt; &lt;code&gt;citext&lt;/code&gt; alone saved me from a whole class of subtle auth bugs where email casing could cause a user to fail login or accidentally create a duplicate account.&lt;/p&gt;




&lt;h2&gt;
  
  
  Architecture
&lt;/h2&gt;

&lt;p&gt;The full architecture diagram is included in the repository (&lt;code&gt;architecture.png&lt;/code&gt;), showing how the browser, Vercel platform, Next.js App Router, NextAuth, Prisma, and Aurora PostgreSQL all connect.&lt;/p&gt;




&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;Buddy started as a frustration with how fragmented travel planning tools are. The H0: Hack the Zero Stack hackathon gave me the right constraints to build it properly — Aurora PostgreSQL for the data layer, Vercel for deployment — and pushed me to solve real infrastructure problems like IAM authentication and Prisma on serverless.&lt;/p&gt;

&lt;p&gt;The result is a full-stack travel app that I'd actually use. Which, honestly, is the best thing you can say about something you built in a hackathon.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Built for the &lt;a href="https://h01.devpost.com/" rel="noopener noreferrer"&gt;H0: Hack the Zero Stack with Vercel v0 and AWS Databases&lt;/a&gt; hackathon. Database: Amazon Aurora PostgreSQL. Hosting: Vercel.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>postgressql</category>
      <category>h0hackathon</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Many Days Later</title>
      <dc:creator>Jesee Jackson Kuya</dc:creator>
      <pubDate>Sat, 28 Mar 2026 01:04:20 +0000</pubDate>
      <link>https://dev.to/jeseekuya/many-days-later-56fn</link>
      <guid>https://dev.to/jeseekuya/many-days-later-56fn</guid>
      <description>&lt;p&gt;I owe you an apology.&lt;br&gt;
I said I was going to document my journey learning Rust daily…&lt;/p&gt;

&lt;p&gt;Yeah… that didn’t happen 😅&lt;/p&gt;

&lt;p&gt;Life happened. Work happened. Overthinking happened.&lt;/p&gt;

&lt;p&gt;But I didn’t stop learning.&lt;/p&gt;

&lt;p&gt;And honestly, that’s what matters.&lt;/p&gt;

&lt;p&gt;So here we are — &lt;strong&gt;many days later&lt;/strong&gt;.&lt;/p&gt;


&lt;h1&gt;
  
  
  Quick Recap
&lt;/h1&gt;

&lt;p&gt;Last time, we:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Installed Rust&lt;/li&gt;
&lt;li&gt;Built a simple guessing game&lt;/li&gt;
&lt;li&gt;Learned basic syntax (&lt;code&gt;let&lt;/code&gt;, &lt;code&gt;mut&lt;/code&gt;, &lt;code&gt;match&lt;/code&gt;, &lt;code&gt;use&lt;/code&gt;)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At that point, Rust felt…&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Not that scary.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;But then I kept going.&lt;/p&gt;

&lt;p&gt;And I finally met the thing everyone warns you about:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Ownership&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;


&lt;h1&gt;
  
  
  The Project
&lt;/h1&gt;

&lt;p&gt;Before we dive in, let me make this real.&lt;/p&gt;

&lt;p&gt;I’m not just learning Rust for fun.&lt;/p&gt;

&lt;p&gt;I’m building something.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;A &lt;strong&gt;ride sharing app&lt;/strong&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Think:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;requesting rides&lt;/li&gt;
&lt;li&gt;matching drivers&lt;/li&gt;
&lt;li&gt;tracking trips&lt;/li&gt;
&lt;li&gt;handling payments (eventually)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Why this?&lt;/p&gt;

&lt;p&gt;Because it’s complex enough to &lt;strong&gt;force me to actually understand Rust&lt;/strong&gt;, not just play with syntax.&lt;/p&gt;


&lt;h1&gt;
  
  
  So… What is Ownership?
&lt;/h1&gt;

&lt;p&gt;Let me explain this in the simplest way possible.&lt;/p&gt;

&lt;p&gt;Ownership is basically:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Who owns a piece of data in your program&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And Rust is VERY strict about this.&lt;/p&gt;


&lt;h1&gt;
  
  
  Imagine This
&lt;/h1&gt;

&lt;p&gt;You have money.&lt;/p&gt;

&lt;p&gt;Only one person can own it at a time.&lt;/p&gt;

&lt;p&gt;You can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;give it away&lt;/li&gt;
&lt;li&gt;borrow it&lt;/li&gt;
&lt;li&gt;or keep it&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But you can’t have &lt;strong&gt;two real owners at the same time&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That’s exactly how Rust treats data.&lt;/p&gt;


&lt;h1&gt;
  
  
  Example Time
&lt;/h1&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;s1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nn"&gt;String&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"hello"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;s2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;s1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Looks harmless, right?&lt;/p&gt;

&lt;p&gt;Wrong.&lt;/p&gt;

&lt;p&gt;After this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;s1&lt;/code&gt; is &lt;strong&gt;no longer valid&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;s2&lt;/code&gt; now owns the data&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you try to use &lt;code&gt;s1&lt;/code&gt;, Rust will stop you immediately.&lt;/p&gt;


&lt;h1&gt;
  
  
  Why Does Rust Do This?
&lt;/h1&gt;

&lt;p&gt;Because Rust wants to prevent:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;memory leaks&lt;/li&gt;
&lt;li&gt;crashes&lt;/li&gt;
&lt;li&gt;weird bugs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Languages like JavaScript or Python hide this from you.&lt;/p&gt;

&lt;p&gt;Rust says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“No. You will deal with memory properly.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;At first, it feels annoying.&lt;/p&gt;

&lt;p&gt;Then you realize:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;This is actually protecting you.&lt;/p&gt;
&lt;/blockquote&gt;


&lt;h1&gt;
  
  
  The First Confusing Moment
&lt;/h1&gt;

&lt;p&gt;When I saw this, I was like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Wait… why can’t I use s1 anymore?
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It felt unnecessary.&lt;/p&gt;

&lt;p&gt;But then it clicked.&lt;/p&gt;

&lt;p&gt;Rust is making sure:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;There is &lt;strong&gt;only one clear owner&lt;/strong&gt; of data at any time.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h1&gt;
  
  
  Borrowing (This Saved Me)
&lt;/h1&gt;

&lt;p&gt;Instead of giving away ownership, you can &lt;strong&gt;borrow&lt;/strong&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;s1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nn"&gt;String&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;from&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"hello"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;len&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;calculate_length&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;s1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="nd"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Length: {len}"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;calculate_length&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="nb"&gt;String&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;-&amp;gt;&lt;/span&gt; &lt;span class="nb"&gt;usize&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="nf"&gt;.len&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;Notice this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;s1&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That &lt;code&gt;&amp;amp;&lt;/code&gt; means:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“I’m borrowing this, not taking it.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;So:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;s1&lt;/code&gt; is still valid&lt;/li&gt;
&lt;li&gt;the function just uses it temporarily&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Real Life Meaning
&lt;/h1&gt;

&lt;p&gt;Think of it like this:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ownership → giving someone your car&lt;/li&gt;
&lt;li&gt;Borrowing → letting someone drive your car&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Big difference.&lt;/p&gt;




&lt;h1&gt;
  
  
  Why This Matters (Especially for My Project)
&lt;/h1&gt;

&lt;p&gt;Remember the ride sharing app?&lt;/p&gt;

&lt;p&gt;We’ll have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;users&lt;/li&gt;
&lt;li&gt;drivers&lt;/li&gt;
&lt;li&gt;trips&lt;/li&gt;
&lt;li&gt;locations&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Data will be moving everywhere.&lt;/p&gt;

&lt;p&gt;Without ownership rules, things could get messy:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;multiple parts of the app modifying the same data&lt;/li&gt;
&lt;li&gt;crashes&lt;/li&gt;
&lt;li&gt;inconsistent states&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Rust prevents this at &lt;strong&gt;compile time&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Meaning:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Bugs are caught BEFORE the app runs.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That’s huge.&lt;/p&gt;




&lt;h1&gt;
  
  
  My Honest Experience
&lt;/h1&gt;

&lt;p&gt;Ownership is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;confusing at first&lt;/li&gt;
&lt;li&gt;frustrating in the beginning&lt;/li&gt;
&lt;li&gt;but makes sense over time&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I won’t lie…&lt;/p&gt;

&lt;p&gt;I had to re-read parts of the Rust book multiple times.&lt;/p&gt;

&lt;p&gt;But once it clicks, you start seeing:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Oh… this is actually clean.”&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h1&gt;
  
  
  What I’ve Learned So Far
&lt;/h1&gt;

&lt;p&gt;After spending more time with Rust:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It forces discipline&lt;/li&gt;
&lt;li&gt;It doesn’t allow shortcuts&lt;/li&gt;
&lt;li&gt;It makes you think before coding&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And I’m starting to understand why people say:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Rust changes how you think about programming&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h1&gt;
  
  
  What’s Next
&lt;/h1&gt;

&lt;p&gt;Now that ownership is (kind of) making sense…&lt;/p&gt;

&lt;p&gt;Next up:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;borrowing deeper&lt;/li&gt;
&lt;li&gt;references&lt;/li&gt;
&lt;li&gt;lifetimes (yes… that scary word)&lt;/li&gt;
&lt;li&gt;and starting the &lt;strong&gt;ride sharing backend&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Final Thoughts
&lt;/h1&gt;

&lt;p&gt;I didn’t keep up with daily updates.&lt;/p&gt;

&lt;p&gt;That’s on me.&lt;/p&gt;

&lt;p&gt;But I didn’t quit.&lt;/p&gt;

&lt;p&gt;And honestly, that’s the real journey.&lt;/p&gt;

&lt;p&gt;We’re still going from:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;0 → 1&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Just not in a straight line.&lt;/p&gt;




</description>
      <category>beginners</category>
      <category>devjournal</category>
      <category>learning</category>
      <category>rust</category>
    </item>
    <item>
      <title>RUST:MY JOURNEY FROM 0 TO 1(Day 1)</title>
      <dc:creator>Jesee Jackson Kuya</dc:creator>
      <pubDate>Thu, 12 Mar 2026 08:50:06 +0000</pubDate>
      <link>https://dev.to/jeseekuya/rustmy-journey-from-0-to-1day-1-51co</link>
      <guid>https://dev.to/jeseekuya/rustmy-journey-from-0-to-1day-1-51co</guid>
      <description>&lt;p&gt;You’ve probably heard the rumors and hype surrounding Rust.&lt;/p&gt;

&lt;p&gt;The language that &lt;em&gt;does everything&lt;/em&gt;.&lt;br&gt;
The language developers fear.&lt;br&gt;
The language AI supposedly struggles with.&lt;br&gt;
The language companies are rewriting their entire codebases in.&lt;/p&gt;

&lt;p&gt;And so on...&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6pfy5yad5id92h3a780k.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6pfy5yad5id92h3a780k.jpeg" alt="typical" width="282" height="178"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;But how much of this is actually true?&lt;/p&gt;

&lt;p&gt;This series is my journey to &lt;strong&gt;debunk the rumors&lt;/strong&gt;. I want to see for myself what Rust is really about.&lt;/p&gt;

&lt;p&gt;The goal is simple:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Learn Rust and ship a real product to production.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;And I’ll track &lt;strong&gt;how many days it actually takes&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I’m a firm believer in learning the hard way, so instead of watching 50 tutorials on YouTube, I’ll be using the official Rust documentation:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Rust Book&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://doc.rust-lang.org/book/" rel="noopener noreferrer"&gt;https://doc.rust-lang.org/book/&lt;/a&gt;&lt;/p&gt;


&lt;h1&gt;
  
  
  Installation
&lt;/h1&gt;

&lt;p&gt;Installing Rust is surprisingly easy.&lt;/p&gt;

&lt;p&gt;I’m using &lt;strong&gt;Manjaro Linux&lt;/strong&gt;, which is Arch-based. On most Linux distributions, you can install Rust with a single command.&lt;/p&gt;

&lt;p&gt;Open your terminal and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;--proto&lt;/span&gt; &lt;span class="s1"&gt;'=https'&lt;/span&gt; &lt;span class="nt"&gt;--tlsv1&lt;/span&gt;.2 https://sh.rustup.rs &lt;span class="nt"&gt;-sSf&lt;/span&gt; | sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This installs Rust using &lt;strong&gt;rustup&lt;/strong&gt;, the official installer and version manager.&lt;/p&gt;

&lt;p&gt;Honestly, this might be one of the &lt;strong&gt;smoothest language installations&lt;/strong&gt; I’ve ever done.&lt;/p&gt;




&lt;h3&gt;
  
  
  Important Note
&lt;/h3&gt;

&lt;p&gt;There’s one thing that can cause installation errors.&lt;/p&gt;

&lt;p&gt;Rust requires a &lt;strong&gt;C compiler&lt;/strong&gt; during installation.&lt;/p&gt;

&lt;p&gt;If you don't already have one installed, install &lt;code&gt;gcc&lt;/code&gt; first.&lt;/p&gt;

&lt;p&gt;On Arch / Manjaro:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;pacman &lt;span class="nt"&gt;-S&lt;/span&gt; base-devel
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the installation command fails, you can follow the official guide here:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://doc.rust-lang.org/book/ch01-01-installation.html" rel="noopener noreferrer"&gt;https://doc.rust-lang.org/book/ch01-01-installation.html&lt;/a&gt;&lt;/p&gt;




&lt;h1&gt;
  
  
  Jumping Right Into Rust
&lt;/h1&gt;

&lt;p&gt;The first example in the Rust book is a &lt;strong&gt;number guessing game&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Here’s the full code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nn"&gt;std&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;cmp&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Ordering&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nn"&gt;std&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;io&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nn"&gt;rand&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Rng&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nd"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Guess the number!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;secret_number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nn"&gt;rand&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;thread_rng&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="nf"&gt;.gen_range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;..=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;loop&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nd"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Please input your guess."&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="k"&gt;mut&lt;/span&gt; &lt;span class="n"&gt;guess&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nn"&gt;String&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

        &lt;span class="nn"&gt;io&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;stdin&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
            &lt;span class="nf"&gt;.read_line&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="k"&gt;mut&lt;/span&gt; &lt;span class="n"&gt;guess&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="nf"&gt;.expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Failed to read line"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;guess&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;u32&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;match&lt;/span&gt; &lt;span class="n"&gt;guess&lt;/span&gt;&lt;span class="nf"&gt;.trim&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="nf"&gt;.parse&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nf"&gt;Ok&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
            &lt;span class="nf"&gt;Err&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;continue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="p"&gt;};&lt;/span&gt;

        &lt;span class="nd"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"You guessed: {guess}"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="k"&gt;match&lt;/span&gt; &lt;span class="n"&gt;guess&lt;/span&gt;&lt;span class="nf"&gt;.cmp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;secret_number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nn"&gt;Ordering&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Less&lt;/span&gt; &lt;span class="k"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nd"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Too small!"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="nn"&gt;Ordering&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Greater&lt;/span&gt; &lt;span class="k"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nd"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Too big!"&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
            &lt;span class="nn"&gt;Ordering&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Equal&lt;/span&gt; &lt;span class="k"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nd"&gt;println!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"You win!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                &lt;span class="k"&gt;break&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;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you're new to Rust, this code might look a little unusual at first.&lt;/p&gt;

&lt;p&gt;But surprisingly, it becomes readable pretty quickly.&lt;/p&gt;

&lt;p&gt;Let’s break it down.&lt;/p&gt;




&lt;h1&gt;
  
  
  Understanding &lt;code&gt;use&lt;/code&gt;
&lt;/h1&gt;

&lt;p&gt;The first thing you notice is the code starting with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nn"&gt;std&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nn"&gt;cmp&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Ordering&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nn"&gt;std&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;io&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nn"&gt;rand&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Rng&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;use&lt;/code&gt; keyword is essentially &lt;strong&gt;Rust’s import system&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It tells the compiler which functionality from other modules we want to use.&lt;/p&gt;

&lt;p&gt;Think of it like:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Language&lt;/th&gt;
&lt;th&gt;Import syntax&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Python&lt;/td&gt;
&lt;td&gt;&lt;code&gt;import random&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;JavaScript&lt;/td&gt;
&lt;td&gt;&lt;code&gt;import fs from "fs"&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Rust&lt;/td&gt;
&lt;td&gt;&lt;code&gt;use rand::Rng&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nn"&gt;std&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;io&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This imports Rust’s &lt;strong&gt;input/output library&lt;/strong&gt; so we can read input from the terminal.&lt;/p&gt;

&lt;p&gt;And this line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;use&lt;/span&gt; &lt;span class="nn"&gt;rand&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="n"&gt;Rng&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;imports a trait that allows us to generate random numbers.&lt;/p&gt;




&lt;h1&gt;
  
  
  Generating the Secret Number
&lt;/h1&gt;

&lt;p&gt;This line creates the number the user must guess:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;secret_number&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nn"&gt;rand&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;thread_rng&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="nf"&gt;.gen_range&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;..=&lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What’s happening here?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;thread_rng()&lt;/code&gt; creates a random number generator.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;gen_range(1..=100)&lt;/code&gt; generates a number between &lt;strong&gt;1 and 100&lt;/strong&gt;.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So every time the game runs, a new number is generated.&lt;/p&gt;




&lt;h1&gt;
  
  
  Variables in Rust
&lt;/h1&gt;

&lt;p&gt;This line creates a variable:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="k"&gt;mut&lt;/span&gt; &lt;span class="n"&gt;guess&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nn"&gt;String&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;new&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Two important things are happening here.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;let&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;let&lt;/code&gt; declares a variable.&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;code&gt;mut&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Rust variables are &lt;strong&gt;immutable by default&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;That means their value cannot change unless you explicitly say they can.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This value &lt;strong&gt;cannot be changed&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;But this can:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="k"&gt;mut&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Rust forces you to be &lt;strong&gt;explicit about mutation&lt;/strong&gt;, which helps prevent bugs.&lt;/p&gt;




&lt;h1&gt;
  
  
  Reading User Input
&lt;/h1&gt;

&lt;p&gt;This section reads input from the terminal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="nn"&gt;io&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nf"&gt;stdin&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="nf"&gt;.read_line&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="k"&gt;mut&lt;/span&gt; &lt;span class="n"&gt;guess&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;.expect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"Failed to read line"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What this does:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Waits for user input&lt;/li&gt;
&lt;li&gt;Stores it in the &lt;code&gt;guess&lt;/code&gt; variable&lt;/li&gt;
&lt;li&gt;Crashes with a helpful message if something fails&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Rust prefers &lt;strong&gt;explicit error handling&lt;/strong&gt;, which you’ll see a lot.&lt;/p&gt;




&lt;h1&gt;
  
  
  Pattern Matching
&lt;/h1&gt;

&lt;p&gt;One of Rust’s most powerful features is &lt;strong&gt;pattern matching&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This block converts the input into a number:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;let&lt;/span&gt; &lt;span class="n"&gt;guess&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;u32&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;match&lt;/span&gt; &lt;span class="n"&gt;guess&lt;/span&gt;&lt;span class="nf"&gt;.trim&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;&lt;span class="nf"&gt;.parse&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nf"&gt;Ok&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="nf"&gt;Err&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;_&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="k"&gt;continue&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;Here’s what’s happening:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The program tries to convert the input into a number.&lt;/li&gt;
&lt;li&gt;If it succeeds → use the number.&lt;/li&gt;
&lt;li&gt;If it fails → ignore it and ask again.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This avoids crashes if the user types something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;hello
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead of breaking the program, Rust simply loops again.&lt;/p&gt;




&lt;h1&gt;
  
  
  Comparing the Guess
&lt;/h1&gt;

&lt;p&gt;Now we compare the guess with the secret number.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight rust"&gt;&lt;code&gt;&lt;span class="k"&gt;match&lt;/span&gt; &lt;span class="n"&gt;guess&lt;/span&gt;&lt;span class="nf"&gt;.cmp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;secret_number&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;Rust compares the values and returns:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;Less&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Greater&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;Equal&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then we print the appropriate message.&lt;/p&gt;




&lt;h1&gt;
  
  
  What I Learned on Day 1
&lt;/h1&gt;

&lt;p&gt;After writing this small program, a few things became clear.&lt;/p&gt;

&lt;h3&gt;
  
  
  Rust is strict
&lt;/h3&gt;

&lt;p&gt;Rust forces you to write &lt;strong&gt;safe code&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This can feel annoying at first, but it prevents many bugs.&lt;/p&gt;




&lt;h3&gt;
  
  
  Rust is very explicit
&lt;/h3&gt;

&lt;p&gt;Nothing happens magically.&lt;/p&gt;

&lt;p&gt;You must clearly state:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;variable types&lt;/li&gt;
&lt;li&gt;mutability&lt;/li&gt;
&lt;li&gt;error handling&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Rust is not as scary as people say
&lt;/h3&gt;

&lt;p&gt;So far, it actually feels &lt;strong&gt;logical and structured&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Yes, the syntax is different, but it's not impossible to understand.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Plan
&lt;/h1&gt;

&lt;p&gt;The challenge continues.&lt;/p&gt;

&lt;p&gt;My goal is to go from &lt;strong&gt;zero to production&lt;/strong&gt; with Rust.&lt;/p&gt;

&lt;p&gt;Over the next posts I will explore:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ownership&lt;/li&gt;
&lt;li&gt;borrowing&lt;/li&gt;
&lt;li&gt;lifetimes&lt;/li&gt;
&lt;li&gt;crates&lt;/li&gt;
&lt;li&gt;building a real project&lt;/li&gt;
&lt;li&gt;deploying it&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And eventually ship something real.&lt;/p&gt;




&lt;h1&gt;
  
  
  Final Thoughts
&lt;/h1&gt;

&lt;p&gt;The hype around Rust is massive.&lt;/p&gt;

&lt;p&gt;But after the first day, one thing is clear:&lt;br&gt;
Rust is just another common language.&lt;/p&gt;

&lt;p&gt;Let’s see how far this rabbit hole goes.&lt;/p&gt;

</description>
      <category>rust</category>
      <category>programming</category>
      <category>learning</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Zero-Downtime Go Module Updates Using AI and CLI Automation</title>
      <dc:creator>Jesee Jackson Kuya</dc:creator>
      <pubDate>Sat, 10 May 2025 21:36:15 +0000</pubDate>
      <link>https://dev.to/jeseekuya/zero-downtime-go-module-updates-using-ai-and-cli-automation-11e8</link>
      <guid>https://dev.to/jeseekuya/zero-downtime-go-module-updates-using-ai-and-cli-automation-11e8</guid>
      <description>&lt;p&gt;&lt;em&gt;This is a submission for the &lt;a href="https://dev.to/challenges/aws-amazon-q-v2025-04-30"&gt;Amazon Q Developer "Quack The Code" Challenge&lt;/a&gt;: Crushing the Command Line&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What I Built
&lt;/h2&gt;

&lt;p&gt;I built a CLI tool in Go that automates safe dependency upgrades in Go projects using Amazon Q Developer. The tool addresses the common pain point of manually updating dependencies, which is often error-prone and time-consuming due to compatibility issues. Here's what it does:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Auto-scans Go projects for outdated dependencies

Uses Amazon Q to generate AI-powered compatibility reports

Predicts potential code conflicts before upgrading

Automatically applies safe upgrades, runs tests, and opens a GitHub PR
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The tool streamlines the entire upgrade pipeline while integrating AI-powered risk analysis before making any changes — something that's often missing in conventional dependency managers&lt;/p&gt;

&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2rswjk2tgz284l5nktzf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2rswjk2tgz284l5nktzf.png" alt=" " width="469" height="441"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa5egokdzy0hib0dty72u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa5egokdzy0hib0dty72u.png" alt=" " width="469" height="493"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Demo Flow:

    Run the CLI: ./q-dep-updater -path=~/dev/myproject -repo=me/myproject

    See predicted conflicts before upgrades

    PR automatically created once tests pass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Code Repository
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/jesee-kuya/cli-rules" rel="noopener noreferrer"&gt;🔗 GitHub Repository – cli-rules&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  How I Used Amazon Q Developer
&lt;/h2&gt;

&lt;p&gt;Amazon Q Developer was the intelligence behind this tool. I used the q chat CLI interface to:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Scan the project and extract outdated dependencies in structured JSON

Predict compatibility conflicts based on code patterns and version diffs

Generate a compatibility report with AI-based suggestions for refactoring
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;By integrating Amazon Q directly into the upgrade workflow, I was able to:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Detect breaking changes before installation

Avoid unnecessary manual debugging

Ensure only conflict-free upgrades move forward
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Tip:&lt;/p&gt;

&lt;p&gt;I found Amazon Q Developer's ability to contextualize Go code very effective when fed with detailed prompts about version differences. Using structured output like JSON made it easy to integrate with the CLI logic.&lt;/p&gt;

</description>
      <category>devchallenge</category>
      <category>awschallenge</category>
      <category>ai</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Understanding Runes in Go</title>
      <dc:creator>Jesee Jackson Kuya</dc:creator>
      <pubDate>Tue, 30 Jul 2024 12:01:10 +0000</pubDate>
      <link>https://dev.to/jeseekuya/understanding-runes-in-go-4ie5</link>
      <guid>https://dev.to/jeseekuya/understanding-runes-in-go-4ie5</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction to Runes&lt;/strong&gt;&lt;br&gt;
The American Standard Code for Information Interchange(ASCII) is a character set representing uppercase letters, lowercase letters, digits, and various punctuations and device-control characters.  The issue with the ASCII is it does not include most characters used in the world like Chinese characters and other character sets used by different languages. This limitation led to the invention of Unicode characters. Unicode is a superset of ASCII; It contains all the characters present in today's global writing system and it assigns each character a special Unicode Code Point. This Unicode Code Point is known as runes in Golang.&lt;/p&gt;

&lt;p&gt;Below is a representation of the ASCII table.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Oct   Dec   Hex   Char                        Oct   Dec   Hex   Char
────────────────────────────────────────────────────────────────────────
000   0     00    NUL '\0' (null character)   100   64    40    @
001   1     01    SOH (start of heading)      101   65    41    A
002   2     02    STX (start of text)         102   66    42    B
003   3     03    ETX (end of text)           103   67    43    C
004   4     04    EOT (end of transmission)   104   68    44    D
005   5     05    ENQ (enquiry)               105   69    45    E
006   6     06    ACK (acknowledge)           106   70    46    F
007   7     07    BEL '\a' (bell)             107   71    47    G
010   8     08    BS  '\b' (backspace)        110   72    48    H
011   9     09    HT  '\t' (horizontal tab)   111   73    49    I
012   10    0A    LF  '\n' (new line)         112   74    4A    J
013   11    0B    VT  '\v' (vertical tab)     113   75    4B    K
014   12    0C    FF  '\f' (form feed)        114   76    4C    L
015   13    0D    CR  '\r' (carriage ret)     115   77    4D    M
016   14    0E    SO  (shift out)             116   78    4E    N
017   15    0F    SI  (shift in)              117   79    4F    O
020   16    10    DLE (data link escape)      120   80    50    P
021   17    11    DC1 (device control 1)      121   81    51    Q
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A Unicode Code Point uniquely identifies a character in Unicode, where runes represent these characters as numbers. For instance, rune 32 denotes a space character. In Golang, &lt;code&gt;UTF-8&lt;/code&gt; encoding is utilized for characters (Unicode code points), represented by a sequence of 1 to 4 bytes. This makes runes the preferred method for string manipulation in Golang, facilitating direct interaction with characters. As software evolves, developers increasingly use runes to manage Unicode complexities, ensuring applications support multilingualism, emojis, and other Unicode functionalities.&lt;/p&gt;

&lt;p&gt;In Golang, a byte, an alias for uint8, spans 1 to 255, while a rune, aliasing &lt;code&gt;int32&lt;/code&gt;, signifies a Unicode code point, with characters encoded using &lt;code&gt;UTF-8&lt;/code&gt;. Runes empower developers to engage directly with characters.&lt;br&gt;
&lt;strong&gt;Working with Runes in Golang&lt;/strong&gt;&lt;br&gt;
There are different ways to initialize a rune in Golang. Let's use the Japanese Yen as an example. The Unicode code point of the Yen is &lt;code&gt;U+00A5.&lt;/code&gt;&lt;br&gt;
To initialize the yen, we can do so directly with the character or the Unicode representation of the character. This representation can be as an integer or a hexadecimal. The yen can also be initialized by an escape sequence. This escapes the U and + of the Unicode code point making it to be &lt;code&gt;\u00A5.&lt;/code&gt; The same escape as an octal escape will be &lt;code&gt;\245.&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main


func main() {
   yen := '¥'                  //initializing with the rune literal
   japYen := 165               //initializing with an integer
   jYen := 0x00A5              //initializing with a hex
   japanYen := '\u00A5'        //initializing with escape sequence
   japnYen := '\245'
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To print the rune as a character. You can use &lt;code&gt;fmt.Printf&lt;/code&gt; with the &lt;code&gt;%c&lt;/code&gt;  or type cast the rune variable to a string.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main


import "fmt"


func main() {
   yen := '¥'           // initializing with the rune literal
   japYen := 165        // initializing with an integer
   jYen := 0x00A5       // initializing with a hex
   japanYen := '\u00A5' // initializing with escape sequence
   japnYen := '\245'


   fmt.Printf("%c\n", yen)
   fmt.Printf("%c\n", japYen)
   // jYen is an int type, type cast it to rune then string to print the character.
   fmt.Println(string(rune(jYen)))
   fmt.Println(string(japanYen))
   fmt.Printf("%c\n", japnYen)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This program will print the  &lt;code&gt;'¥'&lt;/code&gt; character on the terminal as shown below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;\test$ go run .
¥
¥
¥
¥
¥
\test$
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Slicing a string will give you a byte. In string manipulation, that is not ideal because as stated earlier; strings in go are encoded as a sequence 1 t0 4 bytes.&lt;br&gt;
To get the individual characters in a string. Range over the string to get the runes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main


import "fmt"


func main() {
   str := "Happy Coding"


   // Range str to get the individual characters
   for _, v := range str {
       //This will print the characters one by one
       fmt.Println(string(v))
   }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above code will print the individual characters as follows;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/test$ go run .
H
a
p
p
Y


C
o
d
i
n
g
/test$
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To get the first character in a string. Range over, slicing it will give you the first byte, not the first character.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main


import "fmt"


func main() {
  str := "💞 code"


  // slicing a string gives you a byte not the character
  // not ideal for string manipulation
  fmt.Println(string(str[0]))


  // Range str to get the first character
  for i, v := range str {
     if i == 0 {
        fmt.Println(string(v))
     }
  }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The first printing will give you this character ð. This is not the first character that you wanted. Ranging the string gives you the right character as shown below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/test$ go run .
ð
💞
/test$

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To better understand how to work with runes, let us develop a function that works as a Stconv.Atoi package where it takes a string and returns an integer type.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Atoi takes a string and returns an int with an error message
func Atoi(str string) (int, error) {
   var num int
   neg := false //check for negative numbers
   // str[0] gives us a byte. In this case the first byte
   // since the negative sign is an Ascii character. It is encoded as 1 byte
   //non-ASCII characters are encoded as sequences of 2 to 4 bytes
   //Slicing, or indexing a string gives you a byte, not a rune
   if string(str[0]) == "-" {
       neg = true
       str = str[1:]
   }


   // To get the runes in the string, range over the string
   //Ranging a string gives you a rune, not a byte
   for _, v := range str {
       // In the ascii table. The characters 0 to 9 are arranged in order
       if v &amp;gt;= '0' &amp;amp;&amp;amp; v &amp;lt;= '9' {
           // Let's say v is the character 5 with the rune of 54
           // subtracting 54 from the rune of 0 which is 49
           // gives you 5
           num = num*10 + int(v-'0')
       } else {
           // characters with runes less than 49 and
           // runes greater than 58 will return 0 and a
           // parsing error
           return 0, fmt.Errorf(" parsing %v: invalid syntax", str)
       }
   }
   if neg {
       num *= -1
   }
   return num, nil
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Let’s write a program to test the function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main


import "fmt"


func main() {
  // I'm not checking for errors
  num, _ := Atoi("45")
  num1, _ := Atoi("89")
  // Print the sum of num and num1
  fmt.Println(num + num1)


  // I am checking for errors
  num2, err2 := Atoi("ax56")
  if err2 != nil {
     fmt.Println(err2)
  }
  // num2 will be zero
  fmt.Println(num2)
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above program will output the following;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/test$ go run .
134
parsing ax56: invalid syntax
0
/test$
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In summary, runes in Golang are fundamental for handling Unicode characters effectively within strings. They provide a way to represent and process individual characters in a way that is essential for robust and internationalized software development.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>go</category>
      <category>coding</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
