<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <channel>
    <title>Architecture on developwith — developer tips</title>
    <link>https://developwith.com/architecture/</link>
    <description>Recent content in Architecture on developwith — developer tips</description>
    <generator>Hugo</generator>
    <language>en-us</language>
    <atom:link href="https://developwith.com/architecture/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Billing Management Architecture</title>
      <link>https://developwith.com/architecture/billing-management-architecture/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://developwith.com/architecture/billing-management-architecture/</guid>
      <description>&lt;p&gt;Billing systems are mostly &lt;strong&gt;scheduling systems with a database attached&lt;/strong&gt;. Invoices run on cycle dates, usage rolls up every hour, dunning retries every N days, entitlements expire at midnight, and reconciliation compares ledgers nightly. Every one of those is a recurring job — which means the reliability of a billing stack is largely the reliability of its scheduler. This article walks a billing management architecture that treats recurring work as a first-class control plane, delivered via &lt;a href=&#34;https://recurrence.cloud/&#34;&gt;Recurrence Cloud&lt;/a&gt;.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Event-Driven Architecture</title>
      <link>https://developwith.com/architecture/event-driven/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://developwith.com/architecture/event-driven/</guid>
      <description>&lt;p&gt;Event-Driven Architecture (EDA) structures a system around the production, detection, and reaction to events. Services communicate by emitting events rather than calling each other directly.&lt;/p&gt;&#xA;&lt;h2 id=&#34;architecture&#34;&gt;Architecture&lt;/h2&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;┌──────────┐   event   ┌───────────┐   event   ┌──────────┐&#xA;│ Producer │──────────▶│  Message   │──────────▶│ Consumer │&#xA;│ Service  │           │  Broker    │           │ Service  │&#xA;└──────────┘           └─────┬─────┘           └──────────┘&#xA;                             │&#xA;                      ┌──────┼──────┐&#xA;                      │      │      │&#xA;                  ┌────▼─┐ ┌─▼──┐ ┌─▼────┐&#xA;                  │ Svc A│ │Svc B│ │ Svc C│&#xA;                  └──────┘ └────┘ └──────┘&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;core-concepts&#34;&gt;Core Concepts&lt;/h2&gt;&#xA;&lt;table&gt;&#xA;  &lt;thead&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;th&gt;Term&lt;/th&gt;&#xA;          &lt;th&gt;Definition&lt;/th&gt;&#xA;      &lt;/tr&gt;&#xA;  &lt;/thead&gt;&#xA;  &lt;tbody&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;&lt;strong&gt;Event&lt;/strong&gt;&lt;/td&gt;&#xA;          &lt;td&gt;A fact that happened (immutable, past tense)&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;&lt;strong&gt;Producer&lt;/strong&gt;&lt;/td&gt;&#xA;          &lt;td&gt;Service that emits events&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;&lt;strong&gt;Consumer&lt;/strong&gt;&lt;/td&gt;&#xA;          &lt;td&gt;Service that reacts to events&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;&lt;strong&gt;Broker&lt;/strong&gt;&lt;/td&gt;&#xA;          &lt;td&gt;Middleware that routes events (Kafka, RabbitMQ, SQS)&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;  &lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;h2 id=&#34;when-to-use&#34;&gt;When to Use&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Loose coupling&lt;/strong&gt; is a priority — producers don&amp;rsquo;t know about consumers&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Async workflows&lt;/strong&gt; — processing can happen at different speeds&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Fan-out&lt;/strong&gt; — one event triggers multiple independent reactions&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Audit trail&lt;/strong&gt; — events are a log of what happened and when&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;when-to-avoid&#34;&gt;When to Avoid&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;When you need &lt;strong&gt;strong consistency&lt;/strong&gt; (synchronous is simpler)&lt;/li&gt;&#xA;&lt;li&gt;When &lt;strong&gt;request-response&lt;/strong&gt; latency matters (events add delay)&lt;/li&gt;&#xA;&lt;li&gt;Small systems where &lt;strong&gt;direct calls&lt;/strong&gt; are sufficient&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;patterns&#34;&gt;Patterns&lt;/h2&gt;&#xA;&lt;h3 id=&#34;event-sourcing&#34;&gt;Event Sourcing&lt;/h3&gt;&#xA;&lt;p&gt;Store every state change as an event. Current state is derived by replaying events.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Layered Architecture</title>
      <link>https://developwith.com/architecture/layered-architecture/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://developwith.com/architecture/layered-architecture/</guid>
      <description>&lt;p&gt;Layered (or n-tier) architecture organizes an application into horizontal layers, each with a specific responsibility. It&amp;rsquo;s the most common architecture for enterprise applications.&lt;/p&gt;&#xA;&lt;h2 id=&#34;the-layers&#34;&gt;The Layers&lt;/h2&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;┌──────────────────────────┐&#xA;│  Presentation Layer       │  HTTP handlers, controllers, views&#xA;├──────────────────────────┤&#xA;│  Business Logic Layer     │  Domain models, services, rules&#xA;├──────────────────────────┤&#xA;│  Data Access Layer        │  Repositories, ORM, external APIs&#xA;└──────────────────────────┘&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;dependency-rule&#34;&gt;Dependency Rule&lt;/h3&gt;&#xA;&lt;p&gt;&lt;strong&gt;Dependencies point downward only.&lt;/strong&gt; The presentation layer depends on business logic; business logic depends on data access. Never the reverse.&lt;/p&gt;</description>
    </item>
    <item>
      <title>MCP Flow Architecture</title>
      <link>https://developwith.com/architecture/mcp-flow-architecture/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://developwith.com/architecture/mcp-flow-architecture/</guid>
      <description>&lt;p&gt;The &lt;a href=&#34;https://modelcontextprotocol.io&#34;&gt;Model Context Protocol&lt;/a&gt; (MCP) is an open standard — announced November 2024, built on JSON-RPC 2.0 — for connecting AI applications to tools, data, and prompts. It solves the N×M integration problem: instead of every AI host writing custom glue for every data source, each side speaks one protocol. Hosts implement the client half; you implement the server half.&lt;/p&gt;&#xA;&lt;p&gt;This article is a flows-and-diagrams tour: the components, the lifecycle of a connection, the tool-call loop, the reverse flows (sampling, elicitation), and the transports that carry the messages.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Microservices</title>
      <link>https://developwith.com/architecture/microservices/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://developwith.com/architecture/microservices/</guid>
      <description>&lt;p&gt;Microservices decompose an application into small, independently deployable services that communicate over well-defined APIs (REST, gRPC, or message queues).&lt;/p&gt;&#xA;&lt;h2 id=&#34;architecture&#34;&gt;Architecture&lt;/h2&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;┌──────────┐    ┌──────────┐    ┌──────────┐&#xA;│ User Svc │    │ Order Svc│    │ Pay Svc  │&#xA;│  ┌────┐  │    │  ┌────┐  │    │  ┌────┐  │&#xA;│  │DB  │  │    │  │DB  │  │    │  │DB  │  │&#xA;│  └────┘  │    │  └────┘  │    │  └────┘  │&#xA;└────┬─────┘    └────┬─────┘    └────┬─────┘&#xA;     │               │               │&#xA;     └───────────────┼───────────────┘&#xA;                     │&#xA;              ┌──────┴──────┐&#xA;              │ API Gateway │&#xA;              └──────┬──────┘&#xA;                     │&#xA;                  Clients&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;when-to-use&#34;&gt;When to Use&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Multiple teams&lt;/strong&gt; that need independent deploy cadences&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Independent scaling&lt;/strong&gt; — one service needs 10x the resources of others&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Fault isolation&lt;/strong&gt; — one service crash doesn&amp;rsquo;t take down everything&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Technology diversity&lt;/strong&gt; — different services can use different languages&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;when-to-avoid&#34;&gt;When to Avoid&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Small team&lt;/strong&gt; — operational overhead is too high&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Simple domain&lt;/strong&gt; — CRUD doesn&amp;rsquo;t need distributed complexity&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Tight consistency&lt;/strong&gt; requirements — distributed transactions are hard&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;key-decisions&#34;&gt;Key Decisions&lt;/h2&gt;&#xA;&lt;table&gt;&#xA;  &lt;thead&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;th&gt;Decision&lt;/th&gt;&#xA;          &lt;th&gt;Options&lt;/th&gt;&#xA;          &lt;th&gt;Trade-off&lt;/th&gt;&#xA;      &lt;/tr&gt;&#xA;  &lt;/thead&gt;&#xA;  &lt;tbody&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;&lt;strong&gt;Communication&lt;/strong&gt;&lt;/td&gt;&#xA;          &lt;td&gt;REST, gRPC, messaging&lt;/td&gt;&#xA;          &lt;td&gt;Sync vs. async coupling&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;&lt;strong&gt;Data&lt;/strong&gt;&lt;/td&gt;&#xA;          &lt;td&gt;Shared DB, DB per service&lt;/td&gt;&#xA;          &lt;td&gt;Consistency vs. autonomy&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;&lt;strong&gt;Discovery&lt;/strong&gt;&lt;/td&gt;&#xA;          &lt;td&gt;DNS, service mesh, registry&lt;/td&gt;&#xA;          &lt;td&gt;Simplicity vs. observability&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;      &lt;tr&gt;&#xA;          &lt;td&gt;&lt;strong&gt;Deployment&lt;/strong&gt;&lt;/td&gt;&#xA;          &lt;td&gt;Containers, serverless&lt;/td&gt;&#xA;          &lt;td&gt;Control vs. convenience&lt;/td&gt;&#xA;      &lt;/tr&gt;&#xA;  &lt;/tbody&gt;&#xA;&lt;/table&gt;&#xA;&lt;h2 id=&#34;challenges&#34;&gt;Challenges&lt;/h2&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;&lt;strong&gt;Distributed data&lt;/strong&gt; — no ACID across services; plan for eventual consistency&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Network failures&lt;/strong&gt; — design for retries, circuit breakers, timeouts&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Observability&lt;/strong&gt; — distributed tracing is essential (OpenTelemetry, Jaeger)&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Testing&lt;/strong&gt; — contract tests replace integration tests across service boundaries&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p class=&#34;next&#34;&gt;&lt;strong&gt;Next:&lt;/strong&gt; &lt;a href=&#34;https://developwith.com/architecture/event-driven/&#34;&gt;Event-Driven Architecture&lt;/a&gt;&lt;/p&gt;</description>
    </item>
    <item>
      <title>Phoenix LiveView Application Architecture</title>
      <link>https://developwith.com/architecture/phoenix-liveview-architecture/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://developwith.com/architecture/phoenix-liveview-architecture/</guid>
      <description>&lt;p&gt;Phoenix LiveView applications have a distinct architecture that differs from traditional request-response web apps. The server holds state, pushes diffs over WebSockets, and the browser is a thin rendering layer. Understanding how the pieces fit together is key to building maintainable LiveView apps.&lt;/p&gt;&#xA;&lt;h2 id=&#34;the-big-picture&#34;&gt;The big picture&lt;/h2&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;┌─────────────────────────────────────────────────────────────┐&#xA;│                        Browser                              │&#xA;│                                                             │&#xA;│  ┌─────────────────────────────────────────────────────┐   │&#xA;│  │  HEEx Template → minimal JS → renders DOM           │   │&#xA;│  │  phx-click, phx-submit, phx-change push events     │   │&#xA;│  │  receives diffs → patches DOM                        │   │&#xA;│  └──────────────────────┬──────────────────────────────┘   │&#xA;│                         │ WebSocket                         │&#xA;└─────────────────────────┼───────────────────────────────────┘&#xA;                          │&#xA;┌─────────────────────────┼───────────────────────────────────┐&#xA;│                     Phoenix Server                         │&#xA;│                         │                                   │&#xA;│  ┌──────────────────────▼──────────────────────────────┐   │&#xA;│  │                  Endpoint                            │   │&#xA;│  │  (Plug pipeline: parsers, session, CSRF, PubSub)     │   │&#xA;│  └──────────────────────┬──────────────────────────────┘   │&#xA;│                         │                                   │&#xA;│  ┌──────────────────────▼──────────────────────────────┐   │&#xA;│  │                  Router                              │   │&#xA;│  │  live &amp;#34;/posts&amp;#34;, PostLive.Index                       │   │&#xA;│  │  live &amp;#34;/posts/:id&amp;#34;, PostLive.Show                   │   │&#xA;│  │  live &amp;#34;/admin&amp;#34;, AdminLive.Dashboard                  │   │&#xA;│  └──────────┬──────────────────────────┬───────────────┘   │&#xA;│             │                          │                    │&#xA;│  ┌──────────▼──────────┐  ┌───────────▼───────────────┐   │&#xA;│  │   LiveView Module    │  │   Traditional Controller   │   │&#xA;│  │                      │  │   (for JSON API, etc.)     │   │&#xA;│  │  mount/3             │  └───────────┬───────────────┘   │&#xA;│  │  handle_params/3     │              │                   │&#xA;│  │  handle_event/3      │              │                   │&#xA;│  │  handle_info/2       │              │                   │&#xA;│  │  render/1            │              │                   │&#xA;│  └──────────┬──────────┘              │                   │&#xA;│             │                          │                    │&#xA;│             ▼                          ▼                    │&#xA;│  ┌─────────────────────────────────────────────────────┐   │&#xA;│  │              Context Modules                         │   │&#xA;│  │  (Blog, Accounts, Catalog — the public API)         │   │&#xA;│  │                                                      │   │&#xA;│  │  • list_posts/1      • create_post/1                │   │&#xA;│  │  • get_post!/1       • update_post/2                │   │&#xA;│  │  • subscribe/1       • delete_post/1                │   │&#xA;│  └──────────────────────┬──────────────────────────────┘   │&#xA;│                         │                                   │&#xA;│  ┌──────────────────────▼──────────────────────────────┐   │&#xA;│  │              Ecto (Schemas + Repo)                   │   │&#xA;│  │                                                      │   │&#xA;│  │  Schemas ──► Changesets ──► Queries ──► Repo        │   │&#xA;│  │  (Post)       (validation)  (SQL)      (database)    │   │&#xA;│  └──────────────────────────────────────────────────────┘   │&#xA;│                                                             │&#xA;│  ┌─────────────────────────────────────────────────────┐   │&#xA;│  │              Phoenix.PubSub                          │     │&#xA;│  │  (broadcasts events between processes)               │   │&#xA;│  └─────────────────────────────────────────────────────┘   │&#xA;│                                                             │&#xA;│  ┌─────────────────────────────────────────────────────┐   │&#xA;│  │              OTP Supervision Tree                    │   │&#xA;│  │  (Application supervisor manages all processes)      │   │&#xA;│  └─────────────────────────────────────────────────────┘   │&#xA;└─────────────────────────────────────────────────────────────┘&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;layer-by-layer&#34;&gt;Layer by layer&lt;/h2&gt;&#xA;&lt;h3 id=&#34;1-browser-layer&#34;&gt;1. Browser layer&lt;/h3&gt;&#xA;&lt;p&gt;LiveView renders HTML on the server and sends it to the browser. After the initial HTTP render, a WebSocket connection is established. Subsequent interactions send minimal events (&lt;code&gt;phx-click&lt;/code&gt;, &lt;code&gt;phx-submit&lt;/code&gt;, &lt;code&gt;phx-change&lt;/code&gt;) to the server and receive only DOM diffs back.&lt;/p&gt;</description>
    </item>
    <item>
      <title>Separation of Concerns</title>
      <link>https://developwith.com/architecture/separation-of-concerns/</link>
      <pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate>
      <guid>https://developwith.com/architecture/separation-of-concerns/</guid>
      <description>&lt;p&gt;Separation of Concerns (SoC) is the principle that a system should be divided into distinct sections, each addressing a separate concern. It&amp;rsquo;s the foundation of maintainable software.&lt;/p&gt;&#xA;&lt;h2 id=&#34;why-it-matters&#34;&gt;Why It Matters&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;Change isolation&lt;/strong&gt;: A change in one concern shouldn&amp;rsquo;t ripple across the system.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Testability&lt;/strong&gt;: Each concern can be tested independently.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Comprehension&lt;/strong&gt;: Developers can understand one concern without understanding everything.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;in-practice&#34;&gt;In Practice&lt;/h2&gt;&#xA;&lt;h3 id=&#34;horizontal-separation-layers&#34;&gt;Horizontal Separation (Layers)&lt;/h3&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;┌──────────────────────┐&#xA;│   Presentation       │  ← UI, HTTP handlers, CLI&#xA;├──────────────────────┤&#xA;│   Business Logic     │  ← Domain rules, workflows&#xA;├──────────────────────┤&#xA;│   Data Access        │  ← Database, external APIs&#xA;└──────────────────────┘&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h3 id=&#34;vertical-separation-bounded-contexts&#34;&gt;Vertical Separation (Bounded Contexts)&lt;/h3&gt;&#xA;&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;┌─────────┐  ┌─────────┐  ┌─────────┐&#xA;│ Orders  │  │ Billing │  │ Shipping│&#xA;│  ┌───┐  │  │  ┌───┐  │  │  ┌───┐  │&#xA;│  │UI │  │  │  │UI │  │  │  │UI │  │&#xA;│  ├───┤  │  │  ├───┤  │  │  ├───┤  │&#xA;│  │BL │  │  │  │BL │  │  │  │BL │  │&#xA;│  ├───┤  │  │  ├───┤  │  │  ├───┤  │&#xA;│  │DA │  │  │  │DA │  │  │  │DA │  │&#xA;│  └───┘  │  │  └───┘  │  │  └───┘  │&#xA;└─────────┘  └─────────┘  └─────────┘&#xA;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&#34;anti-patterns&#34;&gt;Anti-Patterns&lt;/h2&gt;&#xA;&lt;ul&gt;&#xA;&lt;li&gt;&lt;strong&gt;God object&lt;/strong&gt;: One class/module does everything.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Shotgun surgery&lt;/strong&gt;: A single change requires edits in many places.&lt;/li&gt;&#xA;&lt;li&gt;&lt;strong&gt;Leaky abstraction&lt;/strong&gt;: Business logic bleeds into the data layer or vice versa.&lt;/li&gt;&#xA;&lt;/ul&gt;&#xA;&lt;h2 id=&#34;rules-of-thumb&#34;&gt;Rules of Thumb&lt;/h2&gt;&#xA;&lt;ol&gt;&#xA;&lt;li&gt;If a class has more than one reason to change, split it.&lt;/li&gt;&#xA;&lt;li&gt;If a function does I/O and computation, separate them.&lt;/li&gt;&#xA;&lt;li&gt;If a module imports from every other module, it&amp;rsquo;s a concern magnet — refactor.&lt;/li&gt;&#xA;&lt;/ol&gt;&#xA;&lt;p class=&#34;next&#34;&gt;&lt;strong&gt;Next:&lt;/strong&gt; &lt;a href=&#34;https://developwith.com/architecture/layered-architecture/&#34;&gt;Layered Architecture&lt;/a&gt;&lt;/p&gt;</description>
    </item>
  </channel>
</rss>
