<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Todimu Isewon on Medium]]></title>
        <description><![CDATA[Stories by Todimu Isewon on Medium]]></description>
        <link>https://medium.com/@todimu_isewon?source=rss-8a4d5bb159c6------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*dbzHvJsHr_bMX3vh</url>
            <title>Stories by Todimu Isewon on Medium</title>
            <link>https://medium.com/@todimu_isewon?source=rss-8a4d5bb159c6------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 05:58:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@todimu_isewon/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Deploying Keycloak in Production-Style: Single-Node Setup with Docker, Nginx, and TLS]]></title>
            <link>https://medium.com/codex/deploying-keycloak-in-production-style-single-node-setup-with-docker-nginx-and-tls-c4375b3d255c?source=rss-8a4d5bb159c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/c4375b3d255c</guid>
            <dc:creator><![CDATA[Todimu Isewon]]></dc:creator>
            <pubDate>Wed, 16 Sep 2026 01:46:18 GMT</pubDate>
            <atom:updated>2026-09-16T11:37:31.131Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J8cs2DyO25dW3T_dpQPs7Q.png" /></figure><h3>Deploying Keycloak on AWS: A Production-Style Single-Node Setup</h3><h4>1. Introduction - From start-dev to Production</h4><p>This article is the first part of a three-part series documenting how to deploy Keycloak in a production-like environment. We’ll move beyond the <em>start-dev</em> command and set up Keycloak using a production-oriented architecture on a remote server. Along the way, we’ll configure a persistent database, a real domain name, TLS for HTTPS, and a reverse proxy to keep Keycloak from being directly exposed to the internet.</p><p>The setup in this article is suitable for small-scale projects and internal applications that don’t require high availability. We’ll keep the architecture intentionally simple while introducing the core concepts and practices you need when moving Keycloak from local development toward production. In the next article, we’ll build on this foundation and introduce a highly available Keycloak cluster.</p><h4><strong>2. What This Article Covers</strong></h4><p>This article focuses on deploying Keycloak, rather than explaining Keycloak fundamentals. I’m assuming you already have a basic understanding of Keycloak concepts such as realms, clients, users, roles, and authentication flows. We’ll cover:</p><p>• <strong>Keycloak: </strong>running Keycloak in production mode</p><p>• <strong>Docker &amp; Docker Compose: </strong>containerizing and managing the deployment</p><p>• <strong>AWS EC2: </strong>hosting Keycloak on a remote server</p><p>• <strong>MySQL: </strong>using a persistent external database</p><p>• <strong>Nginx: </strong>reverse proxy and TLS termination</p><p>• <strong>DNS</strong>: pointing a real domain to the server</p><p>• <strong>TLS / Let’s Encrypt: </strong>securing Keycloak with HTTPS</p><p>• <strong>Network Security: </strong>securing access to the server and exposed services</p><p>The goal is to take Keycloak from a local start-dev setup to a production-like deployment suitable for small-scale applications and internal projects.</p><h4><strong>3. What This Article Doesn’t Cover</strong></h4><p>This article focuses on deploying Keycloak, so I’ll assume some familiarity with concepts such as realms, clients, users, roles, OAuth2/OIDC, authentication flows, and the Keycloak Admin Console.</p><p>We won’t cover building applications that integrate with Keycloak, OAuth/OIDC fundamentals, or Keycloak authorization in depth. Kubernetes and high availability/clustering are also outside the scope of this article and will be covered later in the series.</p><h4><strong>4. What We’re Building</strong></h4><p>The deployment will use a single Keycloak instance behind Nginx, with MySQL as the persistent database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R2CFDkpnnuCtTzeqAgHuKA.png" /></figure><p>I’m placing Keycloak behind a reverse proxy because this is the deployment pattern recommended in the Keycloak documentation for exposing Keycloak through a proxy.</p><p>The idea is simple:</p><p>-&gt; <strong>Nginx</strong> is the public-facing component and handles HTTPS.</p><p>-&gt; <strong>Keycloak</strong> remains on the internal Docker network.</p><p>-&gt; <strong>MySQL</strong> provides persistent storage and is not exposed publicly.</p><p>-&gt; <strong>DNS</strong> points the public domain to the server.</p><p>-&gt; <strong>TLS</strong> terminates at Nginx before traffic is forwarded to Keycloak.</p><p>This gives us a relatively simple production-style architecture without introducing the additional complexity of load balancers, multiple Keycloak nodes, or Kubernetes. Those concerns will come later in the series.</p><p>I’m also using <strong>TLS edge termination</strong> at the reverse proxy, trading an additional layer of encryption for simplicity. Since Keycloak is communicating with Nginx over an isolated Docker network on the same server, I’m not establishing a second TLS connection between Nginx and Keycloak (reference <a href="https://www.keycloak.org/server/reverseproxy">here</a>).</p><h4>5. Setting Up the Server</h4><p>It’s now time to leave the intro and start building the cool stuff. Let us first create the EC2 instance and then map it’s public IP to your subdomain.</p><h4>5.1 Provisioning the EC2 Instance</h4><p>Create an <strong>Ubuntu EC2 instance</strong> to host the deployment. I recommend using at least a <strong>medium-sized instance</strong> for this setup, as smaller instances can feel sluggish when running multiple containers with Docker Compose.</p><p>Create a Security Group with the following inbound rules:</p><ul><li><strong>80 (HTTP): </strong>Allow from anywhere</li><li><strong>443 (HTTPS): </strong>Allow from anywhere</li><li><strong>22 (SSH): </strong>Allow only from your IP address</li><li><strong>3306 (MySQL): </strong>Allow only from specific trusted IPs if you need remote database access</li></ul><p>The goal is to keep the publicly exposed surface limited to <strong>HTTP/HTTPS</strong>, while restricting administrative and database access. No other ports should be exposed to the internet.</p><h4>5.2 Configuring DNS</h4><p>Create an <strong>A record</strong> with your DNS provider (I use Cloudfare) that points your domain (for example, auth.todimu.net) to the <strong>public IP address of your EC2 instance</strong>. Set the A record to <strong>DNS-only (grey cloud)</strong>, not proxied.</p><p>Once the record propagates, requests to your domain will resolve to the EC2 server, allowing Nginx to receive and route the traffic to Keycloak. You can test if this works by running the following command then getting your public IP as a response dig +short &lt;DOMAIN_NAME&gt; see sample below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DcOACs74E-lsAPkuRdLV5w.png" /></figure><h4>6. Moving Keycloak Out of Development Mode</h4><p>The first change is moving away from Keycloak’s development runtime. This is the most important part of this article as it forms a basis for all subsequent articles.</p><p>During local development, we can simply run the command below to spin up a docker container:</p><pre>docker run -d --name mykeycloak -p 8080:8080 \<br>  -e KC_BOOTSTRAP_ADMIN_USERNAME=admin \<br>  -e KC_BOOTSTRAP_ADMIN_PASSWORD=admin \<br>  quay.io/keycloak/keycloak:latest start-dev</pre><p>start-dev is convenient because Keycloak relaxes several requirements for development. For a real deployment, we’ll run Keycloak in production mode using an <strong>optimized Docker image</strong>, as recommended in the <a href="https://www.keycloak.org/server/containers">Keycloak container documentation.</a></p><p>Because we’re placing Keycloak behind a reverse proxy, we’ll also configure it to accept HTTP internally and correctly handle forwarded headers. Keycloak’s production setup expects HTTPS by default; see the <a href="https://www.keycloak.org/server/reverseproxy">reverse proxy documentation.</a></p><p>The final optimized Dockerfile is shown below:</p><pre>FROM quay.io/keycloak/keycloak:26.7.3 AS builder<br><br>ENV KC_HEALTH_ENABLED=true<br>ENV KC_METRICS_ENABLED=true<br>ENV KC_FEATURES=token-exchange,admin-fine-grained-authz<br><br>ENV KC_DB=mysql<br><br>WORKDIR /opt/keycloak<br><br>RUN /opt/keycloak/bin/kc.sh build<br><br>FROM quay.io/keycloak/keycloak:26.7.3<br><br>COPY --from=builder /opt/keycloak/ /opt/keycloak/<br><br>EXPOSE 8080<br>EXPOSE 9000<br>EXPOSE 8443<br><br>ENTRYPOINT [&quot;/opt/keycloak/bin/kc.sh&quot;, &quot;start&quot;, &quot;--optimized&quot;,  &quot;--http-enabled=true&quot;, &quot;--proxy-headers=xforwarded&quot;]</pre><ul><li>--http-enabled=true — Allows Keycloak to accept <strong>HTTP connections</strong>, which we need because Nginx handles HTTPS termination.</li><li>--proxy-headers=xforwarded — Tells Keycloak to use X-Forwarded-* headers from Nginx to determine the <strong>original client protocol and request details</strong>.</li></ul><h4>7. Giving Keycloak a Persistent Database</h4><p>Next, we need persistent storage for Keycloak. Keycloak supports several databases (see list <a href="https://www.keycloak.org/server/supported-configurations">here</a>), but we’ll use <strong>MySQL</strong> to ensure authentication data survives container restarts and recreation.</p><p>For this setup, MySQL runs in Docker with persistent storage, though <strong>Amazon RDS</strong> is also a suitable option.</p><h4>8. Bringing the Architecture Together</h4><p>Now we can bring everything together with Docker Compose, the docker compose file is too long to put here but you can view it <a href="https://github.com/Oluwatodimu/keycloak-setup/blob/main/docker-compose.yaml">here</a>.</p><p>All services share an iam-network, which provides Docker service discovery. This allows containers to communicate using service names:</p><pre>nginx → http://iam:8080<br>iam   → database:3306</pre><p>The setup consists of:</p><ul><li><strong>iam</strong> — Keycloak</li><li><strong>database</strong> — MySQL with a persistent volume</li><li><strong>nginx</strong> — reverse proxy and TLS termination</li><li><strong>iam-network</strong> — internal service network</li></ul><p>Keycloak doesn’t need to expose port 8080 publicly:</p><pre>expose:<br>  - &quot;8080&quot;</pre><p>Nginx can reach it internally using:</p><pre>http://iam:8080</pre><p>This keeps Keycloak off the public network; only Nginx exposes ports <strong>80 and 443</strong>.</p><h4>9. Configuring Keycloak’s Public Hostname</h4><p>Keycloak needs to know the <strong>public hostname</strong> it should use when generating URLs. Without this, it may use an internal address or the wrong host/scheme. This is configured in the environment variables.</p><p>We configure it with:</p><pre>KC_HOSTNAME=auth.todimu.net</pre><p>There are two different URLs in our architecture:</p><ol><li>Public URL</li></ol><pre>https://auth.todimu.net</pre><p>This is what the <strong>user and browser</strong> see.</p><p>2. Internal URL</p><pre>http://iam:8080</pre><p>This is what <strong>Nginx uses to communicate with Keycloak</strong> inside the Docker network.</p><p>So the flow is:</p><pre>Browser<br>   ↓<br>https://auth.todimu.net<br>   ↓<br>Nginx<br>   ↓<br>http://iam:8080<br>   ↓<br>Keycloak</pre><p>The public hostname tells Keycloak how it should identify itself externally, while the internal address is only used for service-to-service communication.</p><h4>10. Putting Nginx in Front of Keycloak</h4><p>Rather than exposing Keycloak directly to the internet, we’ll place <strong>Nginx in front of it as a reverse proxy</strong>.</p><pre>Browser<br>   │<br>   │ HTTPS<br>   ▼<br> Nginx<br>   │<br>   │ HTTP<br>   ▼<br>Keycloak</pre><p>Nginx handles <strong>TLS termination</strong> and forwards the request to Keycloak over the internal Docker network. It also passes the original request information through forwarded headers:</p><pre>proxy_set_header X-Forwarded-Proto https;<br>proxy_set_header X-Forwarded-Host $host;<br>proxy_set_header X-Forwarded-Port 443;</pre><p>This is why Keycloak is configured with:</p><pre>&quot;--proxy-headers=xforwarded&quot;</pre><p>Together, these configurations allow Keycloak to understand that the original request was made over HTTPS to the public hostname, even though Nginx communicates with it over HTTP internally.</p><p>This also means <strong>Keycloak itself doesn’t need to be publicly exposed</strong>. Only Nginx needs to accept internet traffic. You can see how I put the Nginx server in from of keycloak in my repo <a href="https://github.com/Oluwatodimu/keycloak-setup/blob/main/docker-compose.yaml">here</a>.</p><h4>11. DNS: Giving the Server a Name</h4><p>Point the Keycloak subdomain to the EC2 public IP:</p><pre>auth.todimu.net<br>       ↓<br>   EC2 public IP</pre><p>The domain is more than a friendly name. Keycloak uses it for <strong>OIDC issuer URLs, redirects, authentication links, email links, and browser access</strong>.</p><h4>12. Moving From the Local Machine to the EC2</h4><p>Everything we’ve done so far was on the local machine. From this point, we’ll move the deployment to the <strong>EC2 instance</strong> we created earlier.</p><p>To follow along, you can use the <a href="https://github.com/Oluwatodimu/keycloak-setup">GitHub repository</a> as a reference.</p><p>SSH into the EC2 instance and create a directory containing the <strong>optimized Keycloak Dockerfile</strong>, docker-compose.yml, and .env file. The Dockerfile and Compose file should be in the same directory.</p><p>You can clone them from GitHub or use any other method you prefer. The .env file should contain your secrets and <strong>should not be committed to the repository</strong>. I have pushed a sample .env file I created to set the Keycloak hostname and other variables needed, you can refer to them <a href="https://github.com/Oluwatodimu/keycloak-setup/blob/main/.env">here</a>.</p><p>You also need to download docker and docker compose on the ec2 and you can use <a href="https://medium.com/@prabhathchathura/how-to-install-docker-docker-compose-on-aws-ec2-ubuntu-beginner-friendly-guide-2ed1962d14ad">this</a> as a guide since the setup is out of scope of this article.</p><p>Once setup, you can then run the docker compose file using docker-compose up, and you should be able to reach the EC2 using the domain name we setup earlier. You should get the following result below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/305/1*G3m9xCZVbC5SBeOmJPEn7A.jpeg" /></figure><p>This is perfectly fine, we will enable HTTPs in the next section.</p><h4>13. Adding HTTPS with Let’s Encrypt</h4><p>Now that Nginx is handling public traffic, we can secure the connection with HTTPS.</p><pre>Browser<br>   │ HTTPS<br>   ▼<br> Nginx<br>   │ HTTP<br>   ▼<br>Keycloak</pre><p>There’s one catch that trips up most single-node tutorials: <strong>Nginx can’t start with a </strong><strong>443 server block that points at certificate files that don&#39;t exist yet.</strong> So we go in three moves, bring Nginx up on HTTP only, obtain the certificate, then switch on TLS.</p><h4>Step 1 - Start with an HTTP-only config</h4><p>Create nginx/conf.d/default.conf with just enough to serve the Let&#39;s Encrypt (ACME) challenge:</p><pre>server {<br>    listen 80;<br>    server_name auth.todimu.net;location /.well-known/acme-challenge/ {<br>        root /var/www/certbot;<br>    }<br>    location / {<br>        return 404;   # nothing else is served until TLS is up<br>    }<br>}</pre><p>Bring the stack up:</p><pre>docker compose up -d</pre><h4>Step 2 - Obtain the certificate with Certbot</h4><p>Certbot proves we control the domain by completing an ACME challenge, after which Let’s Encrypt issues the certificate.</p><pre>Certbot → ACME challenge → Nginx → Let&#39;s Encrypt → Certificate</pre><p>Run Certbot as a one-off container, mounting the same two directories Nginx uses (from the Compose file). Certbot writes challenge files into certbot/www (which Nginx serves) and the issued certificate into certbot/conf:</p><pre>docker run --rm \<br>  -v &quot;$(pwd)/certbot/www:/var/www/certbot&quot; \<br>  -v &quot;$(pwd)/certbot/conf:/etc/letsencrypt&quot; \<br>  certbot/certbot certonly \<br>    --webroot -w /var/www/certbot \<br>    -d auth.todimu.net \<br>    --email you@example.com --agree-tos --no-eff-email</pre><p>If DNS points correctly and port 80 is open, the certificate lands under certbot/conf/live/auth.todimu.net/.</p><h4>Step 3 - Enable HTTPS and lock down access</h4><p>Now replace nginx/conf.d/default.conf with the full configuration. It redirects HTTP to HTTPS (while still serving the ACME path for renewals), terminates TLS, and controls which paths are public:</p><pre># HTTP: ACME challenge + redirect everything else to HTTPS<br>server {<br>    listen 80;<br>    server_name auth.todimu.net;<br><br>    location /.well-known/acme-challenge/ {<br>        root /var/www/certbot;<br>    }<br><br>    location / {<br>        return 301 https://$host$request_uri;<br>    }<br>}<br><br># HTTPS<br>server {<br>    listen 443 ssl;<br>    http2 on;<br>    server_name auth.todimu.net;<br><br>    ssl_certificate     /etc/letsencrypt/live/auth.todimu.net/fullchain.pem;<br>    ssl_certificate_key /etc/letsencrypt/live/auth.todimu.net/privkey.pem;<br><br>    # Basic TLS hardening<br>    ssl_protocols TLSv1.2 TLSv1.3;<br>    ssl_prefer_server_ciphers off;<br>    add_header Strict-Transport-Security &quot;max-age=63072000&quot; always;<br><br>    # --- PUBLIC: OIDC endpoints (login, token, discovery, account) ---<br>    location /realms/ {<br>        proxy_pass http://iam:8080;<br>        proxy_set_header Host              $host;<br>        proxy_set_header X-Real-IP         $remote_addr;<br>        proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;<br>        proxy_set_header X-Forwarded-Proto https;<br>        proxy_set_header X-Forwarded-Host  $host;<br>        proxy_set_header X-Forwarded-Port  443;<br>    }<br><br>    # --- PUBLIC: login theme assets (CSS/JS) ---<br>    # Required, or the login page renders unstyled/broken for end users.<br>    location /resources/ {<br>        proxy_pass http://iam:8080;<br>        proxy_set_header Host              $host;<br>        proxy_set_header X-Real-IP         $remote_addr;<br>        proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;<br>        proxy_set_header X-Forwarded-Proto https;<br>        proxy_set_header X-Forwarded-Host  $host;<br>        proxy_set_header X-Forwarded-Port  443;<br>    }<br><br>    # --- RESTRICTED: Admin Console + Admin REST API ---<br>    location /admin/ {<br>        allow &lt;TRUSTED_IP_HERE&gt;;<br>        deny  all;<br><br>        proxy_pass http://iam:8080;<br>        proxy_set_header Host              $host;<br>        proxy_set_header X-Real-IP         $remote_addr;<br>        proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;<br>        proxy_set_header X-Forwarded-Proto https;<br>        proxy_set_header X-Forwarded-Host  $host;<br>        proxy_set_header X-Forwarded-Port  443;<br>    }<br><br>    # --- RESTRICTED: everything else ---<br>    location / {<br>        allow &lt;TRUSTED_IP_HERE&gt;;<br>        deny  all;<br><br>        proxy_pass http://iam:8080;<br>        proxy_set_header Host              $host;<br>        proxy_set_header X-Real-IP         $remote_addr;<br>        proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;<br>        proxy_set_header X-Forwarded-Proto https;<br>        proxy_set_header X-Forwarded-Host  $host;<br>        proxy_set_header X-Forwarded-Port  443;<br>    }<br>}</pre><p>Reload Nginx to pick up the new config and certificate:</p><pre>docker compose exec nginx nginx -s reload</pre><p>This Nginx configuration does four things:</p><ol><li><strong>HTTP → HTTPS</strong> — port 80 serves the ACME challenge and redirects everything else to HTTPS.</li><li><strong>TLS termination</strong> — port 443 handles HTTPS with the certificate issued for auth.todimu.net, on TLS with HSTS.</li><li><strong>Proxying</strong> — all traffic is forwarded to Keycloak at http://iam:8080 with the X-Forwarded-* headers Keycloak needs.</li><li><strong>Access control</strong> — the Admin Console (/admin/) and every non-OIDC path are restricted to a trusted IP, while /realms/ and /resources/ stay public.</li></ol><p><strong>Why </strong><strong>/resources/ must stay public:</strong> Keycloak serves its login-theme CSS and JavaScript under /resources/. If you restrict everything except /realms/ to your own IP, <em>you</em> will see a perfect login page while every other user gets an unstyled, broken one. Test a login from a device that isn&#39;t on your trusted IP (e.g. your phone on cellular) to confirm it renders.</p><h4>Automating renewal</h4><p>Let’s Encrypt certificates expire after 90 days, so issuance isn’t the whole story. Add a cron job on the EC2 host that renews and then reloads Nginx (renewal alone isn’t enough, Nginx keeps serving the old certificate until it’s reloaded):</p><pre># crontab -e  (daily at 03:00)<br>0 3 * * * cd /home/ubuntu/keycloak &amp;&amp; \<br>  docker run --rm \<br>    -v &quot;$(pwd)/certbot/www:/var/www/certbot&quot; \<br>    -v &quot;$(pwd)/certbot/conf:/etc/letsencrypt&quot; \<br>    certbot/certbot renew --quiet &amp;&amp; \<br>  docker compose exec -T nginx nginx -s reload</pre><p>Certbot only renews when a certificate is near expiry, so running this daily is safe.</p><p>Once this is in place, visit https://auth.todimu.net from your trusted IP and you should reach the Keycloak Admin Console over HTTPS.</p><p>Once you complete this, you can restart the nginx container and check if everything is working fine. See a sample below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sw_SRd0OMvTvBAy6EO_P1A.png" /></figure><p>You should then be able to access the admin portal when you visit the domain name we set up earlier.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FhlN59-17gImZa4HvvBixg.png" /></figure><p>If you made it this far I really appreciate your efforts and want to say a big thank you.</p><h4>14. Is This Actually Production?</h4><p>We’ve moved Keycloak from a local development setup to a <strong>production-style single-node deployment</strong> with:</p><ul><li>Production startup mode</li><li>Persistent database</li><li>Public hostname and HTTPS</li><li>Reverse proxy</li><li>Network isolation and access restrictions</li></ul><p>However, this setup still has limitations. There are no multiple Keycloak nodes, database HA, automatic certificate renewal, centralized secrets management, monitoring, automated deployments, or disaster recovery.</p><p>So while this architecture can be suitable for <strong>small applications or internal projects</strong>, it isn’t a highly available production architecture.</p><h4>15. Conclusion</h4><p>Deploying Keycloak beyond your local machine involves more than simply changing start-dev to start --optimized. We had to think about how Keycloak is exposed, how traffic reaches it, where authentication data is stored, and how the service is secured.</p><p>In this part, we built a <strong>production-style single-node deployment</strong> using EC2, Docker Compose, MySQL, Nginx, DNS, HTTPS, and network restrictions.</p><p>It’s intentionally simple and doesn’t try to solve every production concern. There is no clustering or failover yet, but we now have a solid foundation to build on.</p><p>In <strong>Part 2</strong>, we’ll take this setup further by introducing <strong>multiple Keycloak instances, clustering, and high availability</strong>.</p><p>Thank you for reading..</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c4375b3d255c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/deploying-keycloak-in-production-style-single-node-setup-with-docker-nginx-and-tls-c4375b3d255c">Deploying Keycloak in Production-Style: Single-Node Setup with Docker, Nginx, and TLS</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Conversational SQL: Enabling User-friendly Database Interactions with Gemini-Pro]]></title>
            <link>https://medium.com/codex/conversational-sql-enabling-user-friendly-database-interactions-with-gemini-pro-2e26c9828723?source=rss-8a4d5bb159c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e26c9828723</guid>
            <category><![CDATA[python]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[gemini]]></category>
            <category><![CDATA[sql]]></category>
            <dc:creator><![CDATA[Todimu Isewon]]></dc:creator>
            <pubDate>Thu, 02 May 2024 15:22:49 GMT</pubDate>
            <atom:updated>2024-05-04T07:47:47.511Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1WYKM7KY1WLaFhCs_R_NmA.png" /></figure><p>I got the idea to build this application after watching the Developer’s Keynote at the Google Next ’24 event. I saw how the CTO of <a href="https://www.honeycomb.io/">honeycomb</a> used it in her demo for querying API log data and decided to recreate that with something more relatable.</p><h4>Introduction</h4><p>In today’s data-driven world, accessing and querying databases is a crucial task for businesses of all sizes. However, for non-technical users, crafting SQL queries can be intimidating and challenging. That’s where this application comes in!</p><p>Powered by Python, Streamlit, and the innovative Gemini API, I built an application that aims to bridge the gap between non-technical users and databases. By leveraging natural language processing (NLP) capabilities, this app transforms everyday language into SQL queries, simplifying the database querying process for users with varying levels of technical expertise.</p><p>In this article, we’ll learn how to use Python and Streamlit to create an intuitive user interface and how the Gemini API enables us to generate SQL queries from user input. The aim of this project is to empower non-technical users to seamlessly interact with databases and unlock valuable insights from their data.</p><h4>Requirements</h4><ol><li>A code editor of choice.</li><li>Basic understanding of Python.</li><li>Basic understanding of relational databases and how to query them.</li><li>Gemini API key.</li></ol><h4>Building the Application</h4><p>In this section, I have broken down building the application into the following steps:</p><ol><li>Setting up the development environment.</li><li>Integrating the Gemini API for natural language processing.</li><li>Implementing the SQL querying logic.</li><li>Setting up the user interface.</li><li>Testing the application</li></ol><p>I will go ahead to explain each of these steps in great detail now.</p><h4>Setting up the development environment</h4><p>In this section, I have broken down setting up the development environment into two areas:</p><ol><li>python environment setup.</li><li>database setup.</li></ol><p>In order to setup the python environment, you can use any IDE you prefer and create a new project. After doing this, you should create a virtual environment so there is no need to download the dependencies globally. To set up the virtual environment, you need to create the virtual environment and then activate it. You can do this using the commands:</p><pre>python3 -m venv venv # create the virtual environment<br><br>source venv/bin/activate # activate the virtual environment</pre><p>The next thing to do after setting up the virtual environment is to install the dependencies in the activated virtual environment. To do this you need to create a requirements.txt file, and add the following lines to it:</p><pre>streamlit<br>google-generativeai<br>python-dotenv</pre><p>These are the required dependencies to run the app, to add them, you need to run the following command:</p><pre>pip install -r requirements.txt</pre><p>That’s all for the python environment setup. Next is the database setup.</p><p>For the database, ensure you have MySql server installed and running on your machine, then you can create a database or use an existing database to build the application. For my case, I already have an existing database and that is what I will use in this project. You can get the database schema structure <a href="https://github.com/Oluwatodimu/gemini-sql-generator/blob/main/tables.sql">here</a>.</p><p>Once you have done this, you need to create a .env file and configure your database credentials so the application can have access to the database. You can do this by copying the following to your code, and updating them appropriately:</p><pre>DB_HOST=localhost<br>DB_USER=&lt;DB_USER_HERE&gt;<br>DB_PASSWORD=&lt;DB_PASSWORD_HERE&gt;<br>DB_NAME=&lt;DB_NAME_HERE&gt;</pre><h4>Integrating the Gemini API for natural language processing</h4><p>Congratulations for reading this far!!! At this stage, we will be integrating Gemini-Pro into our application with the help of their python SDK that we previously installed along with other dependencies in the requirements.txt file.</p><p>To integrate Gemini, we need to carry out the following steps:</p><ol><li>Get the Gemini API key and add the value to the .env file.</li><li>Configure Gemini using the Gemini python SDK and the API key.</li><li>Write a prompt that will give Gemini the instructions to generate SQL queries.</li><li>Create a function that will take in user inputs and return an SQL query.</li></ol><p>You can get the Gemini API key from <a href="https://aistudio.google.com/app/apikey">Google AI studio</a>. After successfully completing this, add it to the .env file. Your .env file should look like this at this stage:</p><pre>DB_HOST=localhost<br>DB_USER=&lt;DB_USER_HERE&gt;<br>DB_PASSWORD=&lt;DB_PASSWORD_HERE&gt;<br>DB_NAME=&lt;DB_NAME_HERE&gt;<br>GOOGLE_GEMINI_API_KEY=&lt;GEMINI_API_KEY_HERE&gt;</pre><p>To configure Gemini into our application, we first create an app.py file in the root directory (we will write the core logic here) and add the following code:</p><pre>from dotenv import load_dotenv<br>import os<br>import google.generativeai as genai<br><br>load_dotenv()  # load all the environment variables<br><br>genai.configure(api_key=os.getenv(&quot;GOOGLE_GEMINI_API_KEY&quot;))  # Configure Gemini api key</pre><p>In the code above, we load our API key from the .env file and configure Gemini in our application with the help of their SDK.</p><p>Creating the prompt is a crucial part of our app setup. Here, we tell Gemini what kind of SQL queries to make by outlining the tables and columns in our database. This helps Gemini generate queries that fit our app perfectly.</p><p>I have created a prompt below, tailored to the tables and columns in the database which you can see <a href="https://github.com/Oluwatodimu/gemini-sql-generator/blob/main/tables.sql">here</a>:</p><pre>prompt = [<br>    &quot;&quot;&quot;<br>    You are an expert in SQL queries!<br><br>    The SQL database contains the following tables:<br><br>    Table 1: user<br>    Columns: id (BINARY(16) NOT NULL UNIQUE), password_hash (VARCHAR(64)), first_name (VARCHAR(64)), last_name (VARCHAR(64)), email (VARCHAR(30) UNIQUE), phone_number (VARCHAR(15) UNIQUE), image_url (VARCHAR(256)), activated (BIT NOT NULL), user_type (VARCHAR(11) NOT NULL), created_by (VARCHAR(255)), creation_date (DATETIME), last_modified_by (VARCHAR(255)), last_modified_date (DATETIME)<br><br>    Table 2: authority<br>    Columns: id (BINARY(16) NOT NULL UNIQUE), authority_name (VARCHAR(64) NOT NULL), created_by (VARCHAR(255)), creation_date (DATETIME), last_modified_by (VARCHAR(255)), last_modified_date (DATETIME)<br><br>    Table 3: user_authority<br>    Columns: user_id (BINARY(16) NOT NULL), authority_id (BINARY(16) NOT NULL)<br><br>    Table 4: currency<br>    Columns: id (BINARY(16) NOT NULL UNIQUE), name (VARCHAR(64) NOT NULL), symbol (VARCHAR(30) NOT NULL UNIQUE), enabled (BIT NOT NULL), created_by (VARCHAR(255)), creation_date (DATETIME), last_modified_by (VARCHAR(255)), last_modified_date (DATETIME)<br><br>    Table 5: transactions<br>    Columns: id (BINARY(16) NOT NULL UNIQUE), amount (DECIMAL(64) NOT NULL), type (VARCHAR(15) NOT NULL), purpose (VARCHAR(35) NOT NULL), account_id (BINARY(16) NOT NULL), reference (BINARY(16) NOT NULL UNIQUE), status (VARCHAR(30) NOT NULL), description (VARCHAR(255)), sender_account (VARCHAR(20) NOT NULL), receiver_account (VARCHAR(20) NOT NULL), created_by (VARCHAR(255)), creation_date (DATETIME), last_modified_by (VARCHAR(255)), last_modified_date (DATETIME)<br><br>    Table 6: account<br>    Columns: id (BINARY(16) NOT NULL UNIQUE), available_balance (DECIMAL(64) NOT NULL), reserved_balance (VARCHAR(30) NOT NULL), locked (BIT NOT NULL), status (VARCHAR(20) NOT NULL), type (VARCHAR(20) NOT NULL), currency_id (BINARY(16) NOT NULL), user_id (BINARY(16) NOT NULL), account_number (VARCHAR(20) NOT NULL UNIQUE), created_by (VARCHAR(255)), creation_date (DATETIME), last_modified_by (VARCHAR(255)), last_modified_date (DATETIME)<br>    Please provide an English question related to these tables, and I&#39;ll help you generate the corresponding SQL query.<br>    also the sql code should not have ``` in beginning or end and sql word in output<br>    &quot;&quot;&quot;<br><br>]</pre><p><strong>Note</strong>: to avoid runtime errors we add the `s<em>ql code should not have ``` in beginning or end and sql word in output</em>` so that Gemini creates clean SQL queries that contain no illegal characters, hence making the queries run smoothly.</p><p>After all this is done, the next thing is to create a function that will take in a user’s text input and return SQL queries generated by Gemini. This is shown in the code below:</p><pre>def get_gemini_response(user_text, ai_prompt):<br><br>    &quot;&quot;&quot;<br>    :param user_text: user question from the frontend in the form of text<br>    :param ai_prompt: text we use to prompt Gemini<br>    :return: gemini SQL query<br>    &quot;&quot;&quot;<br><br>    model = genai.GenerativeModel(&#39;gemini-pro&#39;)<br>    ai_response = model.generate_content([ai_prompt[0], user_text])<br>    return ai_response.text</pre><h4>Implementing the SQL querying logic</h4><p>Anytime we query the database, we always get results that includes rows retrieved or affected. At this stage, we are going to write logic that connects to and queries the MySQL database then returns the results (rows). The database is queried using the SQL script generated by Gemini. This is done using the logic below:</p><pre>import mysql.connector<br><br>def read_sql_query(sql_query):<br><br>    &quot;&quot;&quot;<br>    :param sql_query: SQL query to query the db, generated by Gemini<br>    :return: queried data rows<br>    &quot;&quot;&quot;<br><br>    # connect to the db<br>    conn = mysql.connector.connect(<br>        host=os.getenv(&quot;DB_HOST&quot;),<br>        user=os.getenv(&quot;DB_USER&quot;),<br>        password=os.getenv(&quot;DB_PASSWORD&quot;),<br>        database=os.getenv(&quot;DB_NAME&quot;)<br>    )<br><br>    # execute SQL queries<br>    cur = conn.cursor()<br>    cur.execute(sql_query)<br>    rows = cur.fetchall()<br>    conn.commit()<br>    conn.close()<br><br>    # return query results<br>    return rows</pre><h4>Setting up the user interface</h4><p>Now that we have built the core logic of our application, the next thing on our list is to create a friendly user interface that people can use to write their texts. I have done this using <strong>streamlit, </strong>an open-source tool for creating simple UIs.</p><pre># Creating a streamlit app<br>st.set_page_config(page_title=&quot;Query Databases with Gemini Pro&quot;)<br>st.header(&quot;Gemini App To Retrieve Data With Normal Text&quot;)<br><br>question = st.text_input(&quot;Enter your text:&quot;, key=&quot;input&quot;, placeholder=&quot;Type your text here&quot;)<br><br>submit = st.button(&quot;Ask the question&quot;)<br><br># if submit is clicked<br>try:<br>    if submit:<br><br>        if question is None or question == &quot;&quot;:<br>            raise Exception(&quot;question cannot be null&quot;)<br><br>        print(&quot;user input: &quot; + question)<br>        response = get_gemini_response(question, prompt)<br><br>        print(&quot;gemini query: &quot; + response)<br>        response = read_sql_query(response)<br><br>        st.subheader(&quot;The Response is&quot;)<br>        for row in response:<br>            print(row)<br>            st.header(row)<br><br>except Exception as exception:<br>    print(exception)<br>    st.header(&quot;could not generate query from your input&quot;)</pre><p>The logic also includes the instructions to be executed when you enter text and click on the submit button. It ensures the user input is not null or empty, then it uses that input and the prompt we created earlier to generate a response which is an SQL query. This is then used to query the database which will return the results. This is what the UI looks like:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PkjLTrFkUs3lSw66g8EZEQ.png" /></figure><h4>Testing the application</h4><p>In this section, I will test the application and ensure it works correctly. To run the application, we use the following command:</p><pre>streamlit run app.py #app.py is the name of my file, it should be streamlit run &lt;file_name.py&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ahYkJ4n5t1DY45LQrmKqiQ.png" /></figure><p>The application is running perfectly, let us now ask our questions. I will ask questions, then show you the SQL queries under the hood.</p><p>Q1: how many users exist?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ANhVP7G5SqrW8SD0XbVJMg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/976/1*N63A6wJ6nzYseevpB3bWHg.png" /></figure><p>In the pictures above, we can see the text that the user passes into our application, and the result. We can also see the <strong><em>gemini query </em></strong>that was generated based on the text entered.</p><p>I will do this for 2 more complex examples and display the results.</p><p>Q2: What user has the most money in his accounts?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gYxgK3CTsFUQMBossQ77Mg.png" /></figure><p>what happens under the hood</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2eFVLw809rHZHDnM6wBrHA.png" /></figure><p>Q3: What is the most common account type:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f_vAbwB7x1jRNmBQA63v5g.png" /></figure><p>what happens under the hood</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SP-wQWtRiYkhTl9kXSRAAg.png" /></figure><p>That’s it! You have successfully created an application that queries a database using normal text. You can access the full code for this application <a href="https://github.com/Oluwatodimu/gemini-sql-generator">here</a>.</p><h4>Applications of this technology</h4><p>This technology simplifies accessing data from databases, especially for non-technical folks like managers. By allowing queries in everyday language, it speeds up the process and reduces the need for developers, helping teams make decisions faster.</p><h4>Conclusion</h4><p>Our application, built with Python, Streamlit, and the Gemini API, simplifies database querying for non-technical users. By automating SQL query generation from natural language input, we’ve made data exploration more accessible and intuitive. I urge you to explore the application and experience firsthand how it can streamline your database querying process. I also encourage you to try it with your own datasets.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e26c9828723" width="1" height="1" alt=""><hr><p><a href="https://medium.com/codex/conversational-sql-enabling-user-friendly-database-interactions-with-gemini-pro-2e26c9828723">Conversational SQL: Enabling User-friendly Database Interactions with Gemini-Pro</a> was originally published in <a href="https://medium.com/codex">CodeX</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a NUBAN Account Number Classifier with Spring Boot]]></title>
            <link>https://medium.com/stakefair/building-an-account-number-classifier-with-spring-boot-1ab56f4df333?source=rss-8a4d5bb159c6------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ab56f4df333</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[ussd-in-africa]]></category>
            <category><![CDATA[fintech]]></category>
            <dc:creator><![CDATA[Todimu Isewon]]></dc:creator>
            <pubDate>Sun, 18 Sep 2022 03:26:16 GMT</pubDate>
            <atom:updated>2022-09-21T18:41:00.793Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n6T2ZFnAA5lwixX3ddnBww.jpeg" /></figure><p><strong><em>Summary</em></strong></p><p>Have you ever wondered how when you use an application that involves you entering your account number, it gives a short list of banks that your account number could possibly belong to? It achieves this to a high level of accuracy, rather than returning a list of all the banks in operation.</p><p>In this article, we will discuss how this precise classification is achieved, and implement this in code using Java. We are also going to demonstrate the relevance of this classification in building USSD applications that are enabled to perform financial transactions.</p><h4><strong>Requirements</strong></h4><ol><li>A rudimentary understanding of Java language.</li><li>A text editor of choice.</li><li>Postman (to test endpoints from our classification algorithm).</li></ol><h4><strong>Introduction</strong></h4><p>In 2010, the Central Bank of Nigeria (CBN) released guidelines to achieve a uniform customer bank account numbering structure for all money deposit banks. This was also known as the Nigeria Uniform Bank Account Number(NUBAN) scheme. These deposit banks were given 9 months to implement this new classification strategy.</p><p>The aim of this scheme was to tackle financial problems relating to electronic payments, as a result of beneficiary bank accounts being wrongly misclassified.</p><p>In response to the directives of the CBN, the Cheques and ACH Working Group (CAWG) met and deliberated on these issues and recommended an approach to tackle the classification issue.</p><h4><strong>The NUBAN Algorithm</strong></h4><p>After the deliberations of the CAWG, the following steps were approved for developing the NUBAN algorithm:</p><p><strong><em>Step 1 — </em></strong>Approving the NUBAN format ABC-DEFGHIJKL-M, where ABC is the unique 3 digit bank code conferred on the bank by the CBN. A list of banks and their unique bank codes can be found <a href="https://sandbox.interswitchng.com/docbase/docs/autogate-file-transfer/appendix/bank-cbn-codes/">here</a>.</p><p>DEFGHIJKL is the NUBAN account serial number.</p><p>M is the check digit. The <em>check digit</em> is required for the account number validation and classification.</p><p><strong><em>Step 2 </em></strong>— Calculating the <em>check digit</em> using the following steps:</p><ol><li>Calculating the value of A*3+B*7+C*3+D*3+E*7+F*3+G*3+H*7+I*3+J*3+K*7+L*3.</li><li>Calculating modulo 10 of the value above, which is simply the remainder after dividing by 10.</li><li>Subtracting the result of the modulo from 10, in order to get the check digit value.</li><li>If the result is 10, then 0 is used as the check digit.</li></ol><p>In case you are interested in reading more about the NUBAN algorithm, you can check <a href="https://www.cbn.gov.ng/OUT/2011/CIRCULARS/BSPD/NUBAN%20PROPOSALS%20V%200%204-%2003%2009%202010.PDF">here</a> for more details and examples.</p><h4>Application of the NUBAN Algorithm</h4><p>We explained how the NUBAN algorithm works in the last section. How then does this algorithm help us? How do we use this algorithm to classify bank account numbers to a high degree of accuracy? These questions will be answered in this section.</p><p>As seen above in the NUBAN format, the NUBAN serial number (DEFGHIJKL) is 9 digits long which are then followed by by the check digit number M. That makes DEFGHIJKLM, which is 10 digits; the same number of digits in a bank account number.</p><p>If we split a bank account number into its serial number and check digit (last number in the account number), we can use the NUBAN algorithm on a combination of the serial number, with various banks and their unique bank codes. By doing this, we calculate a check digit which we compare to the already know last number of the bank account.</p><p>If both values match, then the account number could belong to the bank whose unique code was used in the computation.</p><p>The algorithm is shown in the diagram below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G8wpxbmQKxVHSZ8AZQZsyA.png" /></figure><p>From the diagram above, the account number is split into a 9 digit serial number and the 1 digit check digit. This is then passed into the NUBAN algorithm. For each bank object in the bank list, the NUBAN algorithm check digit is computed, after which it is compared to the check digit of the account number entered into the algorithm.</p><p>If these digits are the same, the bank is added to the list of possible banks.</p><h4>Putting the Algorithm to code</h4><p>First thing I did was to create a Bank class, containing the bank name and its unique CBN code, as shown below</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fbba8b00ecb1da8751fab10ce07fcd82/href">https://medium.com/media/fbba8b00ecb1da8751fab10ce07fcd82/href</a></iframe><p>After this was done, I created a method that would return the list of all banks in operation in Nigeria. This method accesses a JSON file that contains the bank data for all the banks. After it does this, it parses the contents of the JSON file into a Java list of BankDataDto objects.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3c7c9c6ee0992629aa9b7b80ca4b609a/href">https://medium.com/media/3c7c9c6ee0992629aa9b7b80ca4b609a/href</a></iframe><p>Next thing I did after this was to create a method that would return a list of possible banks that the account number belong to after making the necessary computations and checks, as shown below.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/15ff71c753e646c9d004668a58e584fb/href">https://medium.com/media/15ff71c753e646c9d004668a58e584fb/href</a></iframe><p>I also made provisions for testing with Postman, and also for third parties to be able to use this service by creating an endpoint.</p><p>The full code to the NUBAN algorithm implemented in Java can be accessed <a href="https://github.com/Oluwatodimu/AccountClassification">here</a>.</p><h4>Testing the NUBAN Algorithm</h4><p><strong><em>Step 1 — Run the Spring boot Application</em></strong></p><p>In order to test our code logic and confirm it works as expected, we first run the Spring boot application that houses the NUBAN algorithm. In order to do this, the first step is to clone the application source code from <a href="https://github.com/Oluwatodimu/AccountClassification">here</a>.</p><p><em>Ensure you have Java 11 installed.</em></p><p>After this is done, navigate to the root file containing the code and run the following code in the terminal</p><pre>./mvnw spring-boot:run</pre><p>The photo below shows the terminal output when the application runs successfully.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*knI9EXNNvAPaeaicgfCdUg.png" /></figure><p><strong><em>Step 2- Test the application with Postman</em></strong></p><p>When testing the application endpoint, the endpoint to be used is given below:</p><pre>GET {{base_url}}/api/v1/bank-list/{accountNumber}</pre><p>So if we wanted to see the bank list that 3093255991 belonged to, we would put the account number into the endpoint as follows:</p><pre>GET {{base_url}}/api/v1/bank-list/3093255991</pre><p>The result would be a an array of bank objects containing the name and bank codes, as shown below:</p><pre>{<br>  &quot;code&quot;: 200,<br>  &quot;message&quot;: &quot;Successful call&quot;,<br>  &quot;data&quot;: [<br>    {<br>      &quot;bankName&quot;: &quot;Access Bank&quot;,<br>      &quot;uniqueCbnBankCode&quot;: &quot;044&quot;<br>    },<br>    {<br>      &quot;bankName&quot;: &quot;EcoMobile&quot;,<br>      &quot;uniqueCbnBankCode&quot;: &quot;307&quot;<br>    },<br>    {<br>      &quot;bankName&quot;: &quot;Fidelity Mobile&quot;,<br>      &quot;uniqueCbnBankCode&quot;: &quot;318&quot;<br>    },<br>    {<br>      &quot;bankName&quot;: &quot;First Bank&quot;,<br>      &quot;uniqueCbnBankCode&quot;: &quot;011&quot;<br>    },<br>    {<br>      &quot;bankName&quot;: &quot;Omoluabi Mortgage Bank&quot;,<br>      &quot;uniqueCbnBankCode&quot;: &quot;990&quot;<br>    },<br>    {<br>      &quot;bankName&quot;: &quot;PayAttitude Online&quot;,<br>      &quot;uniqueCbnBankCode&quot;: &quot;329&quot;<br>    },<br>    {<br>      &quot;bankName&quot;: &quot;UBA&quot;,<br>      &quot;uniqueCbnBankCode&quot;: &quot;033&quot;<br>    }<br>  ]<br>}</pre><h4><strong>Applying this Application To USSD Applications</strong></h4><p>Just in case you are wondering what is USSD means, according to Wikipedia,</p><blockquote><em>Unstructured, Supplementary Service Data (USSD) sometimes referred to as “Quick Codes” or “Feature Codes” is a communications protocol used by GSM cellular telephones to communicate with the mobile network operator’s computers.</em></blockquote><p>The USSD can be used for a lot of services, including making financial transactions. Assuming you wanted to perform a financial transaction where you entered your account number, the algorithm we built above would narrow down the list of possible banks your account number could belong from almost 80 banks to 7 banks.</p><p>This might not seem significant, but it actually is, because the number of characters that can be displayed on a USSD application interface at a particular time is 160. The NUBAN algorithm addresses this problem efficiently.</p><p>An example of such is shown in the photos below. I incorporated the NUBAN algorithm in a USSD application I built recently.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SFAHJi01UerqbltQIHDpUA.png" /></figure><h4>Conclusion</h4><p>The aim of this article was to explain the NUBAN algorithm and give a real life application of it. I hope it was helpful and most importantly explanatory. Thank you for reading this far.</p><p>The code for the application can be found in my GitHub repository <a href="https://github.com/Oluwatodimu/AccountClassification">here</a>.</p><p>Thank you!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ab56f4df333" width="1" height="1" alt=""><hr><p><a href="https://medium.com/stakefair/building-an-account-number-classifier-with-spring-boot-1ab56f4df333">Building a NUBAN Account Number Classifier with Spring Boot</a> was originally published in <a href="https://medium.com/stakefair">Stakefair</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>