<?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: Anik Sutradhar</title>
    <description>The latest articles on DEV Community by Anik Sutradhar (@anik_sutradhar_2c84f4b969).</description>
    <link>https://dev.to/anik_sutradhar_2c84f4b969</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%2F3446615%2F16981b42-b1c5-47eb-a4b9-61ad9005d619.png</url>
      <title>DEV Community: Anik Sutradhar</title>
      <link>https://dev.to/anik_sutradhar_2c84f4b969</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/anik_sutradhar_2c84f4b969"/>
    <language>en</language>
    <item>
      <title>FastAPI multiuser chat server #1</title>
      <dc:creator>Anik Sutradhar</dc:creator>
      <pubDate>Thu, 09 Jul 2026 12:45:59 +0000</pubDate>
      <link>https://dev.to/anik_sutradhar_2c84f4b969/fastapi-multiuser-chat-server-1-4ok1</link>
      <guid>https://dev.to/anik_sutradhar_2c84f4b969/fastapi-multiuser-chat-server-1-4ok1</guid>
      <description>&lt;p&gt;In this first post of our WebChat architecture series, we dive deep into the multi-service system design behind a real-time messaging application built with FastAPI, Next.js, Redis, PostgreSQL, and Nginx.&lt;br&gt;
livelink : &lt;a href="https://webchat.aniksutradhar.com/register" rel="noopener noreferrer"&gt;https://webchat.aniksutradhar.com/register&lt;/a&gt;&lt;br&gt;
Lets first start with the architecture:&lt;br&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxns21m50ckcsf9e9qn1v.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fxns21m50ckcsf9e9qn1v.png" alt=" " width="704" height="816"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Next.js Client (The Frontend UI)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Serves the user interface and coordinates client-side real-time socket actions.&lt;/li&gt;
&lt;li&gt;Initiates registration and login requests.&lt;/li&gt;
&lt;li&gt;Maintains a single, persistent Web-Socket connection to the Chat Server.&lt;/li&gt;
&lt;li&gt;Secures payload transmissions (and stores state inside Next.js Contexts).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;FastAPI Auth Server (Service #1)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A lightweight, stateless microservice dedicated solely to credentials, users, and tokens.&lt;/li&gt;
&lt;li&gt;User Registration: Receives email and password, derives a unique username, salts and hashes the password via bcrypt, and writes the record to PostgreSQL.&lt;/li&gt;
&lt;li&gt;User Login: Verifies credentials and issues a signed, cryptographically secure JWT (JSON Web Token) with an expiration.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;FastAPI Chat Server &amp;amp; WebSocket Manager (Service #2)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The stateful service maintains concurrent WebSocket connections and saves message logs.&lt;/li&gt;
&lt;li&gt;Persistent WebSockets: Maintains open connections at /ws?token=....&lt;/li&gt;
&lt;li&gt;Message Broker Integration: Interacts with Redis to keep track of user statuses.&lt;/li&gt;
&lt;li&gt;Database Writes: Writes chats, participants, and messaging logs to PostgreSQL using asynchronous sessions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;PostgreSQL (Storage Layer)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The relational database management system.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Stores core tables: users (shared schema), chats, chat_participants, messages.&lt;/li&gt;
&lt;li&gt;Uses async drivers (asyncpg) to ensure FastAPI never blocks on database writes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Redis (Caching &amp;amp; Presence Layer)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In-memory data structure store.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tracks transient status updates (e.g., whether a user is online, idle, or offline).&lt;/li&gt;
&lt;li&gt;Stores short-lived typing states (e.g. typing:chat_id:user_id) with automatic Time-To-Live (TTL) expiration.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>backenddevelopment</category>
      <category>programming</category>
      <category>fastapi</category>
      <category>python</category>
    </item>
    <item>
      <title>Create you own server at home for free ...</title>
      <dc:creator>Anik Sutradhar</dc:creator>
      <pubDate>Thu, 30 Apr 2026 12:28:57 +0000</pubDate>
      <link>https://dev.to/anik_sutradhar_2c84f4b969/create-you-own-server-at-home-for-free--34l9</link>
      <guid>https://dev.to/anik_sutradhar_2c84f4b969/create-you-own-server-at-home-for-free--34l9</guid>
      <description>&lt;p&gt;You know it's always handy to have your own home server; you can do all kinds of things with it. Like hosting your personal websites, running cron jobs, automation services, and if you have a beast PC, also hosting AI models and running AI services.&lt;br&gt;
This is a step-by-step guide to set up your Ubuntu home server and make it available over the internet.&lt;/p&gt;

&lt;p&gt;Before anything, you need a fresh installation of Ubuntu server&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: go through the basics :
&lt;/h3&gt;

&lt;p&gt;Update your system&lt;br&gt;
&lt;code&gt;sudo apt update &amp;amp;&amp;amp; sudo apt upgrade -y&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Install essential tools:&lt;br&gt;
&lt;code&gt;sudo apt install curl cron sed -y&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Identify your Global IPv6
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Find your address:&lt;br&gt;
&lt;code&gt;ip -6 addr&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Look for the "Global" address. It usually starts with inet6 2405:201:...&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 3: DuckDNS Automation
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Create the directory : &lt;code&gt;mkdir ~/duckdns &amp;amp;&amp;amp; cd ~/duckdns&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Create the script: &lt;code&gt;nano duck.sh&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Paste this(Replace with your info):&lt;br&gt;
&lt;code&gt;echo url="https://www.duckdns.org/update?domains=YOUR_DOMAIN&amp;amp;token=YOUR_TOKEN&amp;amp;ipv6=$(ip -6 addr show dev eth0 | grep 'scope global' | grep -v 'temporary' | awk '{print $2}' | cut -d'/' -f1)" | curl -k -o ~/duckdns/duck.log -K -&lt;/code&gt;&lt;br&gt;
[You need to go to this DuckDNS website, create a domain you like, and the token they will provide]&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Set Permissions: &lt;br&gt;
&lt;code&gt;chmod 700 duck.sh&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Schedule it(Cron):&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Run &lt;code&gt;crontab -e&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Add this to the bottom: &lt;code&gt;*/5 * * * * ~/duckdns/duck.sh &amp;gt;/dev/null 2&amp;gt;&amp;amp;1&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 4: Configure your Router(configure your ISP settings)
&lt;/h3&gt;

&lt;p&gt;Your router blocks all incoming traffic by default. You must create a "Pinhole."&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Go to your router admin panel, for example, &lt;code&gt;192.168.29.1&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Service Setup: Go to Security &amp;gt; Firewall &amp;gt; Custom Services. Add a service for Port 80 and Port 443 (TCP).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Firewall Rule: Go to IPv6 Firewall Rules.&lt;br&gt;
Inbound Rule: Allow traffic to your Global IPv6 (from Step 2) using the services you just created.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 5: Web Server &amp;amp; SSL:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Install Apache: &lt;code&gt;sudo apt install apache2 -y&lt;/code&gt; &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install Certbot: &lt;code&gt;sudo apt install python3-certbot-apache -y&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Get Certificate:&lt;code&gt;sudo certbot --apache -d yourdomain.duckdns.org&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 6: Firewall settings
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;UFW firewall:&lt;br&gt;
&lt;code&gt;sudo ufw allow 80/tcp&lt;br&gt;
sudo ufw allow 443/tcp&lt;br&gt;
sudo ufw allow 22/tcp&lt;br&gt;
sudo ufw enable&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can also set up private SSH keys to access remotely (without passwords)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Fail2Ban: Install to block brute-force attacks: &lt;code&gt;sudo apt install fail2ban -y&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 7: Tailscale:
&lt;/h3&gt;

&lt;p&gt;Tailscale is a private VPN. You should use it alongside DuckDNS, not instead of it.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;With Tailscale: You can access your server's terminal or files from anywhere in the world (even if DuckDNS or your  Router's public port fails) without opening ports.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Install: &lt;code&gt;curl -fsSL https://tailscale.com/install.sh | sh&lt;br&gt;
sudo tailscale up&lt;/code&gt;&lt;br&gt;
[If you mess up a firewall rule and lock yourself out of the public IP, Tailscale provides a private "backdoor" to get back in and fix it.]&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Final check:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;test DNS: &lt;code&gt;nslookup yourdomain.duckdns.org (Should show your IPv6)&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Web access: Visit &lt;a href="https://dev.toShould%20show%20Apache%20page%20with%20Lock%20icon"&gt;yourdomain.duckdns.org&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;VPN: Turn off Wi-Fi on your phone, turn on Tailscale, and try to SSH into the Tailscale IP.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you want to host any application, you need to open those ports.&lt;/p&gt;

</description>
      <category>ubuntu</category>
      <category>homeserver</category>
      <category>networking</category>
      <category>duckdns</category>
    </item>
  </channel>
</rss>
