<?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: Swati Rawat</title>
    <description>The latest articles on DEV Community by Swati Rawat (@swati-rawat).</description>
    <link>https://dev.to/swati-rawat</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4199694%2F150a6b95-8ac0-4708-89f2-96e331399490.png</url>
      <title>DEV Community: Swati Rawat</title>
      <link>https://dev.to/swati-rawat</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/swati-rawat"/>
    <language>en</language>
    <item>
      <title>Building Reliable Mobile-to-ERP Integrations for Enterprise Workflows</title>
      <dc:creator>Swati Rawat</dc:creator>
      <pubDate>Thu, 12 Nov 2026 13:18:34 +0000</pubDate>
      <link>https://dev.to/swati-rawat/building-reliable-mobile-to-erp-integrations-for-enterprise-workflows-kjm</link>
      <guid>https://dev.to/swati-rawat/building-reliable-mobile-to-erp-integrations-for-enterprise-workflows-kjm</guid>
      <description>&lt;p&gt;A field-service app can appear reliable during demos and still fail the moment two people edit the same work order. A technician changes a maintenance status on a train with no signal. Meanwhile, a dispatcher updates the scheduled task at headquarters. When the phone reconnects, which value wins?&lt;/p&gt;

&lt;p&gt;If the answer is simply “the most recent update,” the system may overwrite a legitimate decision. Offline-first enterprise mobile development needs a protocol for ownership, versioning, retries and reconciliation, not just a local database.&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F8z5ujrfzebd49mo0jb4q.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F8z5ujrfzebd49mo0jb4q.png" alt=" " width="800" height="364"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Start with server-owned records and versioned writes
&lt;/h2&gt;

&lt;p&gt;Imagine an illustrative maintenance app. The ERP owns the official work order, while the mobile client holds a permitted local cache and a queue of proposed changes. The local database is not the enterprise system of record.&lt;/p&gt;

&lt;p&gt;Each queued operation should contain a stable operation ID, entity ID, field-level changes, base server version, local creation time, and a device or actor reference. Avoid putting credentials or sensitive employee details into diagnostic events.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nc"&gt;PendingChange&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;operationId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;workOrderId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;baseVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;patch&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Record&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;unknown&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;createdAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Illustrative contract; server must authorize and validate each patch.&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;submitChange&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;change&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;PendingChange&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'/work-orders/changes'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;change&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The server first authenticates the request, checks permissions, and rejects stale or invalid operations. Idempotency prevents a retry from applying the same operation twice. A successful API response does not guarantee that the ERP has processed the update, so the application must define what “accepted,” “applied,” and “confirmed” mean.&lt;/p&gt;

&lt;h2&gt;
  
  
  Do not treat every conflict the same way
&lt;/h2&gt;

&lt;p&gt;Some data can merge safely. Two technicians adding separate inspection photos might create independent append-only events. Two users assigning the same technician to incompatible jobs cannot be merged automatically. Updating a regulatory inspection result may require supervisor review rather than choosing whichever client timestamp is later.&lt;/p&gt;

&lt;p&gt;A sensible protocol can use three outcomes: accepted, rejected with reason, or needs reconciliation. For the last case, preserve both versions and let the authorized person decide. The phone should make the conflict visible without pretending one edit never happened.&lt;/p&gt;

&lt;h2&gt;
  
  
  Design the retry path
&lt;/h2&gt;

&lt;p&gt;Connections will fail after requests arrive but before responses return. Therefore, the client should retry using the same operation ID, with bounded backoff. The server should record that ID and return the earlier outcome on duplicate submission.&lt;/p&gt;

&lt;p&gt;Do not rely on local timestamps to determine authoritative ordering: clocks can drift or be manipulated. Use server-side versions and a consistent data ownership policy. If the user's access has been revoked while offline, cached data must be governed by the organization's device and app protection policies, and the server must reject later unauthorized synchronization.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test the uncomfortable cases
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;Capture a work-order update with airplane mode enabled; confirm the app labels it as pending rather than submitted.&lt;/li&gt;
&lt;li&gt;Change the same record in the ERP; reconnect the phone and verify that the conflict is exposed.&lt;/li&gt;
&lt;li&gt;Submit the same operation ID twice; confirm it cannot cause duplicate writes.&lt;/li&gt;
&lt;li&gt;Revoke a user's access; verify that the backend rejects synchronization and the device policy takes effect as designed.&lt;/li&gt;
&lt;li&gt;Simulate an ERP outage after the gateway accepts a request; verify that status is not incorrectly displayed as completed.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Treat these as release acceptance tests rather than a demonstration script.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where the architecture discussion goes next
&lt;/h2&gt;

&lt;p&gt;An enterprise phone application involves far more than a mobile UI: API gateways, systems of record, identity propagation, monitoring and rollback all shape whether offline work is trustworthy. For a broader architecture and procurement perspective, see enterprise mobile app architecture, costs and implementation  .&lt;/p&gt;

&lt;p&gt;For production security evaluation, &lt;a href="https://mas.owasp.org/MASVS/" rel="noopener noreferrer"&gt;OWASP MASVS&lt;/a&gt; is a useful reference for mobile storage, authentication and network controls.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bottom line:&lt;/strong&gt; the sync algorithm is only as good as its explicit conflict policy. When business data matters, “it eventually uploads” is not a sufficient acceptance criterion.&lt;/p&gt;

&lt;h2&gt;
  
  
  Represent pending work as commands with identity
&lt;/h2&gt;

&lt;p&gt;A mobile application that edits a work order offline should not pretend it has updated the authoritative ERP record. Store a durable command containing an operation ID, work-order ID, expected version, intended change, and creation metadata. This separates the user’s intention from the server’s acceptance. The client can tell the technician that the operation is queued while the backend later decides whether the request remains valid.&lt;/p&gt;

&lt;p&gt;The operation ID is particularly important when connections fail. A timeout does not prove that the ERP rejected the change. If the same operation is retried with a new identifier, the server may process it twice. Persisting a stable ID across restarts allows a backend to reject duplicates or return the known outcome. The implementation must also enforce that an identifier is never reused for a different payload.&lt;/p&gt;

&lt;p&gt;Actual ERP capabilities matter. Some systems support caller-provided idempotency keys; others require a reconciliation lookup through a transaction reference. In systems without reliable deduplication interfaces, the integration design needs an explicit exception-handling plan rather than a blanket “retry until success” rule.&lt;/p&gt;

&lt;h2&gt;
  
  
  Separate network success from business acceptance
&lt;/h2&gt;

&lt;p&gt;An HTTP 202 response can mean a backend accepted a command for processing, not that the ERP applied the business change. The mobile UI must convey that distinction. Consider a state machine with QUEUED, SUBMITTED, CONFIRMED, CONFLICT, and NEEDS_REVIEW. A queued command can survive an app restart. A submitted command remains pending until the authoritative operation is reconciled.&lt;/p&gt;

&lt;p&gt;If an ERP adapter receives an ambiguous timeout after submitting an inspection, the correct immediate response may be to mark the command UNKNOWN and investigate through an approved status lookup. Simply treating timeouts as failures can trigger duplicates; treating them as successes can silently lose work. A durable outbox and correlation ID can help support teams reconstruct what happened across the mobile backend and integration layer.&lt;/p&gt;

&lt;p&gt;Observability should report business-state measures such as median time to authoritative confirmation, oldest outstanding command, and number of unresolved conflicts. A healthy API success percentage can conceal a growing backlog of work orders that never completed.&lt;/p&gt;

&lt;h2&gt;
  
  
  Protect the authorization boundary after reconnect
&lt;/h2&gt;

&lt;p&gt;A technician may have been authorized to edit a job when it was downloaded, but that does not mean the same permission still applies days later. Backend services should verify current object-level permissions when a queued write arrives, as required by the organization’s policy. Locally cached UI roles should never be accepted as the source of authority.&lt;/p&gt;

&lt;p&gt;For a practical acceptance test, download work-order data, disconnect the device, revoke the technician’s access centrally, and then reconnect. Verify that the server blocks unauthorized changes, that the app displays an understandable outcome, and that any retained local data follows the relevant expiry or removal policy. A local “saved” status must not imply permission to commit that change indefinitely.&lt;/p&gt;

&lt;p&gt;The OWASP Mobile Application Security Verification Standard is a useful starting point for evaluating storage, authentication, network security, and privacy controls, but the final tests must reflect actual enterprise data and workflows.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Should mobile apps connect straight to ERP databases?
&lt;/h3&gt;

&lt;p&gt;A controlled API or integration service is generally safer and easier to maintain because it can enforce authorization, validation, business rules, and versioned contracts.&lt;/p&gt;

&lt;h3&gt;
  
  
  What does an idempotency key solve?
&lt;/h3&gt;

&lt;p&gt;It helps the server recognize retried logical operations so they do not create duplicate business effects. The backend must enforce uniqueness and verify the repeated payload.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is last-write-wins safe for offline conflicts?
&lt;/h3&gt;

&lt;p&gt;Only for selected low-risk data. Assignment, approval, inventory, and other consequential fields may need version checks or explicit review.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can a queued offline action bypass a revoked role?
&lt;/h3&gt;

&lt;p&gt;It should not. The backend should apply current authorization according to the organization’s policy when the operation reconnects.&lt;/p&gt;

&lt;h3&gt;
  
  
  What metrics reveal hidden integration failures?
&lt;/h3&gt;

&lt;p&gt;Queue age, time to authoritative confirmation, unresolved conflicts, rejected commands, duplicate suppression, and ERP timeouts expose issues that ordinary HTTP status metrics may miss.&lt;/p&gt;

&lt;p&gt;For a broader treatment of system integrations, offline operations, security, and budgets, see the &lt;a href="https://toadster.ai/blogs/enterprise-mobile-app-development-architecture-costs-and-implementation-guide" rel="noopener noreferrer"&gt;enterprise mobile app development implementation guide&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>backend</category>
      <category>mobile</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>Building an Auditable AI Compliance Workflow: Architecture, Permissions and Human Approvals</title>
      <dc:creator>Swati Rawat</dc:creator>
      <pubDate>Wed, 04 Nov 2026 09:36:59 +0000</pubDate>
      <link>https://dev.to/swati-rawat/building-an-auditable-ai-compliance-workflow-architecture-permissions-and-human-approvals-1eoa</link>
      <guid>https://dev.to/swati-rawat/building-an-auditable-ai-compliance-workflow-architecture-permissions-and-human-approvals-1eoa</guid>
      <description>&lt;p&gt;An AI service extracts a potential obligation from a regulatory update and returns a high-confidence response. What should your application do next?&lt;/p&gt;

&lt;p&gt;It should &lt;strong&gt;not&lt;/strong&gt; turn that score into an approved legal interpretation or a production control change. The model proposes information; trusted services validate it; an authorized human decides applicability; and the system preserves evidence of what happened.&lt;/p&gt;

&lt;p&gt;This post describes a concrete TypeScript-oriented architecture for that separation. It is intentionally a conceptual reference, not production-certified compliance software.&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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmobwtw16hev873jl6dbj.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fmobwtw16hev873jl6dbj.png" alt="sample img" width="800" height="364"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Draw trust boundaries before writing the prompt
&lt;/h2&gt;

&lt;p&gt;A regulatory change workflow can have six stages:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Fetch a notice from an approved regulatory source and preserve source metadata.&lt;/li&gt;
&lt;li&gt;Store the original document and its immutable identifier.&lt;/li&gt;
&lt;li&gt;Ask an AI service to propose candidate obligations with source passages.&lt;/li&gt;
&lt;li&gt;Validate the response and verify that cited passages exist.&lt;/li&gt;
&lt;li&gt;Present the proposal to a user authorized to decide applicability.&lt;/li&gt;
&lt;li&gt;Map approved obligations to controls, changes, tests and audit evidence.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The model must never be the only component able to change a case from &lt;em&gt;proposed&lt;/em&gt; to &lt;em&gt;approved&lt;/em&gt;. A model's self-reported confidence is not an authorization decision.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Use explicit workflow states
&lt;/h2&gt;

&lt;p&gt;Do not replace an auditable process with one boolean called &lt;code&gt;isCompliant&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;CaseStatus&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;RECEIVED&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;ANALYSIS_PENDING&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;AWAITING_REVIEW&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;APPROVED_FOR_MAPPING&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;REJECTED&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;IMPLEMENTATION_PENDING&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;VERIFICATION_PENDING&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;
  &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;CLOSED&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Design which actors and services are allowed to trigger each transition. For example, an AI analysis service can propose a case for review, but it cannot approve its own interpretation.&lt;/p&gt;

&lt;p&gt;Record a version number with the case to prevent stale reviewers from overwriting a newer decision.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Validate output like any other untrusted payload
&lt;/h2&gt;

&lt;p&gt;Suppose the model produces a proposed obligation:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="kd"&gt;type&lt;/span&gt; &lt;span class="nx"&gt;CandidateObligation&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;sourceDocumentId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;sourceQuote&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;summary&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;productArea&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;confidence&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;low&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;medium&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;|&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;high&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A valid JSON shape is only the beginning. Check whether the source document actually exists, whether the quoted text occurs in it, whether the product area is a recognized identifier, and whether the fields satisfy content restrictions. The string &lt;code&gt;confidence: 'high'&lt;/code&gt; must not bypass those checks.&lt;/p&gt;

&lt;p&gt;A source passage is external data. Never execute instructions embedded in that passage as developer or system instructions.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Keep authorization in a trusted service
&lt;/h2&gt;

&lt;p&gt;The application should obtain identity and roles from an authenticated session, not from an LLM message or a caller-supplied role field.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Illustrative pseudocode: not a drop-in DB implementation.&lt;/span&gt;
&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;approveForMapping&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
  &lt;span class="nx"&gt;caseId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;AuthenticatedContext&lt;/span&gt;
&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;roles&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;COMPLIANCE_APPROVER&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;ForbiddenError&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;database&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;transaction&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;cases&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;findForUpdate&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;caseId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;tenantId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tenantId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;NotFoundError&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;AWAITING_REVIEW&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;InvalidTransitionError&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;updated&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;cases&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;id&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;tenantId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tenantId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;expectedVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;version&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;status&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;APPROVED_FOR_MAPPING&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;reviewerId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;

    &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;tx&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;audit&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;insert&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="nx"&gt;caseId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;tenantId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tenantId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;actorId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;auth&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;userId&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;action&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;APPROVED_FOR_MAPPING&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;sourceVersion&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;sourceVersion&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;occurredAt&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Date&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;toISOString&lt;/span&gt;&lt;span class="p"&gt;(),&lt;/span&gt;
    &lt;span class="p"&gt;});&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;updated&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The transaction is important: an approval and its required audit record should not disagree about whether the transition happened. In a distributed design, a transactional outbox may be more appropriate than attempting two independent remote writes.&lt;/p&gt;

&lt;p&gt;You still need authentication, appropriate separation of duties, database permissions, security testing and institution-specific controls.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Design audit events for investigation, not decoration
&lt;/h2&gt;

&lt;p&gt;A useful event can include the case identifier, tenant, authenticated actor, transition, source-document version, policy version, timestamp and correlation ID. AI-analysis events may also record the model configuration and relevant evidence references.&lt;/p&gt;

&lt;p&gt;Avoid copying raw credentials or all sensitive source content into general logs. Auditability requires deliberate access controls and retention, not unlimited data collection.&lt;/p&gt;

&lt;p&gt;For cases linked to compliance decisions, be able to trace:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;original source → model proposal → validated evidence → authorized review → control implementation → verification result&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A timestamp that says &lt;em&gt;AI succeeded&lt;/em&gt; is not sufficient.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Fail safely, including when dependencies fail
&lt;/h2&gt;

&lt;p&gt;Four cases deserve explicit tests:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Model timeout:&lt;/strong&gt; mark analysis incomplete and retry within an approved policy or route to manual review. Do not mark the case approved.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Unsupported citation:&lt;/strong&gt; reject the proposal or flag it for verification. Valid syntax cannot establish factual accuracy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Stale reviewer action:&lt;/strong&gt; require a matching case version or transactional lock, so a late click cannot reverse a more recent decision.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Audit write failure:&lt;/strong&gt; do not report a required approval as committed if its audit event is missing. Use an atomic transaction or another durable consistency pattern.&lt;/p&gt;

&lt;p&gt;If one system writes to a queue, use idempotency keys and retry-safe consumers to avoid duplicate control tasks.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Treat prompt injection as a permissions problem
&lt;/h2&gt;

&lt;p&gt;A legitimate-looking regulatory notice might contain attacker-controlled text. The retrieved document is evidence to analyze, not a source of new system instructions.&lt;/p&gt;

&lt;p&gt;Limit the model's tools, scope retrieval access, validate proposed actions and enforce permissions outside the model. Even a compromised response should not be able to issue account credentials, edit production configuration or close audit cases.&lt;/p&gt;

&lt;p&gt;For threat-modeling patterns, see the &lt;a href="https://genai.owasp.org/" rel="noopener noreferrer"&gt;OWASP GenAI Security Project&lt;/a&gt;. For risk governance, see the &lt;a href="https://www.nist.gov/itl/ai-risk-management-framework" rel="noopener noreferrer"&gt;NIST AI Risk Management Framework&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Test the control boundaries
&lt;/h2&gt;

&lt;p&gt;A useful first-pass test matrix includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Unauthorized users cannot approve cases.&lt;/li&gt;
&lt;li&gt;A user from tenant A cannot view or approve tenant B cases.&lt;/li&gt;
&lt;li&gt;Missing document evidence prevents automated completion.&lt;/li&gt;
&lt;li&gt;Duplicate approval requests do not create duplicate state changes.&lt;/li&gt;
&lt;li&gt;A stale reviewer action fails cleanly.&lt;/li&gt;
&lt;li&gt;A model timeout cannot produce an approved case.&lt;/li&gt;
&lt;li&gt;An audit failure prevents success confirmation.&lt;/li&gt;
&lt;li&gt;Source quotes are verified against the stored document.&lt;/li&gt;
&lt;li&gt;Prompt injection in a retrieved document cannot invoke privileged tools.&lt;/li&gt;
&lt;li&gt;A case cannot close without the necessary verification evidence.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These engineering tests show whether specified controls behave correctly. They do not establish that a product meets every applicable law.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Metrics that matter
&lt;/h2&gt;

&lt;p&gt;Measure both model quality and the workflow's real-world effect. Technical signals include citation verification, extraction correctness, schema rejection rate and latency. Operational measures include human review time, relevant changes missed in quality sampling, unresolved exceptions, overdue control tasks and evidence completeness.&lt;/p&gt;

&lt;p&gt;A faster extraction pipeline does not automatically mean a better compliance control.&lt;/p&gt;

&lt;p&gt;If a team is planning similar integrations in a financial product, a description of &lt;a href="https://toadster.ai/industries/fintech" rel="noopener noreferrer"&gt;fintech AI engineering and software integration capabilities&lt;/a&gt; provides context about the types of systems involved. The engineering patterns above remain independently useful and do not depend on any specific supplier.&lt;/p&gt;

&lt;h2&gt;
  
  
  FAQs
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Can an LLM decide whether a law applies to a business?
&lt;/h3&gt;

&lt;p&gt;It may assist with finding and summarizing candidate requirements. Qualified compliance and legal owners should validate material applicability decisions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Should every compliance workflow use agents?
&lt;/h3&gt;

&lt;p&gt;No. A deterministic state machine with narrow AI assistance is often easier to validate and govern than unnecessary autonomous orchestration.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is an audit log enough for audit readiness?
&lt;/h3&gt;

&lt;p&gt;No. A complete process may also need source evidence, approvals, verified control operation, retention and access restrictions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;The goal is not to make the language model &lt;em&gt;trustworthy enough to approve anything&lt;/em&gt;. It is to design the system so that its most important permissions and transitions are governed independently of model output. Strong trust boundaries make inevitable model and infrastructure failures controlled, reviewable events instead of silent compliance decisions.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>Why a Cheap SaaS Quote Can Hide the Most Important Work</title>
      <dc:creator>Swati Rawat</dc:creator>
      <pubDate>Tue, 27 Oct 2026 13:40:24 +0000</pubDate>
      <link>https://dev.to/swati-rawat/why-a-cheap-saas-quote-can-hide-the-most-important-work-2kjg</link>
      <guid>https://dev.to/swati-rawat/why-a-cheap-saas-quote-can-hide-the-most-important-work-2kjg</guid>
      <description>&lt;p&gt;A SaaS proposal can look attractive because the total sits on one line. The harder question is what that line buys. Two suppliers may quote the same product and be estimating different levels of security, billing logic, observability, or handover. &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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fstaa26h5xitvppd5utfp.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.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fstaa26h5xitvppd5utfp.png" alt=" " width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Normalize scope before price&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Start by writing one product boundary: supported workflows, user roles, customer organizations, subscription plans, integrations, and post-launch expectations. Put each proposal against that boundary. If one vendor excludes migration, QA, or deployment, its headline price is not comparable to a proposal that includes those tasks. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Turn omissions into explicit costs&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;A useful comparison has columns for included work, exclusions, acceptance criteria, owner of third-party subscriptions, warranty period, and support response model. A missing line is not automatically a problem. An unidentified missing line is. Ask each team to quote or estimate exclusions separately. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Illustrative engineering budget&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Consider a purely hypothetical SaaS build requiring 80 hours of discovery, 110 of design, 240 of frontend work, 320 of backend and tenant isolation, 140 of billing and integrations, 170 of QA and security checks, 90 of deployment and handover, and 90 of coordination. That is 1,240 role- &lt;/p&gt;

&lt;p&gt;hours. At an assumed blended $65/hour the calculation is $80,600. This is an example of transparent modeling, not an industry benchmark or an agency rate. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What the comparison should produce&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The output is not simply a cheaper choice. It is a comparable scope, a credible list of unknowns, and a decision about which uncertainty to buy down first. Sometimes that means paid discovery before a complete product commitment. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;A simple normalization exercise&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Imagine Proposal A includes implementation but leaves infrastructure provisioning, acceptance testing, and support as open items. Proposal B names these deliverables and has a higher headline estimate. Instead of asking which vendor is cheaper, create a normalized baseline and request the cost of missing work from each supplier. Add a risk column for items that cannot yet be estimated. The result might still favor Proposal A, but it will no longer depend on comparing incompatible promises. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;An acceptance test worth discussing&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;For a B2B product, require a test in which a signed-in member of Organization A attempts to access Organization B’s invoice, export, and background job result. The expected outcome is rejection, not merely a missing navigation link. Make this one sample of a broader authorization test plan. A proposal that says “secure authentication included” without specifying resource authorization has not answered the question. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Five procurement signals&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Look for explicit assumptions about tenant count and isolation; an inventory of integrations with ownership assigned; a test and deployment handover plan; incident and support responsibilities; and a change-control method that describes how estimates evolve. Those signals do not prove a supplier is good, but they give you concrete questions that can be answered before money changes hands. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Useful context and further reading&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;For more detail on scoping a subscription product, see the SaaS development cost guide. For the security and tenancy decisions behind that budget, review the &lt;a href="https://toadster.ai/blogs" rel="noopener noreferrer"&gt;multi-tenant SaaS architecture guide.&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Teams that need help defining scope or tenancy requirements can evaluate SaaS application &lt;u&gt;development services as one option when preparing a technical brief.&lt;/u&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Frequently asked questions&lt;/strong&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;Should I choose the lowest SaaS quote?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Only when scope, exclusions, security expectations, delivery responsibilities, and post-launch work are genuinely comparable. &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;What is the most important missing item?&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;It depends on the product, but tenant authorization, billing states, and operations are frequent areas worth checking. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to Enforce Module Boundaries Without Breaking a Monolith into Microservices</title>
      <dc:creator>Swati Rawat</dc:creator>
      <pubDate>Fri, 23 Oct 2026 10:49:12 +0000</pubDate>
      <link>https://dev.to/swati-rawat/how-to-enforce-module-boundaries-without-breaking-a-monolith-into-microservices-bba</link>
      <guid>https://dev.to/swati-rawat/how-to-enforce-module-boundaries-without-breaking-a-monolith-into-microservices-bba</guid>
      <description>&lt;p&gt;A monolith can have beautifully organized packages and still be a nightmare to maintain.&lt;/p&gt;

&lt;p&gt;You open the project and see folders called &lt;code&gt;orders&lt;/code&gt;, &lt;code&gt;billing&lt;/code&gt;, and &lt;code&gt;inventory&lt;/code&gt;. Everything looks neatly separated. But the moment you investigate the dependencies, the real picture emerges.&lt;/p&gt;

&lt;p&gt;Orders imports Inventory's internal repository. Billing relies on implementation details from Orders. A small change in one feature unexpectedly affects several others.&lt;/p&gt;

&lt;p&gt;The problem isn't necessarily that the application is a monolith.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The problem is that its module boundaries exist only in the folder structure, not in the architecture.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Moving to microservices will not automatically solve those dependencies. It may simply turn tightly coupled Java classes into tightly coupled network services.&lt;/p&gt;

&lt;p&gt;Before introducing distributed infrastructure, there's a simpler architectural improvement worth considering: enforcing module boundaries inside the existing application.&lt;/p&gt;

&lt;p&gt;In this tutorial, we'll explore how to do that using Java, Spring Boot, and Spring Modulith.&lt;/p&gt;

&lt;p&gt;The examples use a simplified commerce application. They demonstrate structural principles rather than a complete production inventory system.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Start by Defining What Each Module Owns
&lt;/h2&gt;

&lt;p&gt;Imagine an application with four business capabilities:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Orders:&lt;/strong&gt; Creates and manages customer purchases.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Inventory:&lt;/strong&gt; Maintains stock information and availability.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Billing:&lt;/strong&gt; Handles invoices and payment-related operations.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Notifications:&lt;/strong&gt; Delivers customer updates.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A starting package structure might look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;com.example.commerce
├── CommerceApplication.java
├── orders
│   ├── OrderService.java
│   └── internal
│       └── OrderRepository.java
├── inventory
│   ├── InventoryOperations.java
│   └── internal
│       ├── InventoryService.java
│       ├── StockRepository.java
│       └── InMemoryStockRepository.java
├── billing
│   └── BillingOperations.java
└── notifications
    └── NotificationOperations.java
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Under Spring Modulith's default module detection arrangement, the direct subpackages beneath the application root can represent application modules.&lt;/p&gt;

&lt;p&gt;The root package of a module forms its default exposed interface, while internal subpackages contain implementation details.&lt;/p&gt;

&lt;p&gt;This distinction matters.&lt;/p&gt;

&lt;p&gt;Other modules may need to ask Inventory whether enough stock is available. They shouldn't automatically gain access to Inventory's persistence implementation.&lt;/p&gt;

&lt;p&gt;Spring Modulith's &lt;a href="https://docs.spring.io/spring-modulith/reference/fundamentals.html" rel="noopener noreferrer"&gt;official module fundamentals&lt;/a&gt; describe how provided interfaces and internal implementation components are represented.&lt;/p&gt;

&lt;p&gt;The folder structure is the starting point. Enforcing which dependencies are allowed is the next step.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. The Problem: Accessing Another Module's Internals
&lt;/h2&gt;

&lt;p&gt;Consider an Orders service that imports an Inventory repository directly.&lt;/p&gt;

&lt;h3&gt;
  
  
  Before: A Boundary Violation
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kn"&gt;package&lt;/span&gt; &lt;span class="nn"&gt;com.example.commerce.orders&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;com.example.commerce.inventory.internal.StockRepository&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.springframework.stereotype.Service&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Deliberately incorrect architecture example.&lt;/span&gt;
&lt;span class="c1"&gt;// Assumes StockRepository is declared public.&lt;/span&gt;

&lt;span class="nd"&gt;@Service&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;OrderService&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="nc"&gt;StockRepository&lt;/span&gt; &lt;span class="n"&gt;stockRepository&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="nc"&gt;OrderService&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;StockRepository&lt;/span&gt; &lt;span class="n"&gt;stockRepository&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;stockRepository&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;stockRepository&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This example deliberately violates the intended boundary.&lt;/p&gt;

&lt;p&gt;It assumes &lt;code&gt;StockRepository&lt;/code&gt; is public, meaning Java can permit the import. But because the repository belongs to &lt;code&gt;inventory.internal&lt;/code&gt;, Orders has become dependent on Inventory's internal implementation.&lt;/p&gt;

&lt;p&gt;Spring Modulith's default module verification rejects this kind of cross-module access when the modules use the standard arrangement.&lt;/p&gt;

&lt;p&gt;If the repository were package-private instead, the Java compiler would reject the cross-package reference before architecture verification could run.&lt;/p&gt;

&lt;p&gt;The important lesson is that Java visibility and architectural module boundaries are related, but they are not identical.&lt;/p&gt;

&lt;p&gt;A class can be publicly accessible in Java while still being something other modules should not depend on.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Expose a Business Interface Instead
&lt;/h2&gt;

&lt;p&gt;The better approach is to expose a narrow operation through Inventory's public module interface.&lt;/p&gt;

&lt;p&gt;For this example, we'll implement an availability check.&lt;/p&gt;

&lt;h3&gt;
  
  
  File: &lt;code&gt;inventory/InventoryOperations.java&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kn"&gt;package&lt;/span&gt; &lt;span class="nn"&gt;com.example.commerce.inventory&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;InventoryOperations&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="nf"&gt;canReserve&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;sku&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;quantity&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This interface tells other modules what Inventory can do without exposing how Inventory stores its records.&lt;/p&gt;

&lt;p&gt;Next, define the internal repository abstraction.&lt;/p&gt;

&lt;h3&gt;
  
  
  File: &lt;code&gt;inventory/internal/StockRepository.java&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kn"&gt;package&lt;/span&gt; &lt;span class="nn"&gt;com.example.commerce.inventory.internal&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;StockRepository&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;availableQuantity&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;sku&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The repository is declared public here because it is an interface available to components within its own package and potentially other Java packages. Its location within &lt;code&gt;inventory.internal&lt;/code&gt; still signals that it is not part of Inventory's default Spring Modulith API.&lt;/p&gt;

&lt;p&gt;For production applications, teams may further restrict Java visibility according to their implementation needs.&lt;/p&gt;

&lt;h3&gt;
  
  
  File: &lt;code&gt;inventory/internal/InMemoryStockRepository.java&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kn"&gt;package&lt;/span&gt; &lt;span class="nn"&gt;com.example.commerce.inventory.internal&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;java.util.Map&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.springframework.stereotype.Repository&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="nd"&gt;@Repository&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;InMemoryStockRepository&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;StockRepository&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="nc"&gt;Map&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nc"&gt;Integer&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;stock&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt;
        &lt;span class="nc"&gt;Map&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;of&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"SKU-001"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;25&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;

    &lt;span class="nd"&gt;@Override&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;availableQuantity&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;sku&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;stock&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;getOrDefault&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sku&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This provides a simple Spring-managed implementation of the repository contract.&lt;/p&gt;

&lt;p&gt;It intentionally uses fixed sample data and does not provide real persistence or stock reservation functionality.&lt;/p&gt;

&lt;p&gt;Now add the business-facing implementation.&lt;/p&gt;

&lt;h3&gt;
  
  
  File: &lt;code&gt;inventory/internal/InventoryService.java&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kn"&gt;package&lt;/span&gt; &lt;span class="nn"&gt;com.example.commerce.inventory.internal&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;com.example.commerce.inventory.InventoryOperations&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.springframework.stereotype.Service&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="nd"&gt;@Service&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;InventoryService&lt;/span&gt; &lt;span class="kd"&gt;implements&lt;/span&gt; &lt;span class="nc"&gt;InventoryOperations&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="nc"&gt;StockRepository&lt;/span&gt; &lt;span class="n"&gt;repository&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="nc"&gt;InventoryService&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;StockRepository&lt;/span&gt; &lt;span class="n"&gt;repository&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;repository&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;repository&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="nd"&gt;@Override&lt;/span&gt;
    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="nf"&gt;canReserve&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;sku&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;quantity&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;quantity&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;IllegalArgumentException&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
                &lt;span class="s"&gt;"Quantity must be positive"&lt;/span&gt;
            &lt;span class="o"&gt;);&lt;/span&gt;
        &lt;span class="o"&gt;}&lt;/span&gt;

        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;repository&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;availableQuantity&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sku&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="n"&gt;quantity&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice what changed.&lt;/p&gt;

&lt;p&gt;The repository remains an internal dependency of Inventory. Other business modules do not need to know how the availability calculation obtains its data.&lt;/p&gt;

&lt;p&gt;The method is deliberately simplified: &lt;code&gt;canReserve()&lt;/code&gt; only checks reported availability. It does not actually reserve stock.&lt;/p&gt;

&lt;p&gt;A production reservation workflow needs concurrency control, transaction handling, and atomic updates where appropriate.&lt;/p&gt;

&lt;h3&gt;
  
  
  File: &lt;code&gt;orders/OrderService.java&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kn"&gt;package&lt;/span&gt; &lt;span class="nn"&gt;com.example.commerce.orders&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;com.example.commerce.inventory.InventoryOperations&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.springframework.stereotype.Service&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="nd"&gt;@Service&lt;/span&gt;
&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;OrderService&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;private&lt;/span&gt; &lt;span class="kd"&gt;final&lt;/span&gt; &lt;span class="nc"&gt;InventoryOperations&lt;/span&gt; &lt;span class="n"&gt;inventory&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

    &lt;span class="nc"&gt;OrderService&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;InventoryOperations&lt;/span&gt; &lt;span class="n"&gt;inventory&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;inventory&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;inventory&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;

    &lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="nf"&gt;canCreate&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt; &lt;span class="n"&gt;sku&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;quantity&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;inventory&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;canReserve&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="n"&gt;sku&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;quantity&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Orders now depends on Inventory's published interface rather than its repository implementation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This is the main architectural improvement: the dependency follows a business capability instead of exposing internal persistence details.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The anti-pattern and corrected implementation are alternatives. Do not keep both versions of &lt;code&gt;OrderService&lt;/code&gt; in the same project.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Verify Boundaries with Spring Modulith
&lt;/h2&gt;

&lt;p&gt;Code review is useful, but relying on developers to remember every architectural rule becomes difficult as applications evolve.&lt;/p&gt;

&lt;p&gt;Automated verification can help prevent accidental violations.&lt;/p&gt;

&lt;p&gt;First, the application needs a root configuration class.&lt;/p&gt;

&lt;h3&gt;
  
  
  File: &lt;code&gt;CommerceApplication.java&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kn"&gt;package&lt;/span&gt; &lt;span class="nn"&gt;com.example.commerce&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.springframework.boot.SpringApplication&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.springframework.boot.autoconfigure.SpringBootApplication&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="nd"&gt;@SpringBootApplication&lt;/span&gt;
&lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;CommerceApplication&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="kd"&gt;public&lt;/span&gt; &lt;span class="kd"&gt;static&lt;/span&gt; &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;main&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;String&lt;/span&gt;&lt;span class="o"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;SpringApplication&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;run&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;
            &lt;span class="nc"&gt;CommerceApplication&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="n"&gt;args&lt;/span&gt;
        &lt;span class="o"&gt;);&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Spring Modulith provides an &lt;code&gt;ApplicationModules&lt;/code&gt; API for inspecting the module structure.&lt;/p&gt;

&lt;p&gt;The verification test can be written as follows.&lt;/p&gt;

&lt;h3&gt;
  
  
  File: &lt;code&gt;ArchitectureTests.java&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight java"&gt;&lt;code&gt;&lt;span class="kn"&gt;package&lt;/span&gt; &lt;span class="nn"&gt;com.example.commerce&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.junit.jupiter.api.Test&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="nn"&gt;org.springframework.modulith.core.ApplicationModules&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ArchitectureTests&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;

    &lt;span class="nd"&gt;@Test&lt;/span&gt;
    &lt;span class="kt"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;verifiesModuleBoundaries&lt;/span&gt;&lt;span class="o"&gt;()&lt;/span&gt; &lt;span class="o"&gt;{&lt;/span&gt;
        &lt;span class="nc"&gt;ApplicationModules&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;of&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;CommerceApplication&lt;/span&gt;&lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;class&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
            &lt;span class="o"&gt;.&lt;/span&gt;&lt;span class="na"&gt;verify&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
    &lt;span class="o"&gt;}&lt;/span&gt;
&lt;span class="o"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The official &lt;a href="https://docs.spring.io/spring-modulith/reference/verification.html" rel="noopener noreferrer"&gt;Spring Modulith verification documentation&lt;/a&gt; describes this exact API pattern.&lt;/p&gt;

&lt;p&gt;By default, the verification checks include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Circular dependencies between application modules.&lt;/li&gt;
&lt;li&gt;Access to internal types in another application module.&lt;/li&gt;
&lt;li&gt;Violations of explicitly configured allowed dependencies.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For a suitable standard-module arrangement, accessing the Inventory public interface is allowed, while accessing an internal Inventory repository from Orders should be rejected.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Scenario&lt;/th&gt;
&lt;th&gt;Expected verification behavior&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Orders depends on &lt;code&gt;InventoryOperations&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Allowed, assuming no other violations&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Orders accesses &lt;code&gt;inventory.internal.StockRepository&lt;/code&gt;
&lt;/td&gt;
&lt;td&gt;Rejected under default closed-module rules&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Orders and Inventory depend cyclically on one another&lt;/td&gt;
&lt;td&gt;Rejected&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A module violates configured allowed dependencies&lt;/td&gt;
&lt;td&gt;Rejected&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;These results describe the documented rules, not the output of a test suite executed for this article.&lt;/p&gt;

&lt;p&gt;To run the example, the project also needs compatible Spring Boot and Spring Modulith dependencies, plus its normal build and test configuration.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Verification status:&lt;/strong&gt; The Java examples are designed to be consistent, and the &lt;code&gt;ApplicationModules&lt;/code&gt; API has been checked against official documentation. A full Spring Boot application startup and architecture test run have not been demonstrated here.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Why a Passing Architecture Test Isn't Enough
&lt;/h2&gt;

&lt;p&gt;An important limitation deserves attention.&lt;/p&gt;

&lt;p&gt;Even if every architecture test passes, the application can still have poorly chosen business boundaries.&lt;/p&gt;

&lt;p&gt;For example, imagine a Billing module that owns several unrelated operations simply because they involve money.&lt;/p&gt;

&lt;p&gt;Technically, the module may not violate a dependency rule. But it could still be too broad to maintain effectively.&lt;/p&gt;

&lt;p&gt;Automated checks cannot replace domain understanding.&lt;/p&gt;

&lt;p&gt;Teams must still ask:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Does each module represent a coherent business responsibility?&lt;/li&gt;
&lt;li&gt;Are its published operations understandable?&lt;/li&gt;
&lt;li&gt;Are implementation details hidden?&lt;/li&gt;
&lt;li&gt;Do other modules rely on the exposed contract rather than internal behavior?&lt;/li&gt;
&lt;li&gt;Can the responsibility evolve without repeatedly forcing unrelated modules to change?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Architecture tests help enforce the rules the team defines.&lt;/p&gt;

&lt;p&gt;They cannot determine whether every rule is appropriate.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. What About Circular Dependencies?
&lt;/h2&gt;

&lt;p&gt;Suppose Orders depends on Billing, Billing depends on Notifications, and Notifications directly depends on Orders.&lt;/p&gt;

&lt;p&gt;Now the three modules form a dependency cycle.&lt;/p&gt;

&lt;p&gt;This can make changes harder to isolate and can blur responsibility between business capabilities.&lt;/p&gt;

&lt;p&gt;Spring Modulith's verification identifies module-level dependency cycles.&lt;/p&gt;

&lt;p&gt;When a cycle appears, the solution should not simply be to disable the rule.&lt;/p&gt;

&lt;p&gt;Investigate why the modules depend on one another.&lt;/p&gt;

&lt;p&gt;Sometimes responsibilities need to be redistributed. Sometimes one interaction can be expressed through a stable interface or business event.&lt;/p&gt;

&lt;p&gt;The right solution depends on the domain.&lt;/p&gt;

&lt;p&gt;Avoid adding another abstraction merely to hide the dependency without resolving the underlying coupling.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. When Should Modules Communicate Through Events?
&lt;/h2&gt;

&lt;p&gt;A modular monolith can use asynchronous communication without becoming microservices.&lt;/p&gt;

&lt;p&gt;That is useful to understand because developers sometimes equate events with distributed architecture.&lt;/p&gt;

&lt;p&gt;The two are not the same.&lt;/p&gt;

&lt;p&gt;For example, after an order is created, the application may need to send a confirmation notification.&lt;/p&gt;

&lt;p&gt;The Orders module could publish an event, and Notifications could respond without Orders directly depending on notification-delivery internals.&lt;/p&gt;

&lt;p&gt;Spring Modulith's &lt;a href="https://docs.spring.io/spring-modulith/reference/events.html" rel="noopener noreferrer"&gt;event publication documentation&lt;/a&gt; explains its event-oriented module interaction capabilities.&lt;/p&gt;

&lt;p&gt;However, events create design responsibilities of their own.&lt;/p&gt;

&lt;p&gt;A team needs to consider delivery failures, duplicate processing, transaction boundaries, and whether work must be durable.&lt;/p&gt;

&lt;p&gt;A synchronous call may remain the better choice when one module requires an immediate response to complete a business operation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Choose event-driven communication because the interaction needs it, not because asynchronous architecture sounds more modern.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Test at the Module Level
&lt;/h2&gt;

&lt;p&gt;A maintainable module should be testable without requiring every unrelated capability to participate in each test.&lt;/p&gt;

&lt;p&gt;Spring Modulith offers module-focused integration testing through &lt;code&gt;@ApplicationModuleTest&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;That can help developers test a business capability while preserving awareness of its module boundary.&lt;/p&gt;

&lt;p&gt;A sensible testing strategy includes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Unit tests for individual business rules.&lt;/li&gt;
&lt;li&gt;Integration tests for module interfaces and persistence behavior.&lt;/li&gt;
&lt;li&gt;Architecture verification tests for structural dependencies.&lt;/li&gt;
&lt;li&gt;End-to-end tests for workflows spanning multiple modules.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;None of these replaces the others.&lt;/p&gt;

&lt;p&gt;An application may pass its structural verification while still having a broken checkout workflow.&lt;/p&gt;

&lt;p&gt;Likewise, an end-to-end test may pass while the code gradually develops unnecessary internal dependencies.&lt;/p&gt;

&lt;p&gt;Different tests protect different properties.&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Five Common Mistakes to Avoid
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Mistake 1: Treating packages as boundaries without enforcing dependencies
&lt;/h3&gt;

&lt;p&gt;Directories provide organization. Architecture rules establish which relationships are allowed.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mistake 2: Exposing repositories to unrelated modules
&lt;/h3&gt;

&lt;p&gt;When modules depend directly on another module's persistence implementation, changes can spread across business boundaries.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mistake 3: Creating an oversized shared module
&lt;/h3&gt;

&lt;p&gt;A general shared package can become an attractive place for unrelated business rules, slowly introducing coupling throughout the application.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mistake 4: Turning every interaction into an event
&lt;/h3&gt;

&lt;p&gt;Events are valuable when asynchronous or loosely coupled processing serves a real requirement. They are not inherently better for every operation.&lt;/p&gt;

&lt;h3&gt;
  
  
  Mistake 5: Assuming a modular monolith is only a temporary architecture
&lt;/h3&gt;

&lt;p&gt;A modular monolith can remain a deliberate long-term choice.&lt;/p&gt;

&lt;p&gt;The question of whether it should eventually become distributed depends on actual scaling, deployment, reliability, and operational requirements.&lt;/p&gt;

&lt;p&gt;A broader &lt;a href="https://toadster.ai/blogs/modular-monolith-vs-microservices-how-to-choose-based-on-real-scaling-needs" rel="noopener noreferrer"&gt;comparison of modular monoliths and microservices&lt;/a&gt; explores those architectural trade-offs.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Module Boundary Checklist for Code Reviews
&lt;/h2&gt;

&lt;p&gt;Before merging a change, ask:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Does this module expose a stable, meaningful public interface?&lt;/li&gt;
&lt;li&gt;Is another module accessing its internal types?&lt;/li&gt;
&lt;li&gt;Have new dependencies created a cycle?&lt;/li&gt;
&lt;li&gt;Does the receiving module own the business operation it performs?&lt;/li&gt;
&lt;li&gt;Can the change be tested at an appropriate module level?&lt;/li&gt;
&lt;li&gt;Does the architecture verification test still pass?&lt;/li&gt;
&lt;li&gt;Would a future engineer understand why these modules depend on one another?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The objective isn't to maximize the number of modules.&lt;/p&gt;

&lt;p&gt;It's to make dependencies understandable and prevent unrelated capabilities from becoming unnecessarily coupled.&lt;/p&gt;

&lt;p&gt;These concerns also matter when planning &lt;a href="https://toadster.ai/services/software-development" rel="noopener noreferrer"&gt;custom software development&lt;/a&gt;, particularly for applications expected to evolve over several years.&lt;/p&gt;

&lt;h2&gt;
  
  
  Frequently Asked Questions
&lt;/h2&gt;

&lt;h3&gt;
  
  
  What is a module boundary in a modular monolith?
&lt;/h3&gt;

&lt;p&gt;A module boundary defines which business responsibilities a module owns and which operations it exposes to other modules. Good boundaries prevent unrelated code from accessing internal implementation details. They make dependencies easier to understand and support focused testing and maintenance.&lt;/p&gt;

&lt;h3&gt;
  
  
  How can Spring Modulith enforce module boundaries?
&lt;/h3&gt;

&lt;p&gt;Spring Modulith analyzes an application's module structure and can verify architectural rules. Its checks include circular dependencies and access to other modules' internal packages. Teams can also configure permitted module dependencies. These checks support architectural discipline but do not replace domain-design reviews.&lt;/p&gt;

&lt;h3&gt;
  
  
  Can a modular monolith use event-driven communication?
&lt;/h3&gt;

&lt;p&gt;Yes. Modules can publish and consume application events without being independently deployed services. Events may help reduce direct dependencies or support asynchronous work. Teams still need to design for transaction behavior, handler failures, durability requirements, and duplicate processing where applicable.&lt;/p&gt;

&lt;h3&gt;
  
  
  Is Spring Modulith necessary for modular monolith architecture?
&lt;/h3&gt;

&lt;p&gt;No. A modular monolith is an architectural design choice, not a framework requirement. Spring Modulith offers tools for Spring Boot projects, but other technology stacks can enforce boundaries through visibility rules, architecture tests, clear interfaces, and dependency restrictions.&lt;/p&gt;

&lt;h3&gt;
  
  
  When should a modular monolith become microservices?
&lt;/h3&gt;

&lt;p&gt;Consider microservices when specific capabilities require independent scaling, deployment, ownership, or failure isolation and when those benefits justify distributed-system complexity. A growing codebase alone is not sufficient reason to migrate. Measure the relevant constraints before changing deployment boundaries.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;If your monolith is becoming difficult to maintain, splitting it into microservices should not be the automatic first response.&lt;/p&gt;

&lt;p&gt;Investigate the dependencies.&lt;/p&gt;

&lt;p&gt;Define ownership, expose narrow interfaces, protect internals, and introduce structural verification.&lt;/p&gt;

&lt;p&gt;Those practices improve the architecture whether the application remains a modular monolith or eventually extracts selected capabilities into separate services.&lt;/p&gt;

&lt;p&gt;Sometimes the most valuable architectural improvement isn't creating another service.&lt;/p&gt;

&lt;p&gt;It's removing a dependency that should never have existed.&lt;/p&gt;

</description>
      <category>java</category>
      <category>springboot</category>
      <category>architecture</category>
      <category>backend</category>
    </item>
  </channel>
</rss>
