<?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 Vincent Chevalier on Medium]]></title>
        <description><![CDATA[Stories by Vincent Chevalier on Medium]]></description>
        <link>https://medium.com/@chev0100?source=rss-0a4bdd518348------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*pN8gCEetDGfgx6HOtjE43Q.jpeg</url>
            <title>Stories by Vincent Chevalier on Medium</title>
            <link>https://medium.com/@chev0100?source=rss-0a4bdd518348------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 16:56:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@chev0100/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[Demoing a Session-Based Communication App For Redis Pub/Sub and Node.js]]></title>
            <link>https://medium.com/@chev0100/demoing-a-session-based-communication-app-for-redis-pub-sub-and-node-js-78a3993beb87?source=rss-0a4bdd518348------2</link>
            <guid isPermaLink="false">https://medium.com/p/78a3993beb87</guid>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[postman]]></category>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[pub-sub]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[Vincent Chevalier]]></dc:creator>
            <pubDate>Wed, 19 Feb 2025 00:38:02 GMT</pubDate>
            <atom:updated>2025-02-19T00:50:21.005Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Final article of a three-part series exploring scalable session-based app development with Redis and Node.js. Read </em><a href="https://medium.com/@chev0100/build-a-scalable-session-based-communication-app-using-redis-pub-sub-and-node-js-d09f9dc0b16b"><strong><em>Part One</em></strong></a><em> and </em><a href="https://medium.com/@chev0100/real-time-management-with-redis-pub-sub-part-two-acc494adc48f"><strong><em>Part Two</em></strong></a><em> to catch up.</em></p><p>In the previous two articles, we built a scalable, session-based communication app using <strong>Redis</strong>, <strong>Node.js</strong>, and <strong>Express</strong>. Now, it’s time to bring everything to life with a demo, showcasing how our app enables real-time messaging across distributed server instances.</p><h3><strong>Recap: What We Built</strong></h3><h4>Session Management with Express and Redis Sets</h4><p>In <a href="https://medium.com/@chev0100/build-a-scalable-session-based-communication-app-using-redis-pub-sub-and-node-js-d09f9dc0b16b"><strong>Part One</strong></a>, we used Redis Sets to create and track sessions, ensuring unique and consistent data for two users. We implemented endpoints for creating, joining, and closing sessions while leveraging Redis to manage session state efficiently.</p><h4>Real-Time Messaging with Redis Pub/Sub</h4><p>To enable real-time communication, we built a message endpoint that publishes messages to session members instantly. Using Redis Pub/Sub, we demonstrated how the publish and subscribe functions broadcast messages across all connected users in a session.</p><h4>Lightweight and Modular Design</h4><p>From the start, we aimed for a lightweight and modular design. By separating concerns into services for cache management, Pub/Sub, and session handling, we kept controllers focused and streamlined. Middleware and services handled the heavy lifting, making the app easier to maintain and extend.</p><h3><strong>Bringing It All Together</strong></h3><figure><img alt="Screenshot of terminal window showing the load up of the redis pubsub server app." src="https://cdn-images-1.medium.com/max/1017/1*8Jvi79TxssH4Ooz-YLvrng.png" /><figcaption><em>Starting the app on port 3000 and checking to see that all the Redis clients connect properly.</em></figcaption></figure><p>As discussed in <a href="https://medium.com/@chev0100/real-time-management-with-redis-pub-sub-part-two-acc494adc48f"><strong>Part Two</strong></a>, we run our app locally on two servers to simulate a distributed environment where multiple clients interact with the same Redis instance. Each server connects to Redis with its own publisher and subscriber clients, ensuring proper message handling.</p><pre># Start the first server on port 3000<br>APP_PORT=3000 npm start<br><br># Start the second server on port 4000<br>APP_PORT=4000 npm start</pre><p>With our app running, let’s walk through the user flow.</p><h4><strong>Step 1: Creating a Session</strong></h4><p>A user initiates a session by sending a POST request to /session with their userId.</p><figure><img alt="Screenshot from Postman showing a successful request and response along the create session route." src="https://cdn-images-1.medium.com/max/1024/1*Pj0Mcxo3n7emAj8V1PAo5g.png" /><figcaption>A successful request and response along the create session route showing the generated code.</figcaption></figure><p>The server generates a unique 4-digit session code (e.g., 1474) and assigns the user to the session. This simple 4-digit code makes it easy to share and input, but for a production system, we’d likely replace it with a cryptographically secure identifier.</p><h4><strong>Step 2: A Second User Joins the Session</strong></h4><p>The second user joins by sending a POST request to /session/join, providing their userId and the session code 1474.</p><figure><img alt="Screenshot from Postman showing a successful request and response along the join session route for a second user." src="https://cdn-images-1.medium.com/max/1024/1*Mx4GgESVbBK6nTtQ87LyZA.png" /><figcaption>A second user sends a successful request to the join session route and gets a success flag and message stating they joined the session in response.</figcaption></figure><p>To maintain consistency across all requests, we use middleware that processes session-related data before it reaches the handlers. Each endpoint other than create at /session passes through a middleware with a generateKeys function that prepends the code with a session: key. This key is stored in Redis as a set, with its value being each user, similarly prepended with user:.</p><pre>export const generateKeys = (code, userId) =&gt; {<br> if (!code || !userId) {<br>  throw new Error(&#39;Missing userId or code.&#39;);<br> }<br><br> const sessionKey = &#39;session:&#39; + code;<br> const userKey = &#39;user:&#39; + userId;<br><br> return {<br>  sessionKey,<br>  userKey,<br> };<br>};</pre><p>At this point, both users are subscribed to the same Redis Pub/Sub channel (session:1474), allowing them to receive real-time messages.</p><figure><img alt="Illustration of the Pub/Sub flow." src="https://cdn-images-1.medium.com/max/960/1*-pcNbnFXacr6Wcf313Flwg.png" /><figcaption>Illustration of the Pub/Sub workflow: A publisher sends messages to a Redis channel, which are then received by all active subscribers in real time.</figcaption></figure><h4><strong>Step 3: Sending a Message</strong></h4><p>Once connected, either user can send a message using the /session/message endpoint.</p><figure><img alt="Screenshot from Postman showing the user on port 3000 sends a message along with the second code." src="https://cdn-images-1.medium.com/max/1024/1*-vOQyB_Ygm97KoUgST0ltQ.png" /><figcaption>User on port 3000 sends a message along with the second code.</figcaption></figure><p>The message is published to Redis on the channel session:1474 based on the code provided in the request body. Redis notifies all subscribed users in real time.</p><h4><strong>Step 4: Viewing Messages in the Terminal</strong></h4><p>The subscriber listens for messages, parsing the payload and displaying it in the terminal.</p><figure><img alt="Screenshot of terminal window showing that user karmapol50 has sent a successful message request." src="https://cdn-images-1.medium.com/max/973/1*wDhTv-6wUIi2XEhf7CC1jw.png" /><figcaption>User karmapol50 sends a message to /session/message successfully on port 3000.</figcaption></figure><p>We see that the user on port 3000 (karmapol50) sent the message successfully and both servers receive it simultaneously:</p><figure><img alt="Screenshot of terminal window showing user wonderwall50 receives the published message immediately." src="https://cdn-images-1.medium.com/max/1013/1*pCy-3RkPlcaZ69SfCLHmcg.png" /><figcaption>User wonderwall96 receives the published message immediately.</figcaption></figure><p>This format is just for demo purposes and could be structured as a proper response, but in this case we are just logging a message to the console.</p><pre>//port 3000<br>User karmapol50 received message: &quot;everything in its right place&quot;<br><br>// port 4000<br>User wonderwall96 received message: &quot;everything in its right place&quot;</pre><p>The key takeaway here is how Redis Pub/Sub uses a <strong>callback function</strong> in the subscribe method to pass along messages in real-time. Messages are <strong>JSON objects</strong> when published, then parsed upon reception:</p><pre>subscriber.subscribe(sessionId, (message) =&gt; {<br>   console.log(`User ${userId} received message: ${message}`);<br>  });<br><br>publisher.publish(sessionId, JSON.stringify(message));</pre><h4>Step 5: Leaving the Session</h4><p>Users can leave by sending a POST request to /session/leave.</p><pre>{<br>  &quot;userId&quot;: &quot;wonderwall96&quot;,<br>  &quot;code&quot;: &quot;1474&quot;<br>}</pre><p>The session service publishes a message to inform all remaining users.</p><pre>{<br>    &quot;success&quot;: true,<br>    &quot;message&quot;: &quot;wonderwall96 left session 1474&quot;<br>}</pre><p>Once all users leave, the session is deleted from Redis.</p><h3><strong>Conclusion: Scaling Beyond the Basics</strong></h3><p>This demo showcases Redis Pub/Sub in action, but there’s room for improvement. Some enhancements to consider:</p><h4>Integrating WebSockets for a Fully Event-Driven Experience</h4><ul><li><strong>Keep REST endpoints</strong> for session management (create, join, leave).</li><li><strong>Use WebSockets</strong> to handle messaging in real-time without constant API polling.</li><li>Allows for <strong>true bidirectional communication</strong>.</li></ul><h4><strong>Real-Time AppFeatures to Where This Could Be Applied</strong></h4><ul><li><strong>Notifications</strong>: Let users know when a new message arrives without polling.</li><li><strong>Chat UI</strong>: Build an interface around WebSockets to visualize conversations.</li><li><strong>Swipe-to-Match</strong>: Adaptable for interactive applications like Tinder.</li></ul><h4><strong>Data Persistence: When &amp; Why?</strong></h4><p>By default, sessions in our demo are <strong>ephemeral</strong> (temporary and stored only in memory). This approach is:</p><p>✔ <strong>Lightweight</strong>: No need for heavy database queries. ✔ <strong>Scalable</strong>: Sessions automatically expire when inactive. ✔ <strong>Simple</strong>: Reduces infrastructure complexity.</p><p><strong>However, persistence becomes essential when:</strong></p><ul><li><strong>Tracking User History</strong>: Saving past conversations or interactions.</li><li><strong>Storing Engagement Data</strong>: Keeping logs of session activities for analytics.</li><li><strong>Session Recovery</strong>: Allowing users to resume conversations after disconnecting.</li></ul><p><strong>For persistence, we could:</strong></p><ul><li>Store session metadata in <strong>MongoDB/PostgreSQL</strong>.</li><li>Log messages in a time-series database like <strong>Redis Streams</strong>.</li><li>Implement <strong>message queues (RabbitMQ, Kafka)</strong> for reliability.</li></ul><h3>Final Thoughts</h3><p>The full source code is available on <a href="https://github.com/vincentpchevalier/redis-session-pubsub">my GitHub repo</a>. The completed project includes error handling, installation instructions, and a README to help you get started.</p><p>This Redis Pub/Sub project is just the beginning! By extending it with WebSockets and persistence layers, you can build <strong>scalable</strong>, <strong>real-time</strong> applications tailored to your needs.</p><p>Got questions or ideas for improvement? Message me and let’s discuss.</p><p>Until next time!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78a3993beb87" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Real-Time Messaging Between Users with Redis Pub/Sub]]></title>
            <link>https://medium.com/@chev0100/real-time-management-with-redis-pub-sub-part-two-acc494adc48f?source=rss-0a4bdd518348------2</link>
            <guid isPermaLink="false">https://medium.com/p/acc494adc48f</guid>
            <category><![CDATA[pub-sub]]></category>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[backend-development]]></category>
            <dc:creator><![CDATA[Vincent Chevalier]]></dc:creator>
            <pubDate>Thu, 13 Feb 2025 18:13:38 GMT</pubDate>
            <atom:updated>2025-02-19T00:49:45.800Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Redis logo." src="https://cdn-images-1.medium.com/max/1024/1*D4BGM0cjmzPOQX54J2KdUA.jpeg" /><figcaption>Redis provides the backbone of our real-time Pub/Sub messaging system.</figcaption></figure><p><em>This is Part Two of </em><a href="https://medium.com/@chev0100/build-a-scalable-session-based-communication-app-using-redis-pub-sub-and-node-js-d09f9dc0b16b"><strong><em>Build a Scalable Session-Based Communication App Using Redis Pub/Sub and Node.js</em></strong></a>, <em>a three-part series delving into scalable session-based app development using Redis and Node.js. Read </em><a href="https://medium.com/@chev0100/build-a-scalable-session-based-communication-app-using-redis-pub-sub-and-node-js-d09f9dc0b16b"><strong><em>Part One</em></strong></a><strong><em> </em></strong><em>and </em><a href="https://medium.com/@chev0100/demoing-a-session-based-communication-app-for-redis-pub-sub-and-node-js-78a3993beb87"><strong><em>Part Three</em></strong></a><strong><em>.</em></strong></p><p>In <a href="https://medium.com/@chev0100/build-a-scalable-session-based-communication-app-using-redis-pub-sub-and-node-js-d09f9dc0b16b"><strong>Part One</strong>,</a> we built the foundation for a scalable session-based app using <strong>Redis Sets</strong> to manage sessions and track users. Now, it’s time to bring the app to life with <strong>real-time messaging</strong>. With session management in place, the next step is to implement the <a href="https://redis.io/docs/latest/develop/interact/pubsub/"><strong>Pub/Sub messaging service</strong></a>, enabling users in a session to exchange messages instantly. For <strong>Part Two</strong>, we’ll explore how to set up this messaging service and integrate it with the session management system. Let’s dive in!</p><h4>The Importance of Unique Keys</h4><p>Previously, we created a set of unique keys to help manage sessions and access <strong>Pub/Sub channels</strong>. To ensure seamless communication, maintaining consistent and unique session/user keys (session:&lt;code&gt; and user:&lt;userId&gt;) is crucial. These keys make it easy to <strong>subscribe</strong>, <strong>publish</strong>, and <strong>unsubscribe</strong> from Redis channels, both in the application and when debugging in the <a href="https://redis.io/docs/latest/develop/tools/cli/"><strong>Redis CLI</strong></a>.</p><h3>Building the Pub/Sub Messaging Service</h3><h4>Setting Up Redis Pub/Sub Clients</h4><p>Just like when we created our cache client for storing our session and user management sets, Redis requires separate clients for publishing and subscribing to messages. Here’s how we initialize them:</p><pre>// services/redis.service.js<br>import redis from &#39;redis&#39;;<br><br>let pubClient;<br>let subClient;<br><br>export const initializeRedis = async () =&gt; {<br> console.log(&#39;Connecting to Redis...&#39;);<br> try {<br>  const url = process.env.REDIS_URL;<br><br>  // Cache client: same code as earlier<br><br>  // Publisher client<br>  pubClient = redis.createClient({ url });<br>  await pubClient.connect();<br>  console.log(&#39;Publisher client connected.&#39;);<br><br>  // Subscriber client<br>  subClient = redis.createClient({ url });<br>  await subClient.connect();<br>  console.log(&#39;Subscriber client connected.&#39;);<br> } catch (error) {<br>  console.error(&#39;Redis initialization error:&#39;, error);<br>  throw new Error(&#39;Unable to connect to Redis.&#39;);<br> }<br>};<br><br>export { pubClient, subClient };</pre><p><strong>Why Separate Clients?<br></strong>Using separate clients for publishing and subscribing ensures that messages are handled efficiently. This setup also mirrors real-world applications, where publishers and subscribers often operate independently.</p><p><strong>NB: Running Multiple Server Instances<br></strong>For local development, it’s optimal to run two server instances (e.g., on ports 3000 and 4000). This simulates a distributed environment where multiple clients interact with the same Redis server. Each server instance connects to Redis using its own publisher and subscriber clients, ensuring proper message handling.</p><pre># Start the first server on port 3000<br>APP_PORT=3000 npm start<br><br># Start the second server on port 4000<br>APP_PORT=4000 npm start</pre><h4>Pub/Sub Manager Functions</h4><figure><img alt="Illustration of the Pub/Sub workflow." src="https://cdn-images-1.medium.com/max/960/1*-pcNbnFXacr6Wcf313Flwg.png" /><figcaption>Illustration of the Pub/Sub workflow: A publisher sends messages to a Redis channel, which are then received by all active subscribers in real time.</figcaption></figure><p>The <a href="https://redis.io/docs/latest/develop/interact/pubsub/"><strong>Pub/Sub (Publish/Subscribe)</strong></a> pattern is a messaging system that enables real-time communication between a publisher and multiple subscribers without requiring them to interact directly. In our application, the Pub/Sub service uses Redis to create session-specific channels where messages can be broadcast. Subscribers (e.g., users connected to a session) listen to a designated channel and receive updates as soon as a message is published. This setup allows for efficient, event-driven communication, such as broadcasting real-time updates or notifications to all users within a session. The service provides core methods for subscribing users to channels, publishing messages, and unsubscribing users when they leave, as shown in the functions of our pubsub.service.js:</p><p><strong>Subscribe to a Session Channel<br></strong>Subscribes a user to a session’s Pub/Sub channel to receive messages.</p><pre>export const subscribe = async (userId, sessionId) =&gt; {<br> await subClient.subscribe(sessionId, (message) =&gt; {<br>  console.log(`User ${userId} received message: ${message}`);<br> });<br>};</pre><p><strong>Publish a Message<br></strong>Publishes a message to all users subscribed to a session’s channel.</p><pre>export const publish = async (sessionId, message) =&gt; {<br> await pubClient.publish(sessionId, JSON.stringify(message));<br>};</pre><p><strong>Unsubscribe from a Session Channel<br></strong>Unsubscribes a user from a session’s channel when they leave.</p><pre>export const unsubscribe = async (sessionId) =&gt; {<br> await subClient.unsubscribe(sessionId);<br>};</pre><h3>Bringing It All Together with the Session Service</h3><p>The <strong>session service</strong> acts as the glue between the cache and Pub/Sub services. It handles the business logic for session creation, joining, messaging, and closing, ensuring that Redis Sets and Pub/Sub channels are properly synchronized.</p><h4>Session Service Integration</h4><p>Here’s how the session service integrates Redis cache and Pub/Sub:</p><pre>// services/session.service.js<br>import { cache, pubsub } from &#39;../services/redis.service.js&#39;;<br>import { generateKeys } from &#39;../utils/keys.js&#39;;<br>import { generateCode } from &#39;../utils/generateCode.js&#39;;<br><br>export const createSession = async (userId) =&gt; {<br> const code = await generateCode();<br> const { sessionKey, userKey } = generateKeys(code, userId);<br><br> await cache.createSession({ sessionKey, userKey });<br> await pubsub.subscribe(userId, sessionKey);<br><br> return code;<br>};<br><br>export const joinSession = async (sessionKey, userKey) =&gt; {<br> await cache.addUser({ sessionKey, userKey });<br> await pubsub.subscribe(parseKey(userKey), sessionKey);<br>};<br><br>export const sendMessage = async (sessionKey, message) =&gt; {<br> await pubsub.publish(sessionKey, message);<br>};<br><br>export const leaveSession = async (sessionKey, userKey) =&gt; {<br> await cache.removeUser({ sessionKey, userKey });<br> await pubsub.unsubscribe(sessionKey);<br>};<br><br>export const closeSession = async (sessionKey) =&gt; {<br> await cache.deleteSession(sessionKey);<br> await pubsub.unsubscribe(sessionKey);<br>};</pre><h4>Middleware for Validation</h4><p>To keep the controllers lightweight, validation logic is handled in middleware. For example:</p><pre>// middleware/validateUser.js<br><br>export const validateSession = async (req, res, next) =&gt; {<br>  const { code, userId } = req.body;<br><br>  if (!userId || !code) {<br>   throw new Error(&#39;Missing userId or code.&#39;);<br>  }<br><br>  const { sessionKey, userKey } = generateKeys(code, userId);<br><br>  const inCache = await cacheClient.exists(sessionKey);<br><br>  if (!inCache) {<br>   throw new Error(&#39;Session not found.&#39;);<br>  }<br><br>  req.keys = { sessionKey, userKey };<br><br>  next();<br> };</pre><h4>Lightweight Controllers</h4><p>Controllers focus on handling requests and responses, delegating business logic to services and middleware. Here’s the createSession controller:</p><pre>// controllers/session.controller.js<br>export const createSession = async (req, res) =&gt; {<br> const { userId } = req.body;<br><br> if (!userId) throw new Error(&#39;Missing userId.&#39;);<br><br> const code = await sessionService.createSession(userId);<br><br> res.status(201).json({<br>  success: true,<br>  message: &#39;Session created.&#39;,<br>  data: { code },<br> });<br>};</pre><h3>Wrapping It Up</h3><p>With the app now complete, we’ve built a robust foundation for real-time communication. <a href="https://medium.com/@chev0100/build-a-scalable-session-based-communication-app-using-redis-pub-sub-and-node-js-d09f9dc0b16b">In <strong>Part One</strong>, we set up the <strong>Express server</strong>, designed <strong>RESTful API routes</strong>, and leveraged <strong>Redis Sets</strong> to manage session data and track users.</a> In this instalment, we implemented the <strong>Pub/Sub messaging service</strong> and integrated it with our session management service and middleware. By combining Redis Sets for session tracking and Pub/Sub for real-time updates, our app ensures efficient and scalable communication. The <strong>session service</strong> orchestrates the flow between these components, while lightweight controllers and middleware keep the code clean and maintainable.</p><h4><strong>What’s Next?</strong></h4><p>In <strong>Part Three, </strong>we’ll bring it all to life with a live demo of the app in action. You’ll see how users can:</p><ul><li><strong>Create</strong> and <strong>join</strong> <strong>sessions</strong>.</li><li>Exchange <strong>real-time messages</strong> within a session.</li><li><strong>View messages in their terminals as they’re sent and received.</strong></li></ul><p>We’ll also explore future possibilities, like integrating <strong>WebSockets</strong> for a fully event-driven interface and adding <strong>persistent session storage</strong>. Stay tuned for the final instalment, where we’ll test the app and show you how to extend it for your own projects!</p><p><a href="https://medium.com/@chev0100/demoing-a-session-based-communication-app-for-redis-pub-sub-and-node-js-78a3993beb87"><strong>Jump to Part Three</strong></a></p><p><em>You can find the </em><strong><em>full code</em></strong><em> for this project on my </em><a href="https://github.com/vincentpchevalier/redis-session-pubsub"><strong><em>GitHub Repo</em></strong></a><strong><em>.</em></strong><em> Feel free to explore, fork, and build upon it for your own projects!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=acc494adc48f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build a Scalable Session-Based Communication App Using Redis Pub/Sub and Node.js]]></title>
            <link>https://medium.com/@chev0100/build-a-scalable-session-based-communication-app-using-redis-pub-sub-and-node-js-d09f9dc0b16b?source=rss-0a4bdd518348------2</link>
            <guid isPermaLink="false">https://medium.com/p/d09f9dc0b16b</guid>
            <category><![CDATA[expressjs]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[pub-sub]]></category>
            <category><![CDATA[redis]]></category>
            <category><![CDATA[backend-development]]></category>
            <dc:creator><![CDATA[Vincent Chevalier]]></dc:creator>
            <pubDate>Tue, 11 Feb 2025 16:04:19 GMT</pubDate>
            <atom:updated>2025-02-19T00:44:20.490Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Logos for Node.js and Redis." src="https://cdn-images-1.medium.com/max/964/1*t5LykpqI4trdLOLIJlWsuA.png" /><figcaption>Logos for Node.js and Redis.</figcaption></figure><p><em>Part One of a three-part series exploring scalable session-based app development with Redis and Node.js. Read </em><a href="https://medium.com/@chev0100/real-time-management-with-redis-pub-sub-part-two-acc494adc48f"><strong><em>Part Two</em></strong></a><strong><em> </em></strong><em>and </em><a href="https://medium.com/@chev0100/demoing-a-session-based-communication-app-for-redis-pub-sub-and-node-js-78a3993beb87"><strong><em>Part Three</em></strong></a><em>.</em></p><p>As a front-end developer transitioning to full-stack, I wanted to tackle a project that combined <strong>real-time communication</strong> with <strong>scalable session management.</strong> The goal? Build a lightweight, session-based app where users could interact in real-time without the complexity of persistent data storage. Enter <strong>Redis:</strong> a powerful in-memory data store with built-in <strong>Pub/Sub capabilities, </strong>perfect for transient messaging and session management.</p><p>In this <strong>three-part series</strong>, I’ll walk you through how I built a session-based communication app using <strong>Node.js</strong>, <strong>Express</strong>, and <strong>Redis</strong>. Here’s what we’ll cover:</p><ul><li><strong>Part One</strong>: Setting up the <strong>Express server</strong>, designing a <strong>RESTful API</strong> for session management, and using <strong>Redis Sets</strong> to track users and sessions.</li><li><strong>Part Two</strong>: Diving into <strong>Redis Pub/Sub</strong> for real-time messaging, showing how users can exchange messages within a session.</li><li><strong>Part Three</strong>: Exploring a <strong>full demo</strong> of the app, discussing future improvements like <strong>WebSocket integration</strong>, and wrapping up with key takeaways.</li></ul><p>By the end of the series, you’ll have a solid foundation to build your own real-time systems, whether for chat apps, multiplayer games, or collaborative tools.</p><h3><strong>Why Redis Pub/Sub?</strong></h3><p>Redis is a natural fit for lightweight, real-time applications. Its <strong>Pub/Sub</strong> feature enables decoupled communication between publishers and subscribers, while its in-memory data store ensures <strong>low latency</strong> and <strong>high performance</strong>. For this project, Redis handles two key tasks:</p><ol><li><strong>Session Management:</strong> Using Redis Sets, the app tracks users in a session and manages session lifecycles.</li><li><strong>Real-Time Messaging: </strong>Pub/Sub channels enable instant message broadcasting between users in a session.</li></ol><p>While Redis Pub/Sub is ideal for transient messaging, it’s worth noting that it doesn’t retain messages, making it less suitable for systems requiring guaranteed delivery. For more complex use cases, integrating <strong>WebSockets</strong> or a persistent database like <strong>MongoDB </strong>could be the next step.</p><h3>What You’ll Learn in Part One</h3><p>I’ll focus on building the foundation for our session-based app using <strong>Node.js</strong> and <strong>Express. </strong>We will cover the following:</p><ol><li>Set up a <strong>RESTful API</strong> to handle session management.</li><li>Use <strong>Redis Sets</strong> to efficiently track users and sessions.</li><li>Build a fully functional cache service for creating, joining, and managing sessions, all powered by Redis’s lightweight and scalable data storage.</li></ol><p>By the end of this article, you’ll have a solid understanding of how to use Redis for session management and be ready to dive into real-time messaging in Part Two.</p><h3>Setting Up Express and RESTful API Routes</h3><p>For this project, I built a lightweight <strong>Express</strong> server with a RESTful API to handle session management and real-time messaging. The API exposes four key endpoints for creating, joining, leaving, and closing sessions, as well as one endpoint for sending messages between users. This design allows for easy session management and lays the groundwork for a more event-driven interface (e.g., using WebSockets) in the future.</p><h4>Express Server Setup</h4><p>Here’s a basic setup for the Express server:</p><pre>import express from &#39;express&#39;;<br>import sessionRoutes from &#39;./routes/session.routes.js&#39;;<br><br>const app = express();<br>app.use(express.json());<br><br>// Session management routes<br>app.use(&#39;/session&#39;, sessionRoutes);<br><br>const PORT = process.env.APP_PORT || 3000;<br>app.listen(PORT, () =&gt; {<br> console.log(`Server running on port ${PORT}`);<br>});</pre><h4>API Routes Overview</h4><figure><img alt="A JSON object in Postman showing a response with a randomly-generated code and message reading “Session created.”" src="https://cdn-images-1.medium.com/max/525/1*MKQUndE8NOF-7btR0kUw_A.png" /><figcaption>Response for /session route with the randomly generated code.</figcaption></figure><p>The API is designed to handle the following operations:</p><p><strong>Create a Session </strong>POST /session<br><strong>Purpose:</strong> Creates a new session with the user as the first member.<br><strong>Input:</strong> userIdin the request body.<br><strong>Output:</strong> A unique session code is generated and returned.</p><p><strong>Join a Session </strong>POST /session/join<br><strong>Purpose:</strong> Adds a user to an existing session.<br><strong>Input:</strong> userId and code in the request body.<br><strong>Constraint:</strong> Only two users can join a session at a time.</p><p><strong>Leave a Session </strong>PUT /session/leave<br><strong>Purpose:</strong> Removes a user from the session.<br><strong>Input:</strong> userId and code in the request body.<br><strong>Note:</strong> The session remains open for the other user.</p><p><strong>Close a Session </strong>DELETE /session/close<br><strong>Purpose:</strong> Closes the session for all users and deletes it from Redis.<br><strong>Input:</strong> userId and code in the request body.</p><p><strong>Send a Message </strong>POST /session/message<br><strong>Purpose:</strong> Publishes a message to all users in the session.<br><strong>Input:</strong> userId, code, and messagein the request body.<br><strong>Note:</strong> Messages are logged to the console in this version.</p><h4>Router Setup</h4><p>Here’s how the routes are defined in the Express router:</p><pre>// routes/session.route.js<br><br>import { Router } from &#39;express&#39;;<br>import {<br> createSession,<br> joinSession,<br> leaveSession,<br> sendMessage,<br>} from &#39;../controllers/session.controller.js&#39;;<br><br>const sessionRouter = Router();<br><br>sessionRouter.post(&#39;/&#39;, createSession);<br>sessionRouter.post(&#39;/join&#39;, joinSession);<br>sessionRouter.put(&#39;/leave&#39;, leaveSession);<br>sessionRouter.delete(&#39;/close&#39;, closeSession);<br>sessionRouter.post(&#39;/message&#39;, sendMessage);<br><br>export default sessionRouter;</pre><h4><strong>Why This Design Works</strong></h4><p>This RESTful API provides a clear and structured way to manage sessions and messaging. By decoupling session management from real-time communication, the app remains flexible and scalable. For example, transitioning to WebSockets in the future would only require modifying the messaging layer, while the session management logic remains unchanged.</p><h3>Using Redis Sets to Manage Session Data and Track Users</h3><p>At the core of this application are two Redis services:</p><ol><li><strong>Cache Service</strong>: Uses Redis Sets to manage session data and track users.</li><li><strong>Pub/Sub Service</strong>: Handles real-time messaging between users in a session.</li></ol><p>These services are initialized when the app starts and work together to ensure seamless session management and communication. While the <strong>cache service</strong> validates sessions and users (e.g., ensuring a session exists and only two users are allowed), the <strong>pub/sub service</strong> enables real-time message broadcasting.</p><h4>Node.js and Redis: Initializing Redis Clients</h4><p>To interact with Redis, the app uses the redis library for Node.js. To use Redis, you’ll need to <strong>install it locally for development</strong> or use <a href="https://redis.io/docs/latest/operate/rc/"><strong>a cloud-based Redis service for production.</strong></a></p><h4>Installing Redis Locally</h4><p>For local development, you can install Redis on your machine. Here’s how:</p><ol><li><strong>Install Redis</strong><br><a href="https://redis.io/docs/latest/operate/oss_and_stack/install/install-redis/">Follow the official Redis installation guide for your operating system.</a> For <strong>macOS, </strong><a href="https://redis.io/docs/latest/operate/oss_and_stack/install/install-redis/install-redis-on-mac-os/">use <strong>Homebrew</strong></a>:</li></ol><pre>brew install redis</pre><p><strong>2. Start the Redis Server<br></strong>Once installed, start the Redis server with:</p><pre>redis-server</pre><p><strong>3. Connect to Redis<br></strong>Set your .env file to point to your local or remote Redis instance:</p><pre>REDIS_URL=redis://localhost:6379</pre><h4>Connecting to Redis in the App</h4><p>The Redis client connects to the server using the URL specified in the .env file. Here’s how we set up the client for the cache service:</p><pre>// services/redis.service.js<br><br>import redis from &#39;redis&#39;;<br><br>let cacheClient;<br><br>export const initializeRedis = async () =&gt; {<br> console.log(&#39;Connecting to Redis...&#39;);<br> try {<br>  const url = process.env.REDIS_URL;<br><br>  cacheClient = redis.createClient({ url });<br>  await cacheClient.connect();<br>  console.log(&#39;Cache client connected.&#39;);<br> } catch (error) {<br>  console.error(&#39;Redis initialization error:&#39;, error);<br>  throw new Error(&#39;Unable to connect to Redis.&#39;);<br> }<br>};<br><br>export { cacheClient };</pre><p>We initialize it within our app&#39;s index.js file:</p><pre>import express from &#39;express&#39;;<br>import { initializeRedis } from &#39;./services/redis.service.js&#39;;<br>import sessionRoutes from &#39;./routes/session.routes.js&#39;;<br><br>// Initialize Express app<br>const app = express();<br>app.use(express.json());<br><br>// Initialize Redis<br>initializeRedis();<br><br>// Session management routes<br>app.use(&#39;/session&#39;, sessionRoutes);<br><br>// Start the server<br>const PORT = process.env.APP_PORT || 3000;<br>app.listen(PORT, () =&gt; {<br> console.log(`Server running on port ${PORT}`);<br>});</pre><h4>Cache Service: Managing Sessions with Redis Sets</h4><p>The cache service is responsible for creating, validating, and managing sessions using Redis Sets.</p><ul><li><strong>Session Keys</strong>: Each session is represented by a unique key in the format session:&lt;code&gt;, where code is a 4-digit identifier.</li><li><strong>User Keys</strong>: Users in a session are stored as members of the session Set, with keys in the format user:&lt;userId&gt;.</li></ul><figure><img alt="Redis Insight Dashboard showing session keys and user members." src="https://cdn-images-1.medium.com/max/906/1*9Om7FjgkktX2zAEbQO7shA.png" /><figcaption><em>Redis Insight Dashboard showing session keys and user members. Each session (e.g., </em><em>session:1357) stores user keys (e.g., </em><em>user:redrover1977) as members in a Redis Set. The TTL ensures sessions expire after a set time (in seconds).</em></figcaption></figure><p>For example, a user with the ID redrover1977 creates a session, and a random code (1357) is generated and returned in the response. A Redis Set is added to the cache with the following key and member:</p><ul><li><strong>Key: </strong>session:1357</li><li><strong>Member(s): </strong>user:redrover1977</li></ul><p>When a second user joins, their ID (e.g., user:experts12) is added to the same Set. Redis Sets ensure that each user is unique within a session, preventing duplicates. Additionally, features like <strong>TTL (Time to Live)</strong> and helper methods like sCard in our<strong> cache service</strong> allow us to count and control the number of unique members, and automatically expire sessions.</p><h4>Generating a Unique Session Code</h4><p>As the app creates a session, it generates a <strong>unique 4-digit code.</strong> This code is used to create the session key and ensure no two sessions have the same identifier. Here’s the snippet for generating the session code:</p><pre>// utils/generateCode.js<br><br>import { cacheClient } from &#39;../services/index.js&#39;;<br><br>export const generateCode = async () =&gt; {<br> let code;<br> let exists;<br><br> do {<br>  code = Math.floor(1000 + Math.random() * 9000).toString();<br>  exists = await cacheClient.exists(`${process.env.SESSION_KEY}${code}`);<br> } while (exists);<br><br> return code;<br>};</pre><p>This function generates the random code and checks if it already exists in Redis. If the code is unique, it’s returned and used to <strong>create a new session</strong>.</p><h4>Key Generation Helper Functions</h4><p>To simplify key creation and parsing, we use these helper functions:</p><pre>// utils/keys.js<br><br>export const generateKeys = (code, userId) =&gt; {<br> const sessionKey = process.env.SESSION_KEY + code;<br> const userKey = process.env.USER_KEY + userId;<br><br> return { sessionKey, userKey };<br>};<br><br>export const parseKey = (key) =&gt; {<br> if (key.startsWith(process.env.SESSION_KEY)) {<br>  return key.split(process.env.SESSION_KEY)[1];<br> } else if (key.startsWith(process.env.USER_KEY)) {<br>  return key.split(process.env.USER_KEY)[1];<br> } else {<br>  throw new Error(&#39;Invalid key.&#39;);<br> }<br>};</pre><p>These functions are used when creating and validating sessions, ensuring consistent key formats across the app.</p><h4>Session Management Functions</h4><p>The service provides several functions to manage sessions and users. In cache.service.js there are the following functions:</p><p><strong>Create a Session<br></strong>Adds the first user to a new session Set and sets an expiration time using TTL.</p><pre>export const createSession = async ({ sessionKey, userKey }) =&gt; {<br> await cacheClient.sAdd(sessionKey, userKey);<br><br> // expiration set to 3600 seconds<br> await cacheClient.expire(sessionKey, process.env.TTL_EXPIRATION); <br>};</pre><p><strong>Add a User to a Session<br></strong>Validates that the session has fewer than two users before adding a new member and updates the session’s expiration time.</p><pre>export const addUser = async ({ sessionKey, userKey }) =&gt; {<br> const userCount = await cacheClient.sCard(sessionKey);<br><br> if (userCount &gt;= 2) throw new Error(&#39;Session is already full.&#39;);<br><br> await cacheClient.sAdd(sessionKey, userKey);<br><br> // update the expiration to 3600 seconds again<br> await cacheClient.expire(sessionKey, process.env.TTL_EXPIRATION);<br>};</pre><p><strong>Remove a User from a Session<br></strong>Removes a user from the session Set.</p><pre>export const removeUser = async ({ sessionKey, userKey }) =&gt; {<br> await cacheClient.sRem(sessionKey, userKey);<br>};</pre><p><strong>Close a Session<br></strong>Deletes the session Set from Redis, effectively ending the session.</p><pre>export const deleteSession = async (sessionKey) =&gt; {<br> await cacheClient.del(sessionKey);<br>};</pre><h4>Integration with the Session Service</h4><p>The <strong>cache service</strong> is integrated into a higher-level <strong>session service*</strong>, which maps to the API endpoints. For example, when a user <strong>creates a session,</strong> the session service:</p><ol><li>Generates a unique session code.</li><li>Uses the cache service to create the session and add the user.</li><li>Subscribes the user to the session’s Pub/Sub channel for real-time messaging.</li></ol><p>This separation of concerns ensures that the cache service handles data storage and validation, while the session service orchestrates the overall flow between both Redis services (cache and pubsub).</p><p><em>*We’ll cover more about the session service in Part Two when we integrate it with our Pub/Sub service.</em></p><h3>Coming Up</h3><p>In this first article, we’ve laid the foundation for a <strong>scalable session-based app</strong> using <strong>Node.js</strong>, <strong>Express</strong>, and <strong>Redis Sets</strong> for caching and validation. By building and integrating a cache service with a higher-level session service, we’ve ensured a <strong>clean separation of concerns</strong> and prepared the app for real-time communication.</p><p>In <a href="https://medium.com/@chev0100/real-time-management-with-redis-pub-sub-part-two-acc494adc48f"><strong>Part Two</strong></a>, we’ll dive into <strong>Redis Pub/Sub</strong> to enable real-time messaging between users, explore how to set up publisher and subscriber clients, and demonstrate how the app handles live message broadcasting.</p><p><em>You can find the </em><strong><em>full code</em></strong><em> for this project on my </em><a href="https://github.com/vincentpchevalier/redis-session-pubsub"><strong><em>GitHub Repo</em></strong></a><strong><em>.</em></strong><em> Feel free to explore, fork, and build upon it for your own projects!</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d09f9dc0b16b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[My Top 5 Tech Podcast Picks for 2024: Why You Might Like Them Too]]></title>
            <link>https://medium.com/@chev0100/my-top-5-tech-podcast-picks-for-2024-why-you-might-like-them-too-170e081be197?source=rss-0a4bdd518348------2</link>
            <guid isPermaLink="false">https://medium.com/p/170e081be197</guid>
            <category><![CDATA[personal-growth]]></category>
            <category><![CDATA[tech]]></category>
            <category><![CDATA[podcast]]></category>
            <category><![CDATA[culture]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Vincent Chevalier]]></dc:creator>
            <pubDate>Sat, 06 Apr 2024 01:43:22 GMT</pubDate>
            <atom:updated>2024-04-06T01:43:22.719Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jmDYVyh3ZbN9E5CW" /><figcaption>Photo by <a href="https://unsplash.com/@kruschti?utm_source=medium&amp;utm_medium=referral">Thorsten Konersmann</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Like many people over the last few years, I’ve developed a deep appreciation for tech podcasts. They provide great company during walks, household chores, or commutes. For better or for worse, thanks to the easy access to quality sound recording equipment and editing software, there are more podcasts than ever. While my podcast listening habits go back at least a decade, my interest in tech podcasts grew during the early 2020s lockdowns, coinciding with my growing interest in technology. As I delved more into coding and pivoted my career towards the tech industry, I became increasingly aware of its impact on society, culture, and commerce. I sought out tech podcasts to deepen my knowledge of trends, tutorials, and topics, and to learn about the difference people were making in the industry. Over time, I’ve expanded my weekly listening content and now consider myself well-informed about the tech world. With that in mind, I’ve compiled a list of my top five podcasts for a broader perspective on the offerings and future of technology.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*GKR8tLqsO1nQMb-DXYos-g.jpeg" /><figcaption>Logo for Syntax by Wes Bos and Scott Tolinski</figcaption></figure><h3>#1 — Syntax</h3><p><em>Hosted by Wes Bos and Scott Tolinski</em></p><p>Billing itself as a “Tasty Treats Podcast for Web Developers,” Syntax is hosted by two very experienced and dynamic developers who I have admired for a long time. My first intro to JavaScript was Wes Bos’s <a href="https://javascript30.com/">30 Day Vanilla JS Coding Challenge</a><em>,</em> and I find him to be an engaging educator and spokesperson. This podcast is <em>for</em> developers <em>by</em> developers, covering everything from technical explainers to interviews with industry professionals, and discussions of recent developments or fads in the developer community. During a recent episode titled <a href="https://syntax.fm/show/747/middleware-explained">“Middleware Explained,”</a> they breakdown core concepts of the topic, giving examples of where and how to use it, and talking about its limitations. In <a href="https://syntax.fm/show/734/htmx-web-apps-with-carson-gross">another episode</a>, they interviewed Carson Gross, the creator of htmx, discussing the origins of this library and how it has gained a meme status in development communities across the internet. Each episode (<a href="https://syntax.fm/shows">on their website</a>) comes with a timestamped list of show notes, making it easy for listeners to review past topics and apply this to their work or research.</p><p><strong>Who is this for?</strong> Primarily for developers!</p><p><strong>Where to find it?</strong> Available on major platforms including Apple Music, Spotify and at <a href="https://syntax.fm/"><strong>syntax.fm</strong></a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ROpExodrkyDjCzjbN4gVrw.png" /><figcaption><a href="https://www.404media.co/404-media-podcast-male-conference-devternity/">Image: 404 Media</a></figcaption></figure><h3>#2 — The 404 Media Podcast</h3><p><em>Hosted by Jason Koebler, Sam Cole, Joseph Cox, and Emanuel Maiberg</em></p><p>A newcomer on the scene, the <a href="https://www.404media.co/the-404-media-podcast/"><strong>404 Media Podcast</strong></a> is the flagship podcast for the news website of the same name. 404 Media was founded by a quartet of former VICE Motherboard journalists who wanted to produce high-quality investigative journalism and critical perspectives on topics within tech including labour politics, finance, surveillance apparatus, national security, and culture. In their own words, they are a “digital media company exploring the ways technology is shaping–and is shaped by–our world.” On their most recent episode “<a href="https://podcasts.apple.com/us/podcast/the-xz-backdoor-and-the-ai-peer-review-crisis/id1703615331?i=1000651308908">The Xz Backdoor and the AI Peer-Review Crisis</a>,” ****they discussed research about how generative AI text was increasingly showing up in academic articles, finding that the closer a paper was submitted to the submission deadline, the more certain words favoured by LLMs would appear in the writing. Earlier this month, their lead journalist Jason Koebler, sat down with a spokesperson at Google and discussed their company’s recent shift towards supporting the right to repair. Coming from Motherboard, these journalists are rigorous and willing to discuss difficult topics from a left-of-centre perspective. Their podcast is a great way to learn about the deeper context of the journalism that they feature on their main news site.</p><p><strong>Who is this for?</strong> Listeners who enjoyed Vice’s investigative work and edgy style and who are more critical of the tech world</p><p><strong>Where to find it?</strong> Their episodes are free to all but second half of the episode where they delve deeper into the topic is protected by a paywall. You can find their content on Apple Music, Spotify, Google Podcasts, or a custom RSS feed found on the <a href="https://www.404media.co/the-404-media-podcast/"><strong>404 Media Website</strong></a><strong>.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ltw7sMlvngqaGKY3dLUiaw.jpeg" /><figcaption><a href="https://www.theverge.com/2017/2/17/14648166/vergecast-podcast-243-planet-of-the-apps-caavo-iphone-rumors-sonos">Photo by James Bareham / The Verge</a></figcaption></figure><h3>#3 — The Vergecast</h3><p><em>Hosted by Nilay Patel, David Pierce, and Alex Cranz</em></p><p>Part of the Vox Media podcast network, <a href="https://www.theverge.com/the-vergecast"><strong>The Vergecast </strong></a>is the flagship podcast for the <a href="https://www.theverge.com/">Verge dot com</a>. The Vergecast is a fun listen for tech-enthusiasts wanting to keep on top of the latest trends and gadgets coming out of Silicon Valley and beyond. In their own words, The Vergecast “gives an irreverent and informative look at what’s happening right now (and next) in the world of technology and gadgets,” maintaining a strong focus on current events and trends. They are much more sympathetic and easy-going on the tech world and its popular companies or figures. <a href="https://www.theverge.com/2024/3/5/24090759/humane-pin-nothing-2a-transparent-lenovo-laptop-mwc-vergecast">Recent episodes include a trip to Barcelona</a> where they assessed the most recent releases presented at the Mobile World Congress (MWC). In another episode, <a href="https://www.theverge.com/24118418/keyboard-layout-qwerty-microsoft-copilot-surface-netflix-thumbs">they discuss the history of the QWERTY keyboard</a>, how it ended up as the default setup, and how there are better ways to organize keys. It’s a fun user-centric story that listeners could learn a lot from.</p><p><strong>Who is this for?</strong> People who like gadgets and are very sympathetic to the tech world while wanting to stay informed.</p><p><strong>Where to find it?</strong> Available on major platforms like Apple Music, Spotify, and Google Podcasts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*XPz6Wk9A5TDQguqTZ4rshw.jpeg" /><figcaption><a href="https://techwontsave.us/">Logo for the Tech Won’t Save Us podcast.</a></figcaption></figure><h3>#4 — Tech Won’t Save Us</h3><p><em>Hosted by Paris Marx</em></p><p>Tech Won’t Save Us is a Canadian techno-pessimist/realist podcast that features a distinctive conversational style between its host, Paris Marx and his guests. The topics and commentary are a bit more academic and researched than the previous podcasts in this list. While still covering recent events, the podcast does a great job digging down into some of the larger questions that frame the tech world and its place in our society. The episodes will often cover legal, regulatory, financial, and cultural events and movements in tech, including the hype around cryptocurrencies and the NFT-bubble, discussions of the trial of Sam Bankman-Fried, and more local perspectives like analyzing the recent conflict between the tech giants (Google, Facebook) and the Canadian government over taxing news content on the major platforms. Last fall, the team behind Tech Won’t Save Us produced, <a href="https://podcasts.apple.com/ca/podcast/elon-musk-unmasked-shaping-the-future-part-4/id1507621076?i=1000633442126">Elon Musk Unmasked</a>, a 4-part mini-series cataloguing the rise and fall of controversial tech CEO Elon Musk. They also hold a yearly <a href="https://twitter.com/techwontsaveus/status/1736527590863544465">“Worst Person In Tech”</a> bracket where they canvas their listeners and twitter users on who they think had a particularly negative impact on tech in the past year.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CizU_Aq1bxYvO_gVeLBgvg.png" /><figcaption>The results for the Tech Won’t Save Us “Worst Person In Tech” bracket of 2023.</figcaption></figure><p><strong>Who is this for?</strong> People who enjoy a deeper dive on bigger topics and enjoy complex social, economic, and political forces behind tech being explained to them by knowledgeable experts.</p><p><strong>Where to find it?</strong> Part of the Harbinger Media Network of podcasts you can find Tech Won’t Save Us on their <a href="https://techwontsave.us/"><strong>website</strong></a><strong>, </strong>at Apple Music, Spotify, or Google podcasts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZTzx8BADj2qafOovx_-QuQ.jpeg" /><figcaption>Alex Goldman and PJ Vogt of Reply All</figcaption></figure><h3>#5 — Reply All (Honourable Mention)</h3><p><em>Hosted by Alex Goldman and PJ Vogt (and later Emmanuel Dzotsi)</em></p><p>This was the first tech podcast I ever listened to and remains one of my favourite shows ever. Reply All was a tech lifestyle show that focused on human-centric stories about a variety of quirky and interesting topics. Unfortunately, they are no longer releasing new episodes, but their archive is still up and has many classic episodes available for when when you run out of more recent podcasts to listen to. You can find a list of their best episodes on the <a href="https://gimletmedia.com/shows/reply-all/posts/getting-started">Reply All website</a>. For example, Episode #130: The Snapchat Thief follows the trail of a rash of account robberies where hackers took over popular Snapchat handles only to try and sell them back to their original owners for a ridiculous price. In one of my favourite episodes, host Alex Goldman tracks the employees of a scamming call centre in India, developing a relationship with them and eventually visiting them in person to get insight in why they do what they do. The show really paved the way for tech podcasts and remains a crucial resource for people interested in the culture and history of the web.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/316/1*RFoAhyvM9A3IMl0npFEPNA.png" /><figcaption>Podcast art for Reply All.</figcaption></figure><p><strong>Who is this for?</strong> Nerds who are nostalgic for the internet of the 2010s.</p><p><strong>Where to find it?</strong> A Gimlet Media podcast, available on Spotify and <a href="https://gimletmedia.com/shows/reply-all">on their website.</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=170e081be197" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Shifting Gears: How htmx Challenges Traditional Web Development]]></title>
            <link>https://medium.com/@chev0100/shifting-gears-how-htmx-challenges-traditional-web-development-61e5fc37520a?source=rss-0a4bdd518348------2</link>
            <guid isPermaLink="false">https://medium.com/p/61e5fc37520a</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[personal-growth]]></category>
            <category><![CDATA[htmx]]></category>
            <category><![CDATA[memes]]></category>
            <dc:creator><![CDATA[Vincent Chevalier]]></dc:creator>
            <pubDate>Tue, 12 Mar 2024 04:24:48 GMT</pubDate>
            <atom:updated>2024-03-12T04:24:48.070Z</atom:updated>
            <content:encoded><![CDATA[<p>As a developer I spend a lot of time on Twitter (now X) following people in the industry, trying to keep up with new trends, and discover new concepts and workflows in web development. Recently I started noticing a lot of hype and memes being spun about a trendy little JavaScript library called ‘htmx.’ Admittedly, I had no clue about its purpose or relevance to my existing skill set. This makes sense, given my recent focus on JavaScript and frameworks like React and Flutter. I enjoyed playing around with data and APIs but my knowledge and experience was limited to the MERN stack. So when I scrolled across this meme I had trouble understanding its full meaning:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E_P36mcuCCDVBbq4pVUAfQ.png" /><figcaption>A meme from the htmx.org essay page.</figcaption></figure><p>My curiosity was piqued. What was this promise of a streamlined process with little to no packages to worry about or complex architectures to twist my mind around? I chose to jump into research-mode. I looked around and with a bit of intrepid searching, I found some answers. I listened to some podcasts (shoutout to Syntax’s great <a href="https://syntax.fm/show/726/is-htmx-a-joke"><strong>couple of episodes</strong></a><strong> </strong>on <a href="https://syntax.fm/show/734/htmx-web-apps-with-carson-gross"><strong>the topic</strong></a>), <a href="https://htmx.org/">read <strong>some essays and documentation</strong></a>, and started playing around with the code (I had to do a bit of <a href="https://labcodes.com.br/blog/en-us/development/pros-and-cons-for-a-htmx-beginner/"><strong>research</strong></a> into <a href="https://pugjs.org/api/getting-started.html"><strong>templating</strong></a> to figure out where to start). Here is what I have learned.</p><h3>What is htmx?</h3><p>htmx, a compact JavaScript library, has gained popularity for those seeking an efficient alternative to extensive front-end coding. In contrast to traditional approaches where back-end frameworks generate HTML from data, htmx centers around HTML templates. While HTML lacks reactivity, htmx addresses this limitation by extending the core idea of HTML as hypertext.</p><p>htmx introduces a novel concept: treating any HTML element as a trigger for HTTP requests (and not just GET and POST but PUT, PATCH, and DELETE too). It enhances events, allowing them to handle and trigger requests, facilitating CRUD operations with new attributes. Htmx empowers developers to create and target modular components, departing from the traditional approach that affects the entire window upon re-render without the use of frameworks. By using HTML for server-side rendering of components, your app dynamically loads them onto the webpage with minimal to no reliance on JavaScript. Lightweight, dependency-free, and browser-oriented, htmx further extends its capabilities to loading and swapping CSS styles upon retrieving templates from the server.</p><p>With a relatively straightforward front-end setup, requiring a server configuration and a templating language on the backend, htmx contributes to improved responsiveness and performance. Additionally, its minuscule code base, 67% smaller than frameworks like React and Angular, makes it an appealing choice for developers looking to enhance accessibility for users relying on assistive technology.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*enhDZELW9yjrgs36S1j-1g.png" /><figcaption>Another great (yet inscrutable) meme from htmx.org</figcaption></figure><h3>Why htmx?</h3><p>The author of htmx, Carson Gross, is an evangelist for hypertext / hypermedia. Hypertext, at it’s simplest form, is computerized text on a digital display that contains links to other (hyper)media and (hyper)text. In his 2022 essay, <a href="https://htmx.org/essays/when-to-use-hypermedia/">“<strong>When Should You Use Hypermedia?”</strong></a> Gross argues that a hypermedia approach can be more efficient than SPAs built with RESTful APIs. By moving all the rendering to the server where the data already is and then serving it client-side, your application can be much more efficient and streamlined. Moreover, the htmx approach fully leverages and extends the existing attributes of HTML to do the heavy lifting of state management and logic that JavaScript usually does. You are removing the middle JSON layer and relay information more directly to the client.</p><p>This is a great library for backend developers who want to have little or no involvement with using a front-end framework. It’s easy to learn and configure, making it straightforward to get a fully functional web app up and running quickly. That said, it’s not ideal for large applications or those that need to scale. The workflow requires a front-end developer (like myself) to think differently — all responses are in HTML, which takes some getting used to after working with JSON for so long. Furthermore, as a relatively new framework, there is scarce documentation and not much community interest, despite its meme popularity. Because of this, it’s difficult to know where to start. There are so many ways you can set up your project, with different frameworks, libraries, and programming languages on the backend that you can use to configure your app. The community has yet to establish a standard approach for those who want to experiment. That didn’t stop me from experimenting a bit on my own. I set up a small server using Node.js, Pug, and MongoDB to play around with building a web app completely made out of components compiled, rendered, and deployed from the server-side. I will be sharing some of these experiments in future blog posts, so keep an eye out for this space.</p><h3>Resources</h3><p><strong>The official htmx&lt;/&gt; site: </strong><a href="http://htmx.org/">htmx.org</a></p><p><strong>Syntax Episode 734 <em>“htmx web apps with Carson Gross”</em>:</strong> <a href="https://syntax.fm/show/734/htmx-web-apps-with-carson-gross">https://syntax.fm/show/734/htmx-web-apps-with-carson-gross</a></p><p><strong>My Twitter (X):</strong> <a href="https://twitter.com/technivincent">https://twitter.com/technivincent</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=61e5fc37520a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Decoding W3C’s Web Sustainability Guidelines: A Developer’s Intro]]></title>
            <link>https://medium.com/@chev0100/decoding-w3cs-web-sustainability-guidelines-a-developer-s-intro-14a7015c4ace?source=rss-0a4bdd518348------2</link>
            <guid isPermaLink="false">https://medium.com/p/14a7015c4ace</guid>
            <category><![CDATA[environmental-impact]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[personal-growth]]></category>
            <category><![CDATA[sustainability]]></category>
            <category><![CDATA[junior-developer]]></category>
            <dc:creator><![CDATA[Vincent Chevalier]]></dc:creator>
            <pubDate>Thu, 08 Feb 2024 02:48:49 GMT</pubDate>
            <atom:updated>2024-02-08T03:00:40.369Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dxLorFCF4uUW5tXN" /><figcaption>Photo by <a href="https://unsplash.com/@jcraice?utm_source=medium&amp;utm_medium=referral">Julia Craice</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>A few months ago, I attended an Ottawa JavaScript group meetup at Fullscript in Centretown, marking my return to in-person events since the onset of the pandemic. As a budding developer navigating the local professional scene, I anticipated the opportunity to network, gain insights into trending topics, and engage with like-minded peers. The vibe was congenial and enthused amongst the attendees who were ready to share their passion for JavaScript and discuss important issues. It was in this context that I found myself confronted with a question that has long preoccupied me as a digital content creator and global citizen: How can we reconcile society’s increasing reliance on the internet with its escalating energy consumption and consequent environmental impacts?</p><p>This question was brought front-of-mind by presenter Brett Tackaberry, Principal Architect at Google Cloud, who delivered a presentation on the W3C’s newly introduced Web Sustainability Guidelines. His insights not only covered the guidelines themselves but also delved into the collective responsibility of developers to implement them. This sparked my curiosity about the personal impact of adopting these guidelines and the feasibility of incorporating them into my development practices. To explore these questions, I embarked on a journey of research.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SB2dEZvACIRasJGJZ-TZsw.png" /><figcaption>World Wide Web Consortium on <a href="https://commons.wikimedia.org/wiki/File:W3C_icon.svg">Wikimedia Commons</a></figcaption></figure><h3>What are the Web Sustainability Guidelines?</h3><p>The Web Sustainability Guidelines (WSG) represent a set of foundational principles crafted by the World Wide Web Consortium (W3C), offering “baseline guidance” to web content developers, tool authors, governmental agencies and non-governmental organizations, and corporate entities. Originating as an extension of the Web Content Accessibility Guidelines (WCAG) established in 1999 to champion web accessibility, the WSG distinguishes itself with a primary objective: to define “environmental, social, and economic best practices based on measurable, evidence-based research” [<a href="https://w3c.github.io/sustyweb/#background-on-wsg">1</a>]. Unlike the WCAG, which centres on inclusivity and ease of access, the WSG extends its reach to encompass a holistic approach, examining the environmental impact of every facet of web content and services.</p><p>The WSG’s scope is broad, addressing not only sustainable websites and products but also considering elements such as browser compatibility, hardware (including devices and telecommunications infrastructure), server specifications and proximity to access points, code performance, design and development workflows, adoption of ethical business practices, and more.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CCyKwG_oyZUXOacyOG5j_A.png" /><figcaption>Screenshot from the <a href="https://www.sustainablewebmanifesto.com/">Sustainable Web Manifesto</a></figcaption></figure><p>In September 2023, the initial version (1.0) of the Web Sustainability Guidelines was introduced by the W3C, evolving from the GRI Standards and the Sustainable Web Manifesto [<a href="https://www.w3.org/blog/2023/introducing-web-sustainability-guidelines/">2</a>]. While the GRI Standards provide a structured framework for organizations to report on sustainability initiatives [<a href="https://www.globalreporting.org/about-gri/">3</a>], the Sustainable Web Manifesto issues a call to action based on six fundamental principles for those involved in building and maintaining the web [<a href="https://www.sustainablewebmanifesto.com/">4</a>]:</p><p><em>“Clean. The services we provide and services we use will be powered by renewable energy.”</em></p><p><em>“Efficient. The products and services we provide will use the least amount of energy and material resources possible.”</em></p><p><em>“Open. The products and services we provide will be accessible, allow for the open exchange of information, and allow users to control their data.”</em></p><p><em>“Honest. The products and services we provide will not mislead or exploit users in their design or content.”</em></p><p><em>“Regenerative. The products and services we provide will support an economy that nourishes people and planet.”</em></p><p><em>“Resilient. The products and services we provide will function in the times and places where people need them most.”</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/920/1*_RHLz70ZDSDzpVCYRbb-vA.png" /><figcaption>Join the movement!</figcaption></figure><blockquote>If you, as a conscientious and caring individual would like to join me in signing the manifesto, you can find it and its accompanying sign-up form here: <a href="https://www.sustainablewebmanifesto.com/"><strong>https://www.sustainablewebmanifesto.com/</strong></a></blockquote><p>The manifesto supplies us with lofty ambitions and a much needed intervention into the way the corporate world has done business since the advent of the World Wide Web and modern tech industry in the 1990s. It’s refreshing to see some of the techno-optimism from that period find its way to the present moment, in spite of the advent of certain extremely energy-intensive products and technologies like the rise of and pivot to video streaming, the blockchain, cryptocurrency, and the NFT craze, as well as the development of increasingly complex Large Language Models (LLMs) and generative AI over the last decade. While a manifesto alone may not suffice to address the environmental challenges posed by these tech advancements, the Web Sustainability Guidelines emerge as a vital tool. Comprising four categories of compliance — User Experience Design, Web Development, Infrastructure, and Product and Business — these guidelines will be instrumental in shifting cultures and business practices towards a more sustainable future.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8srW7-tCIvWvIR05" /><figcaption>Photo by <a href="https://unsplash.com/@appolinary_kalashnikova?utm_source=medium&amp;utm_medium=referral">Appolinary Kalashnikova</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>WSG and me: Crafting a Sustainable Development Path from Ideation to Impact</h3><p>This blog post marks the beginning of a series dedicated to exploring the ways in which I can align my workflow with the principles of the Web Sustainability Guidelines (WSG).</p><p>Embarking on this journey, I’ve initiated a comprehensive self-audit, aligning my approach with the Product and Business guidelines. In subsequent posts, I will delve deeper into each category, elucidating the specific strategies employed to diminish my environmental impact as a developer. Expect insights into my ongoing projects, where I will showcase examples of refactoring and optimizing existing work to adhere more closely to the WSG.</p><p>Moving through the various phases of ideation, development, production, and release, each post will explore how I can make a meaningful impact, whether through substantial overhauls or incremental adjustments requiring minimal effort. By employing practices such as utilizing low-carbon tools, adhering to DRY (Don’t Repeat Yourself) coding principles, and selecting servers or web hosts in close geographic proximity, I will aim to demonstrate tangible implementations of sustainable development practices.</p><p>Moving forward, I hope to showcase the adaptability of the WSG to diverse contexts and practices, underscoring its relevance for developers regardless of the scale of our work or level of expertise. I invite you to join me in considering how these principles can be seamlessly integrated into the development process.</p><h3>References</h3><ol><li><strong>Web Sustainability Guidelines (WSG) 1.0. Section 1.1 Background on WSG.</strong> <a href="https://w3c.github.io/sustyweb/#background-on-wsg">https://w3c.github.io/sustyweb/#background-on-wsg</a></li><li><strong>W3C Blog: Introducing Web Sustainability Guidelines.</strong> <a href="https://www.w3.org/blog/2023/introducing-web-sustainability-guidelines/">https://www.w3.org/blog/2023/introducing-web-sustainability-guidelines/</a></li><li><strong>GRI (Global Reporting Initiative).</strong> <a href="https://www.globalreporting.org/about-gri/**">https://www.globalreporting.org/about-gri/</a></li><li><strong>Sustainable Web Manifesto.</strong> <a href="https://www.sustainablewebmanifesto.com/**">https://www.sustainablewebmanifesto.com/</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=14a7015c4ace" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>