<?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 Aditya Gavali on Medium]]></title>
        <description><![CDATA[Stories by Aditya Gavali on Medium]]></description>
        <link>https://medium.com/@adityagavali0911?source=rss-8eee67f91079------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*xq0DryYpjvPfI1E5</url>
            <title>Stories by Aditya Gavali on Medium</title>
            <link>https://medium.com/@adityagavali0911?source=rss-8eee67f91079------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 21:40:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@adityagavali0911/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[From MERN Stack to Microservices: Built a Hospital Management System and Here’s What I Learned]]></title>
            <link>https://medium.com/@adityagavali0911/where-i-started-75687b897dd5?source=rss-8eee67f91079------2</link>
            <guid isPermaLink="false">https://medium.com/p/75687b897dd5</guid>
            <category><![CDATA[micoservices]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[rabbitmq]]></category>
            <category><![CDATA[mern-stack]]></category>
            <dc:creator><![CDATA[Aditya Gavali]]></dc:creator>
            <pubDate>Fri, 03 Apr 2026 07:35:45 GMT</pubDate>
            <atom:updated>2026-04-03T08:53:34.351Z</atom:updated>
            <content:encoded><![CDATA[<p>I specialize in backend development with the MERN stack — Node.js, Express, MongoDB, Next.js. I knew how to build production APIs, structure databases, and handle server-side logic. What I did not know was how to think beyond a single server.</p><p>Two weeks ago microservices, Docker, and RabbitMQ were just buzzwords I nodded along to in conversations. I had zero hands-on experience with any of them.</p><p>So I decided to stop nodding and start building.</p><p>The result is <strong>MediCore</strong> — a hospital management backend built entirely with microservices architecture. This post is about what I built, why each piece exists, and what actually surprised me along the way.</p><p><strong>GitHub:</strong> <a href="https://github.com/Adityanpx/medicore">https://github.com/Adityanpx/medicore</a></p><h3>What is wrong with the monolith I was building before?</h3><p>Nothing — until it grows.</p><p>In a typical MERN app everything lives together. One Express server, one MongoDB database, all routes in one codebase. This is totally fine when you start.</p><p>But imagine your hospital app gets big. Your appointment booking feature starts getting massive traffic. You want to scale just that part — you cannot. You have to scale the entire application.</p><p>Or imagine your billing code has a bug and crashes the server. Now doctors cannot log in, patients cannot book appointments, nothing works — because everything lives together.</p><p>Or your team grows to 10 developers all pushing to the same codebase. Chaos.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8NCW_6VUKTreTw-sM4itVQ.png" /></figure><p>Microservices fixes this by splitting the app into small independent services. Each does one job. Each has its own database. Each can be deployed and scaled on its own. If billing crashes, everything else keeps working.</p><h3>What I built — MediCore</h3><p><strong>Six independent services, each a completely separate Node.js + Express application:</strong></p><p><strong>API Gateway</strong> — Single entry point. Routes all requests to the right service. The only port your frontend ever talks to.</p><p><strong>Auth Service</strong> — Registration, login, JWT token management. Every other service calls this to verify tokens.</p><p><strong>Patient Service</strong> — Patient profiles, medical history, blood group, emergency contacts.</p><p><strong>Doctor Service</strong> — Doctor profiles, specializations, qualifications, availability slots.</p><p><strong>Appointment Service</strong> — Book, cancel, and complete appointments. The most complex service — talks to three others.</p><p><strong>Billing Service</strong> — Never called directly. Automatically generates bills when an appointment completes via RabbitMQ.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KoErYTGPpWE5sJgTrRinHw.png" /></figure><p>Each service runs on its own port and connects to its own MongoDB database. Nothing is shared between them.</p><h3>Why an API Gateway?</h3><p>Without it, your frontend would need to know about six different services running on six different ports. That is a mess.</p><p>The API Gateway is the single door into the system. Frontend calls one URL. Gateway looks at the path and forwards the request to the right service. Simple and clean — the frontend never needs to know how many services exist behind it.</p><h3>How services talk to each other — Two ways</h3><p><strong>Way 1: Direct HTTP calls</strong></p><p>When a patient books an appointment, appointment-service needs to know — does this patient exist? Does this doctor exist? Is the doctor available that day?</p><p>So appointment-service directly calls patient-service and doctor-service over HTTP and waits for the answers before proceeding.</p><p>One smart thing I did here: instead of calling patient-service first and then doctor-service one after the other, both calls happen simultaneously using Promise.all(). Cut the waiting time in half.</p><p><strong>Way 2: RabbitMQ Message Queue</strong></p><p>When a doctor marks an appointment as complete, a bill needs to be generated. But should appointment-service directly call billing-service and wait?</p><p>No. The doctor should not wait for billing to finish before getting a success response. And if billing-service is temporarily down, the appointment completion should not fail because of it.</p><p>So instead, appointment-service publishes a message to RabbitMQ — “appointment completed, here is the data” — and immediately returns success to the doctor. Billing-service is running in the background listening for exactly this kind of message. When it receives one, it automatically generates the bill.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xsRFgSwr5r0I_6AdO5gkkw.png" /></figure><p>The beautiful part: appointment-service has no idea billing-service exists. Zero direct connection. If tomorrow I want to add a notification service that sends SMS on appointment completion, I just add another listener. I never touch appointment-service at all.</p><h3>The thing that broke my brain — No database joins</h3><p>In a monolith when you need patient data inside an appointment, you join the collections. Simple.</p><p>In microservices each service owns its database. appointment-service cannot touch the patients database. So every time an appointment is fetched, do I call patient-service just to get the patient name?</p><p>That would mean extra HTTP calls on every single read. Too slow.</p><p>The solution is storing a snapshot of the data at booking time. When the appointment is created, I store the patient name and doctor name directly inside the appointment document. Yes the data is duplicated. Yes that is intentional. It is called <strong>denormalization</strong> and it is the correct pattern here.</p><p>It felt wrong coming from a monolith background. Now it makes complete sense.</p><h3>Circuit Breaker — The pattern that impressed me most</h3><p>Every service calls auth-service to verify JWT tokens. What happens if auth-service goes down?</p><p>Without protection: every request to every service hangs, waiting for auth-service to respond. After 30 seconds each times out. 100 simultaneous requests means 100 threads all stuck. The healthy service runs out of memory and crashes too. One failure became five failures.</p><p>The Circuit Breaker pattern fixes this. It works exactly like the fuse box in your house.</p><p>After 3 consecutive failures to reach auth-service, the circuit opens. Now instead of making the actual HTTP call and waiting, it immediately returns — “auth service temporarily unavailable, try again in 30 seconds.” No waiting. Instant response. Healthy services stay healthy.</p><p>After 30 seconds the circuit tests recovery with one request. If auth-service is back — circuit closes, everything goes back to normal. If still down — circuit opens again for another 30 seconds.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z8Tf5Ew_s7JBmmPP50I27w.png" /></figure><p>I used the opossum library. Every inter-service HTTP call in MediCore is wrapped with a circuit breaker.</p><h3>Distributed Tracing — How I debug across 6 services</h3><p>In a monolith debugging is easy — one log file.</p><p>In microservices one booking request touches six services. If something breaks, which service caused it?</p><p>The answer is Correlation IDs. When a request enters the system at the API Gateway, it gets a unique ID. That ID travels through HTTP headers when services call each other, and gets embedded in RabbitMQ messages for async operations too.</p><p>Every log entry in every service includes this ID. When something breaks I search for that one ID and see the complete story across all six services — which service handled it, in what order, how long each step took, and exactly where it failed.</p><p>I used Winston for structured JSON logging across all services.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pm4KtxDEUUpfte1NCWMtKw.png" /></figure><h3>Docker — Containerization</h3><p>Every service has a Dockerfile. A single docker-compose.yml at the root starts all six services together with one command.</p><p>This solves the classic “works on my machine” problem. Someone clones the repo, runs docker-compose up, and everything starts identically — no manual setup, no version mismatches.</p><h3>What surprised me</h3><p>Three things genuinely surprised me during this build.</p><p><strong>First</strong> — how clean the architecture feels once you stop fighting it. Keeping services small and focused makes each piece much easier to reason about and maintain.</p><p><strong>Second</strong> — the Circuit Breaker pattern. Proactively stopping calls to a failing service instead of letting the failure cascade feels almost obvious in hindsight. It is elegant.</p><p><strong>Third</strong> — data denormalization. Storing duplicate data on purpose feels like a crime coming from a SQL background. But in distributed systems it is often the right answer. This mental model shift is the biggest adjustment.</p><h3>What is next</h3><ul><li>React frontend to complete the full stack experience</li><li>Kubernetes for production orchestration</li><li>Notification service using the existing RabbitMQ setup — just add a new consumer, zero changes to existing services</li></ul><h3>The repo</h3><p>Everything is on GitHub — all six services, Dockerfiles, docker-compose, and a complete Postman collection to test every single endpoint from scratch.</p><p><strong>GitHub:</strong> <a href="https://github.com/Adityanpx/medicore">https://github.com/Adityanpx/medicore</a></p><p>If you are a MERN developer wondering what to learn next — microservices is a great answer. The first few days are confusing. After that the patterns start clicking and it becomes genuinely fun.</p><p>Drop any questions in the comments. Happy to go deeper on anything.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=75687b897dd5" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>