A granite block beside interlocking stone blocks
    Microservices vs Monolith

    Microservices vs monolithic architecture for EHR development: which fits your platform?

    Healthcare adds constraints that generic architecture advice skips: one audit trail for every access to patient data, PHI that spreads with every service that stores it, order and medication workflows that cannot half-commit, and certification and export duties that cross every component.

    Should an EHR or clinical platform use microservices or a monolith?

    Quick answer

    Microservices vs monolithic architecture for EHR development usually resolves to a modular monolith first: one deployable with strict internal modules, one audit log and one transaction boundary for orders. Split a module into a service when a team or scaling need demands it. Agnotic Technologies designs both and decides module by module.

    CriterionModular monolithMicroservices
    Team size and release cadenceOne to a few teams releasing togetherMany teams that must release independently
    Audit log consistencyOne log, written in the same transaction as the changeEvery service logs; you must correlate entries and protect a central store
    PHI scopeOne runtime and one database to safeguardEvery service, queue and cache that holds PHI is in scope
    Orders and medication administrationOne database transactionOutbox or saga patterns with compensating steps when a service fails
    Certification retestingOne build to regression test after a changeEach release of a service in the certified scope needs its own regression evidence
    EHI exportOne schema to export fromA fan-out job across every service that holds patient data
    ObservabilityStack traces and one logDistributed tracing to follow one request across services
    Security surfaceOne perimeter and in-process callsService identity, mutual authentication and an API gateway between services
    Where AI agent tools sitTools call module APIs in-process, under the user's permissionsTools call service APIs, each call with its own identity and audit entry

    What they are

    What is Modular monolith

    A monolith ships as one deployable with one database. A modular monolith keeps that single deployable but enforces boundaries inside it: each module owns its tables and exposes an internal API, so a module can later become a service without a rewrite.

    What is Microservices

    Microservices split the system into independently deployed services that talk over APIs or events, each with its own data store. Each service scales and releases on its own, at the cost of distributed data, network failure modes and more security surface to run.

    Key differences

    Why is the audit trail the first thing to design?

    Audit rules span every component. 45 CFR 164.312(b) requires recording and examining activity in ePHI systems, and ONC (ASTP) criterion 170.315(d)(2) requires detecting audit log alteration. A monolith commits each entry with its change; microservices need one append-only store and a shared request ID.

    How does PHI scope grow with each service?

    PHI scope grows because the HIPAA Security Rule covers all ePHI an organization creates, receives, maintains or transmits (45 CFR 164.306(a)). Every service, queue or cache holding PHI needs access control, encryption and logging. Pass identifiers, not copies of patient records.

    What happens to orders and medication workflows?

    A medication order touches order entry, pharmacy verification, the administration record and often billing. In one database that is one transaction. Across services it needs an outbox or saga with compensating actions and a visible pending state. Keep that core in one module.

    How do certification and EHI export cross service boundaries?

    Criterion 170.315(b)(10) requires export of all of a single patient's electronic health information, and of a patient population, in a computable, documented format. With microservices, export becomes a job across every service holding patient data, and new services must join it before release.

    Where should AI agent components sit?

    AI agent components should act as clients of the domain, never a back door into the database. Agent tools call the user interface's APIs under the user's permissions, so rules and audit apply. The runtime can scale separately; PHI stays in the owning modules.

    What security work does a microservices design add?

    Microservices add the security features NIST SP 800-204 lists: authentication and access management, service discovery, secure communication, security monitoring, resiliency, and load balancing and throttling. Each is a component to run and test. A modular monolith needs most of these only at its edge.

    When to use each

    When to use Monolith or modular monolith

    • One or two product teams building a new EHR, clinical platform or practice system.
    • Order entry, medication administration and results that must commit together.
    • A first certification cycle, where one audit log and one export path keep testing contained.
    • An AI agent whose tools call the same module APIs as the user interface.

    When to use Microservices

    • Several teams that must release independently, such as scheduling, billing and patient messaging.
    • Workloads with very different scaling needs, such as imaging ingestion next to a scheduling screen.
    • Integration edges, such as an HL7 v2 or FHIR gateway, that change on their own cadence.
    • AI agent runtimes and model hosting that need their own scaling, kept outside the PHI core.

    Where do healthcare microservice designs fail?

    1. Split audit logs. Each service logs in its own format and store, and nobody can reconstruct who viewed a chart. Fix: one append-only audit store, with one request ID carried across every call.

    2. Distributed transactions on orders. An order is saved, but the pharmacy service never receives it. Fix: keep the order core in one module, or use an outbox with a pending state the user can see.

    3. PHI copied into every service. Each service caches demographics for convenience, and the number of stores in scope multiplies. Fix: pass identifiers and look details up from the owning service.

    4. Agent tool calls that bypass the domain. An AI agent writes straight to a table and skips validation and audit. Fix: agent tools call domain APIs only, never the database.

    5. Export that misses a service. A new service holds patient data but is not part of the EHI export job. Fix: make export coverage a release check for every service.

    6. Splitting before the boundaries are known. Services follow screens instead of domains and then call each other on every request. Fix: start modular, watch which modules change and scale on their own, then extract those.

    Frequently Asked Questions

    No. The certification criteria describe capabilities, such as audit logging and EHI export, not an architecture style. Either style can meet them; with microservices the audit and export work spans more components.