<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Coder Legion - Recent posts tagged buildiinpublic</title>
<link>https://coderlegion.com/tag/buildiinpublic</link>
<description>Powered by Question2Answer</description>
<item>
<title>Building the Realtime Foundation of the MyZubster Metaverse</title>
<link>https://coderlegion.com/26533/building-the-realtime-foundation-of-the-myzubster-metaverse</link>
<description>&lt;h2 id=&quot;building-the-realtime-foundation-of-the-myzubster-metaverse&quot;&gt;Building the Realtime Foundation of the MyZubster Metaverse&lt;/h2&gt;
&lt;p&gt;We are upgrading the MyZubster Metaverse from a REST-synchronized experience into an authenticated realtime multiplayer environment.&lt;/p&gt;
&lt;p&gt;Before continuing with the next development phase, here is a transparent update on what is already working and what we are implementing next.&lt;/p&gt;
&lt;h3 id=&quot;from-polling-to-realtime-communication&quot;&gt;From polling to realtime communication&lt;/h3&gt;
&lt;p&gt;The first version of the Metaverse uses REST endpoints to manage:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;player sessions;&lt;/li&gt;
&lt;li&gt;character movement;&lt;/li&gt;
&lt;li&gt;shared presence;&lt;/li&gt;
&lt;li&gt;chat messages;&lt;/li&gt;
&lt;li&gt;emotes;&lt;/li&gt;
&lt;li&gt;verified identities;&lt;/li&gt;
&lt;li&gt;world synchronization.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;This gave us a reliable starting point, but periodic polling is not the final architecture we want for a persistent shared world.&lt;/p&gt;
&lt;p&gt;We have now introduced a Socket.IO gateway mounted at:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;/realtime
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It supports WebSocket communication with HTTP polling available as a compatibility fallback.&lt;/p&gt;
&lt;h3 id=&quot;the-preview-runtime-is-online&quot;&gt;The preview runtime is online&lt;/h3&gt;
&lt;p&gt;The realtime infrastructure has been deployed to an isolated Vercel preview environment.&lt;/p&gt;
&lt;p&gt;We verified it using the public health endpoint:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;GET /api/realtime/health
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The current response is:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-json&quot;&gt;{
  &quot;success&quot;: true,
  &quot;status&quot;: &quot;ok&quot;,
  &quot;transport&quot;: &quot;socket.io&quot;,
  &quot;socketPath&quot;: &quot;/realtime&quot;,
  &quot;presence&quot;: &quot;local-fallback&quot;,
  &quot;privacy&quot;: &quot;aggregate-only&quot;
}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This confirms that the application is running, Socket.IO is attached correctly, the preview database is reachable, and observability is configured to avoid exposing private user data.&lt;/p&gt;
&lt;h3 id=&quot;secure-realtime-authentication&quot;&gt;Secure realtime authentication&lt;/h3&gt;
&lt;p&gt;Clients cannot connect anonymously to protected realtime features.&lt;/p&gt;
&lt;p&gt;An authenticated user first requests a short-lived token from:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;POST /api/realtime/token
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The server creates a dedicated JWT containing only the information required by the realtime gateway.&lt;/p&gt;
&lt;p&gt;The gateway verifies:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;signature and expiration;&lt;/li&gt;
&lt;li&gt;issuer and audience;&lt;/li&gt;
&lt;li&gt;realtime-specific purpose;&lt;/li&gt;
&lt;li&gt;user identity;&lt;/li&gt;
&lt;li&gt;user role.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Authentication alone does not grant access to every channel. Each subscription is authorized independently by the server.&lt;/p&gt;
&lt;p&gt;Every user also receives a private channel:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;user:&amp;lt;userId&amp;gt;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This provides a controlled foundation for private notifications and direct message delivery.&lt;/p&gt;
&lt;h3 id=&quot;presence-messaging-and-reconnects&quot;&gt;Presence, messaging, and reconnects&lt;/h3&gt;
&lt;p&gt;The new gateway already supports the core operations required by a multiplayer environment:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;presence.join
presence.heartbeat
presence.leave
channel.subscribe
channel.unsubscribe
chat.send
realtime.resume
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When a client reconnects, it can request restoration of its previous subscriptions. The server verifies every channel again before restoring access.&lt;/p&gt;
&lt;p&gt;Messages are validated, persisted, deduplicated, and delivered only to authorized recipients.&lt;/p&gt;
&lt;p&gt;We also added backpressure controls so the service can reject excess work safely during temporary overload.&lt;/p&gt;
&lt;h3 id=&quot;preview-database-isolation&quot;&gt;Preview database isolation&lt;/h3&gt;
&lt;p&gt;The preview deployment does not reuse unrestricted production credentials.&lt;/p&gt;
&lt;p&gt;We created:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;a dedicated MongoDB preview user;&lt;/li&gt;
&lt;li&gt;a custom least-privilege role;&lt;/li&gt;
&lt;li&gt;access limited to the preview database;&lt;/li&gt;
&lt;li&gt;cluster-level restrictions;&lt;/li&gt;
&lt;li&gt;encrypted Vercel environment variables;&lt;/li&gt;
&lt;li&gt;branch-specific configuration.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;The MongoDB URI and realtime signing secret are never committed to GitHub or exposed to frontend code.&lt;/p&gt;
&lt;h3 id=&quot;privacy-aware-observability&quot;&gt;Privacy-aware observability&lt;/h3&gt;
&lt;p&gt;Realtime systems need monitoring, but operational visibility should not become user surveillance.&lt;/p&gt;
&lt;p&gt;Our observability layer collects aggregate technical information such as:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;connection attempts;&lt;/li&gt;
&lt;li&gt;successful and rejected connections;&lt;/li&gt;
&lt;li&gt;active connections;&lt;/li&gt;
&lt;li&gt;disconnects;&lt;/li&gt;
&lt;li&gt;message failures;&lt;/li&gt;
&lt;li&gt;duplicate messages;&lt;/li&gt;
&lt;li&gt;resume operations;&lt;/li&gt;
&lt;li&gt;processing duration;&lt;/li&gt;
&lt;li&gt;Redis failures.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Private conversations and raw personal identifiers are not included in public metrics.&lt;/p&gt;
&lt;p&gt;The detailed metrics endpoint is restricted to authenticated administrators.&lt;/p&gt;
&lt;h3 id=&quot;why-presence-is-still-using-a-fallback&quot;&gt;Why presence is still using a fallback&lt;/h3&gt;
&lt;p&gt;The health response currently reports:&lt;/p&gt;
&lt;pre&gt;&lt;code class=&quot;language-text&quot;&gt;presence: local-fallback
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This means presence works inside the active application instance, but it is not yet coordinated across multiple Vercel instances.&lt;/p&gt;
&lt;p&gt;It is an important distinction: the realtime runtime is operational, but distributed presence is still the next step.&lt;/p&gt;
&lt;p&gt;Redis will provide:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;shared presence state;&lt;/li&gt;
&lt;li&gt;cross-instance Socket.IO delivery;&lt;/li&gt;
&lt;li&gt;instance coordination;&lt;/li&gt;
&lt;li&gt;presence expiration;&lt;/li&gt;
&lt;li&gt;better horizontal scaling.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;what-we-are-working-on-next&quot;&gt;What we are working on next&lt;/h3&gt;
&lt;p&gt;Our next development phase is focused on:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;connecting the Metaverse frontend to Socket.IO;&lt;/li&gt;
&lt;li&gt;keeping REST synchronization as a temporary fallback;&lt;/li&gt;
&lt;li&gt;introducing the Socket.IO Redis adapter;&lt;/li&gt;
&lt;li&gt;configuring an isolated preview Redis instance;&lt;/li&gt;
&lt;li&gt;testing multiple simultaneous clients;&lt;/li&gt;
&lt;li&gt;verifying disconnect and resume behavior;&lt;/li&gt;
&lt;li&gt;validating privacy-safe metrics;&lt;/li&gt;
&lt;li&gt;completing the production review and merge.&lt;/li&gt;
&lt;/ol&gt;
&lt;h3 id=&quot;current-project-status&quot;&gt;Current project status&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;Realtime server: &lt;strong&gt;implemented&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Vercel preview: &lt;strong&gt;online&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;MongoDB connection: &lt;strong&gt;verified&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Health endpoint: &lt;strong&gt;verified&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Socket authentication: &lt;strong&gt;implemented&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Channel authorization: &lt;strong&gt;implemented&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Presence lifecycle: &lt;strong&gt;implemented&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Reconnect support: &lt;strong&gt;implemented&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Aggregate observability: &lt;strong&gt;implemented&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Frontend Socket.IO connection: &lt;strong&gt;in progress&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Distributed Redis coordination: &lt;strong&gt;next&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;Production release: &lt;strong&gt;pending validation&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id=&quot;building-a-world-not-just-a-page&quot;&gt;Building a world, not just a page&lt;/h3&gt;
&lt;p&gt;The MyZubster Metaverse is intended to become a shared digital space connected to identities, creators, projects, collaboration, and community experiences.&lt;/p&gt;
&lt;p&gt;Making that possible requires more than adding a WebSocket. It requires strong security boundaries, failure handling, database isolation, reconnect logic, privacy-aware monitoring, and distributed state management.&lt;/p&gt;
&lt;p&gt;The server-side foundation is now online.&lt;/p&gt;
&lt;p&gt;The next step is connecting the world to it.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;MyZubster: &lt;a rel=&quot;nofollow&quot; href=&quot;https://www.myzubster.com&quot;&gt;https://www.myzubster.com&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;GitHub: &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/MyZubster-Ecosystem&quot;&gt;https://github.com/MyZubster-Ecosystem&lt;/a&gt;&lt;/p&gt;
</description>
<category>Articles</category>
<guid isPermaLink="true">https://coderlegion.com/26533/building-the-realtime-foundation-of-the-myzubster-metaverse</guid>
<pubDate>Wed, 09 Sep 2026 00:12:26 +0000</pubDate>
</item>
</channel>
</rss>