<?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: Hassan Yosuf</title>
    <description>The latest articles on DEV Community by Hassan Yosuf (@hassanyosuf).</description>
    <link>https://dev.to/hassanyosuf</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.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F759766%2Fb2ce14a7-e383-42c4-8c35-62a7a080fe41.png</url>
      <title>DEV Community: Hassan Yosuf</title>
      <link>https://dev.to/hassanyosuf</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hassanyosuf"/>
    <language>en</language>
    <item>
      <title>LLaMA 3.3 AI Assistant to My Spring Boot WebSocket App</title>
      <dc:creator>Hassan Yosuf</dc:creator>
      <pubDate>Mon, 11 May 2026 19:02:07 +0000</pubDate>
      <link>https://dev.to/hassanyosuf/llama-33-ai-assistant-to-my-spring-boot-websocket-app-hbo</link>
      <guid>https://dev.to/hassanyosuf/llama-33-ai-assistant-to-my-spring-boot-websocket-app-hbo</guid>
      <description>&lt;p&gt;Real-time messaging apps are great engineering exercises, but adding a conversational AI that seamlessly interacts within the same chat room takes the complexity—and the fun—to the next level. &lt;/p&gt;

&lt;p&gt;Recently, I integrated a LLaMA 3.3 model into my messaging backend, &lt;strong&gt;ChatUp&lt;/strong&gt;. Here is a breakdown of what the application is, and how I architected the AI integration using Spring Boot, WebSockets, and the Groq API.&lt;/p&gt;

&lt;p&gt;🔗 &lt;strong&gt;Live Demo:&lt;/strong&gt; &lt;a href="https://chatup-jg85.onrender.com/landing.html" rel="noopener noreferrer"&gt;Try ChatUp here&lt;/a&gt;&lt;br&gt;&lt;br&gt;
💻 &lt;strong&gt;GitHub Repo:&lt;/strong&gt; &lt;a href="https://github.com/HassanYosuf/ChatUp" rel="noopener noreferrer"&gt;HassanYosuf/ChatUp&lt;/a&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  What is ChatUp?
&lt;/h2&gt;

&lt;p&gt;Before adding AI, I built ChatUp as a robust, real-time messaging backend. The goal was to engineer a system capable of low-latency, bi-directional communication and real-time state synchronization. &lt;/p&gt;

&lt;p&gt;Under the hood, it is powered by an event-driven architecture using Spring Boot and WebSocket/STOMP. The frontend is highly responsive, built entirely with HTML5, CSS3, and ES6+ JavaScript, utilizing SockJS for reliable WebSocket fallback and cross-browser compatibility. To ensure the application is easily deployable and scalable, the entire system is containerized with Docker and hosted on the Render cloud.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Core Architecture of the AI Integration
&lt;/h2&gt;

&lt;p&gt;To keep the application highly maintainable, ChatUp utilizes a modular MVC architecture. When it came time to introduce AI capabilities, my primary architectural constraint was strict: &lt;strong&gt;the AI integration could not disrupt or add latency to the core human-to-human message flow&lt;/strong&gt;. &lt;/p&gt;

&lt;h3&gt;
  
  
  How It Works: Intercepting the Stream
&lt;/h3&gt;

&lt;p&gt;Instead of building a separate "bot chat" interface, I wanted the assistant to live directly inside the existing multi-user chat rooms. &lt;/p&gt;

&lt;p&gt;Here is the event flow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The Trigger:&lt;/strong&gt; The application monitors the WebSocket stream and intercepts any messages prefixed with &lt;code&gt;@ai&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Routing:&lt;/strong&gt; Once detected, the message is decoupled from the standard chat flow and routed to a dedicated AI service layer. &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Brains:&lt;/strong&gt; This service layer processes the message and handles the external call to the Groq API (running the LLaMA 3.3 model). &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Broadcast:&lt;/strong&gt; Once the LLM generates a response, the Spring Boot service broadcasts the AI's reply in real time back to all subscribers in that specific chat room. &lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Frontend Handling
&lt;/h3&gt;

&lt;p&gt;On the client side, I wanted to ensure the user experience remained intuitive. I added distinct UI rendering logic to the JavaScript. AI-generated messages are styled differently from standard user messages, making it immediately clear when the LLM is speaking to the room versus a human participant. &lt;/p&gt;




&lt;h2&gt;
  
  
  Swapping the Brain: Alternative APIs
&lt;/h2&gt;

&lt;p&gt;One of the biggest advantages of decoupling the AI logic into a dedicated service layer is that you aren't locked into a single provider. While I used Groq for its incredibly low latency with LLaMA 3.3, this architecture makes it trivial to swap in other LLM APIs by simply changing the endpoint and payload structure in the service class.&lt;/p&gt;

&lt;p&gt;If you are looking to build something similar, here are a few other APIs that fit perfectly into this pattern:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Anthropic Claude API:&lt;/strong&gt; If your chat rooms require complex reasoning, coding assistance, or handling large contexts (like summarizing a long chat history), Claude is an excellent alternative. It is highly capable and relatively easy to integrate into a Spring Boot pipeline.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;OpenAI API (GPT-4o-mini):&lt;/strong&gt; The industry standard. It's incredibly reliable, well-documented, and the &lt;code&gt;-mini&lt;/code&gt; model is fast and cost-effective for high-volume, real-time chat environments.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Local Models via Ollama:&lt;/strong&gt; If data privacy is a strict constraint or you want to run the system entirely on-premise without API costs, you can point your Spring Boot service to a local Ollama instance running open-weights models. The latency will depend entirely on your hardware, but the integration pattern remains exactly the same.&lt;/li&gt;
&lt;/ul&gt;




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

&lt;p&gt;Integrating an LLM via the Groq API into a live STOMP/WebSocket pipeline was a fantastic exercise in decoupling services. By isolating the AI routing into its own layer, the app successfully maintains high-performance real-time state sync for normal chats while offering powerful generative AI capabilities on demand.&lt;/p&gt;

&lt;p&gt;If you are working with Spring Boot WebSockets or integrating LLMs into event-driven systems, feel free to check out the repo or drop a comment below!&lt;/p&gt;

</description>
      <category>ai</category>
      <category>llm</category>
      <category>springboot</category>
      <category>websocket</category>
    </item>
    <item>
      <title>MVC (Model-View-Controller)</title>
      <dc:creator>Hassan Yosuf</dc:creator>
      <pubDate>Thu, 05 May 2022 16:30:08 +0000</pubDate>
      <link>https://dev.to/hassanyosuf/mvc-model-view-controller-55hk</link>
      <guid>https://dev.to/hassanyosuf/mvc-model-view-controller-55hk</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction:&lt;/strong&gt;&lt;br&gt;
The Model-View-Controller (MVC) is an architectural pattern that separates an application into three main logical components: the model, the view, and the controller. Each of these components is built to handle specific development aspects of an application. MVC is one of the most frequently used industry-standard web development frameworks to create scalable and extensible projects.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MVC Architecture:&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Model:&lt;/strong&gt;&lt;br&gt;
The Model component corresponds to all the data-related logic that the user works with. This can represent either the data that is being transferred between the View and Controller components or any other business logic-related data. For example, a Customer object will retrieve the customer information from the database, manipulate it and update it data back to the database or use it to render data.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;View:&lt;/strong&gt;&lt;br&gt;
The View component is used for all the UI logic of the application. For example, the Customer view will include all the UI components such as text boxes, dropdowns, etc. that the final user interacts with.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Controller:&lt;/strong&gt; &lt;br&gt;
Controllers act as an interface between Model and View components to process all the business logic and incoming requests, manipulate data using the Model component and interact with the Views to render the final output. For example, the Customer controller will handle all the interactions and inputs from the Customer View and update the database using the Customer Model. The same controller will be used to view the Customer data.&lt;/p&gt;

&lt;p&gt;In Java Programming, the Model contains the simple Java classes, the View used to display the data and the Controller contains the servlets. Due to this separation, the user requests are processed as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A client (browser) sends a request to the controller on the server-side, for a page.&lt;/li&gt;
&lt;li&gt;The controller then calls the model. It gathers the requested data.&lt;/li&gt;
&lt;li&gt;Then the controller transfers the data retrieved to the view layer.&lt;/li&gt;
&lt;li&gt;Now the result is sent back to the browser (client) by the view.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Advantages of MVC Architecture:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Faster Development Process&lt;/li&gt;
&lt;li&gt;Ability To Provide Multiple Views&lt;/li&gt;
&lt;li&gt;The Modification Does Not Affect The Entire Model&lt;/li&gt;
&lt;li&gt;MVC Model Returns The Data Without Formatting&lt;/li&gt;
&lt;li&gt;SEO Friendly Development Platform&lt;/li&gt;
&lt;li&gt;MVC has the feature of scalability that in turn helps the growth of the application.&lt;/li&gt;
&lt;li&gt;The components are easy to maintain because there is less dependency.&lt;/li&gt;
&lt;li&gt;A model can be reused by multiple views that provide the reusability of code.&lt;/li&gt;
&lt;li&gt;The developers can work with the three layers (Model, View, and Controller) simultaneously.&lt;/li&gt;
&lt;li&gt;Using MVC, each layer is maintained separately therefore we do not require to deal with massive code.&lt;/li&gt;
&lt;li&gt;The extending and testing of applications is easier.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Disadvantages of MVC Architecture:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Complexity&lt;/li&gt;
&lt;li&gt;Cost of Frequent Updates&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;MVC on the Web-based Applications&lt;/strong&gt;&lt;br&gt;
As a web developer, this pattern will probably be quite familiar even if you've never consciously used it before. Your data model is probably contained in some kind of database.Your app's controlling code is probably written in HTML/JavaScript, and your user interface is probably written using HTML/CSS/whatever else you like. This sounds very much like MVC, but MVC makes these components follow a more rigid pattern.&lt;br&gt;
In the early days of the Web, MVC architecture was mostly implemented on the server-side, with the client requesting updates via forms or links, and receiving updated views back to display in the browser. However, these days, more of the logic is pushed to the client with the advent of client-side data stores, and &lt;code&gt;XMLHttpRequest&lt;/code&gt; allowing partial page updates as required.&lt;br&gt;
Web frameworks such as Spring MVC, AngularJS, and React.js all implement an MVC architecture.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;MVC Flow Diagram:&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;&lt;strong&gt;Flow Steps&lt;/strong&gt;&lt;br&gt;
Step 1 − The client browser sends requests to the MVC Application.&lt;br&gt;
Step 2 − Global receives this request and performs routing based on the URL &lt;br&gt;
Step 3 − This routing operation calls the appropriate controller and executes it &lt;br&gt;
Step 4 − The Controller processes the data using the Model and invokes the appropriate method &lt;br&gt;
Step 5 − The processed Model is then passed to the View, which in turn renders the final output.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The MVC pattern has many advantages by separation of input logic, business logic and UI logic and on the other hand it also increases the development speed, easy to understand and test the bugs and error. It completely segregates the different layers of software architecture such as the Model Layer, View Layer, and Controller Layer.&lt;br&gt;
It increases the readability of the code but on the other hand, it has some drawbacks such as framework navigation can be complex because it introduces new layers of abstraction and requires users to adapt to the decomposition criteria of MVC. and Knowledge on multiple technologies becomes the norm. Developers using MVC need to be skilled in multiple technologies.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>java</category>
      <category>design</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
