Technical document

Splitting is merely a means to an end – Cross-cutting design for fundamentally splitting a multi-tenant business SaaS platform into dozens of services and operating them without breakage

This article details the practical work of fundamentally splitting a multi-tenant business SaaS platform, which unifies attendance, sales, accounting, POS, and even AI assistants, from a semi-monolith into dozens of independent services. It covers differential deployment, fail-safe migration order, separation of configuration and code paths, automatic compensation for migration drift, single source of truth for API specifications, a two-tier topology for authentication and public access, and a design for integrating AI assistants and RAG onto the same foundation, all with reasons for decisions and trade-offs.
Architecture / Operations Design~30 minPublication Date September 22, 2026Update date September 22, 2026
Splitting is merely a means to an end – Cross-cutting design for fundamentally splitting a multi-tenant business SaaS platform into dozens of services and operating them without breakage

Summary

Key points of this document

  • Operational design after splitting is more challenging than the splitting itself.
  • What was split? – An overview of the multi-tenant business SaaS platform.
  • Fixing assumptions and constraints upfront prevents wavering decisions.

Overview

We fundamentally split a multi-tenant business SaaS suite, which consolidated attendance, sales, inventory, quotes, accounting, invoicing, HR/payroll, reservations, forms, POS, commerce, content management, access control, audit logs, and even AI assistants and chatbots onto a single platform, from a semi-monolith into dozens of independent services. The strongest realization during this work was that the difficulty lies not in "where to draw service boundaries," but in "whether it can continue to operate without breaking after being split." Naming and port conflicts, manual releases where the entire system is redeployed with every change, discrepancies between schema registries and actual databases, and ambiguous boundaries where authentication sessions leak to public pages. These issues don't arise from the act of splitting itself, but rather emerge when operational design after splitting is deferred. This article organizes the cross-cutting mechanisms established concurrently with the split, along with the reasons for decisions and trade-offs.

Operational design after splitting is more challenging than the splitting itself.

The starting point was a state where numerous business domains with different characteristics (attendance, sales, forms, reservations, access control, etc.) coexisted within a single or semi-monolithic system. Although teams and change frequencies differed per domain, code and deployment were integrated. Consequently, a small fix in one feature would trigger a rebuild and redeployment of unrelated domains. The scope of change impact was unpredictable, releases always required full synchronization, and fault isolation had to be done within a unified log.

To resolve this state, each domain is split into independent services, but splitting is not the goal. The moment services are split, what was implicitly integrated before becomes explicit. This includes host public port conflicts, duplicate container and image names, consistency of database migrations across separate services, and handling authentication sessions that span services. If operational design for these cross-cutting issues is not prepared with the same intensity as the splitting design, the number of operational vulnerabilities will increase with each split.

Being multi-tenant also complicates the design. Since one service handles data for multiple organizations, it is crucial not to compromise the layer at which tenant isolation is guaranteed during splitting. Even after splitting services, the consistency of tenant boundaries must be maintained across all services. Splitting was also an effort to proceed while adhering to this cross-cutting invariant.

Symptoms manifest in several ways: updating a shared library in one domain triggers a build for unrelated domains, waiting for all services to deploy completely with each release, or high load in one domain impacting the response of a co-located domain. These are not individual bugs but rather the surfacing of undefined boundaries, which cannot be solved by adding features. A structural change is needed to separate code and deployment units along business domains.

This article aims to specifically share "mechanisms to prevent breakage after splitting," rather than "how to split," for designers and operators considering migrating from monoliths to microservices. It will not touch upon specific business content or projects, focusing solely on technical structure and decisions.

What was split? – An overview of the multi-tenant business SaaS platform.

The subject was not a single-function tool specialized in one business area. It was a multi-tenant business SaaS suite that consolidated attendance, sales, inventory and BOM, quotes, accounting, invoicing, HR/payroll, reservations, forms, in-store POS, commerce, content management, audit and access logs, access control, organization management, and even AI assistants and chatbots, all built on a common foundation. Dozens of backends, dozens of domain screens, dedicated authentication apps, and multiple public portals collaborate as a single platform. The fact that so many feature sets, each capable of being a standalone product, coexist under one roof makes this split unique.

What makes this scale challenging is that while each domain has enough functionality to stand as an independent product, foundational elements like authentication, organization, permissions, notifications, and auditing must be shared across all domains. The more independence is emphasized, the harder it becomes to share the foundation; the more sharing is enforced, the more independent deployments and scaling are sacrificed. At the heart of the decomposition design was the decision of how and at which layer to resolve this tension of "balancing independence with a shared foundation." Each subsequent chapter, when boiled down, is an answer to this single tension.

Furthermore, it supports multi-brand (OEM) offerings, providing the same foundation as entry points for different brands, and also features developer-facing aspects such as public APIs for external developers and an integrated API reference that can be cross-referenced across all services. Placing disparate aspects—business applications, public portals, AI, and a developer platform—on a single operational model. The decomposition was a reorganization to accommodate this scale and diversity into a form that a small team could continuously operate without breaking.

  • Consolidating attendance, sales, accounting, billing, HR/payroll, reservations, POS, CMS, permissions, auditing, and AI onto a single platform.
  • Balancing the independence of each domain with the sharing of foundational elements like authentication, permissions, and auditing.
  • Placing business applications, public portals, AI, and a developer platform (public API/integrated reference) on a single operational model.

Fixing assumptions and constraints upfront prevents wavering decisions.

The entire system is managed in a monorepo, and the direction of dependencies is strictly enforced to be unidirectional. The application main body (entry point for each service) depends on feature packages per domain, and feature packages depend on shared libraries. Reverse references—referencing applications from shared libraries, or feature packages depending on each other horizontally—are prohibited. This unidirectional dependency, though subtle, forms the basis for mechanically determining "what gets rebuilt when something changes" after decomposition, and is the very prerequisite for differential deployments discussed later.

The biggest operational constraint is that active services cannot be stopped. Therefore, migration can only proceed incrementally. We adhere to the order of first inventorying specifications, then adding annotations and configurations, and finally retiring old implementations. While an "overhaul" approach might seem cleaner, it entails a prolonged period of discrepancy between production and design during the migration phase, which we judged to be high-risk.

To actually enforce unidirectional dependencies, merely sharing conventions verbally is insufficient. Packages are separated as workspace boundaries, and references that violate the dependency direction are blocked during builds or checks. This way, when a service is later extracted, only what that service truly depends on needs to be taken out, avoiding the "don't know how much will come along" situation common in monolithic eras. The ease of decomposition is a byproduct of dependency discipline before decomposition.

For the execution platform, we adopted a configuration where containerized services are deployed to a managed serverless execution environment (equivalent to Cloud Run), state is centralized in PostgreSQL, infrastructure is declaratively managed with Terraform, and local environments can reproduce the production topology with Docker Compose. All selections prioritized the ability to "detect discrepancies between declaration and reality."

Local reproducibility is the lifeline for verification at this scale of decomposition. We made it possible to set up the same configuration as production locally with containers, allowing for verification of inter-service communication, authentication cookie behavior, and migration application on development machines. The fewer problems that only reproduce in production, the less anxiety there is about releases. Conversely, if the production topology cannot be reproduced locally, bugs caused by boundaries will be encountered for the first time in production.

Service boundaries become a reality through consistent naming and port assignments.

The first step in decomposition, surprisingly, was organizing naming and ports. Services that had evolved independently had disparate container names, image names, and exposed ports, leading to conflicts when co-located on the same host or development machine. Therefore, all services were placed under a unified prefix, allowing them to be treated as a single logical group on the container platform. Just having consistent names greatly simplifies operations for visibility, startup order, and log aggregation.

Ports exposed by the host to the outside were collectively moved to a dedicated range of numbers that would not conflict with other projects. What's important here is the demarcation: internal container ports and inter-container communication ports were not changed. By moving only the externally visible ports and keeping internal name resolution-based communication intact, the ripple effect of changes was minimized. For paths where the browser reconnects via host ports, such as hot reloading for development servers, follow-up settings like explicit client-side port specification are required.

A unified set of services is also effective in terms of observability. By appearing as a single group on the platform, cross-service log tracking and understanding which services are running can be done at a glance. While splitting increases the number of monitored targets by the number of services, if naming and grouping are consistent, this increase can be offset to some extent by improved overview. Conversely, if only the number increases with inconsistent names, splitting will only appear as a 'mess' to operators.

Unifying naming includes handling derivations like 'releasing the same entity with only configuration changes' for different brands. Duplicating code for each derivation increases the number of maintainable items. Therefore, we decided to keep the entity common, express differences with variables indicating the brand or build-time arguments, and separate only the entry points. Not unnecessarily increasing the number of service entities is also part of the splitting. Along with port organization, we create a state where 'this project's services' appear as a single unit on the platform, enabling batch startup, shutdown, and log checking.

Along with the split, numerous tests and configuration files that had long diverged from the implementation were also retired en masse. Keeping non-working tests actually lowers the reliability of CI. This was a decision to 'settle debts together when splitting.' However, retirement was done in conjunction with the reconstruction of the testing infrastructure, described later, to avoid leaving gaps in coverage.

  • Move only outward-facing public ports to the collision avoidance zone, keeping internal container communication immutable.
  • Unify naming to a common prefix so that they can be treated as a single service group on the platform.
  • Retire obsolete tests, but always as part of a reconstruction plan.
  • Common derivations (e.g., entry points for different brands) should be expressed through configuration differences without increasing entities.

Making a single manifest the source of truth enables differential deployments.

The first decision made for CI/CD after the split was to 'aggregate the list and attributes of services into a single data source, rather than human-written procedures.' For each service, we declare the scope of owned files, build definition, deployment type (resident service/batch job/static delivery), migration necessity, test target packages, and dependency classification for shared packages in a single manifest. This becomes the sole source of truth for deployment decisions.

During deployment, the list of changed files is matched against the manifest, and only affected services are selected. File scope is specified using glob patterns, which are internally converted to regular expressions for matching. If a shared package changes, the impact propagates to all services linked to that classification (backend shared/frontend shared). In addition to the selection results, flags are simultaneously output indicating whether it includes frontend (requires CDN invalidation), whether infrastructure definitions have changed (requires IaC diff plan), whether migration is needed, and what the test target packages are.

The aim of this design is clear: to avoid rebuilding and redeploying unrelated services. Full synchronization releases are time-consuming and costly, and they create opportunities for accidents even in services that haven't changed. Differential deployment narrows the impact of each release to only what has actually changed.

Matching file scopes requires a bit of subtle normalization. Glob notation (symbols for arbitrary depth, and symbols that don't cross directories) is mechanically converted to internal regular expressions and matched against changed file paths. Here, an overlap occurs where a service owns a broad directory, but a part of it is under the jurisdiction of another service. Therefore, we allow declaring exclusion ranges in addition to ownership ranges, expressing 'this part of this directory is not considered my change.' The expressiveness of the manifest directly translates to the accuracy of the diff.

The selection logic has several modes. The default is differential selection based on changed files, but modes are also provided to target all services during major platform changes, or to specify only particular services by name. Having an escape hatch to explicitly say 'release only this' in an emergency is insurance against overestimating the infallibility of automatic selection. Test target packages take the union of sets declared by each selected service, remove duplicates, and resolve dependencies all at once. Handling the union in bulk significantly reduces total CI time compared to repeated individual installations per service.

There are also limitations. Touching one shared package will cause many dependent services to be rebuilt simultaneously. The coarser the granularity of sharing, the larger this 'ripple effect' will be. As a countermeasure, exclusion specifications are included in the manifest to tighten the scope of impact, and the granularity of sharing itself needs to be regularly reviewed. As long as the manifest is the source of truth, maintaining its accuracy directly translates to operational quality.

  • Declare service attributes (scope, type, migration necessity, test target, shared dependencies) in a single data record.
  • Mechanically derive affected services and associated flags from changed files × manifest.
  • The ripple effect of shared package changes is unavoidable, so mitigate it with exclusion specifications and granularity review.

The build → migrate → deploy sequence proactively prevents failures.

The deployment pipeline has been redesigned into elite phases: build, migration, rollout (+ connectivity check), and post-processing. The most crucial aspect here is the order. We separate the container image build from the rollout that actually deploys the new revision, and execute database migration "in between" them. If the migration fails, the rollout is aborted.

There's a reason for this order. If new code is deployed first and then the schema is changed, there will be a moment when the new code runs in production with the old schema. Conversely, if only the schema breaks first and the new code doesn't arrive, the old code will face the new schema. Serializing build → migrate → deploy creates an invariant: "new code is released to production only when the schema has been updated as expected." Migration failure acts as a stop line to prevent new code from touching the old schema.

Rollout is performed synchronously. We wait until the new revision is Ready (receivable) and consider it successful only after a simple connectivity check passes. To absorb temporary infrastructure-side operation conflicts, we include several retries and short waits. The method varies by deployment type: resident services use synchronous updates and connectivity checks, batch jobs use a loop with retries, and static delivery involves synchronizing build artifacts to object storage and invalidating the CDN. These three systems are handled by a single pipeline.

Deployment post-processing is not just a concluding task. For releases including the frontend, CDN caches are invalidated. For backend and frontend releases, authentication connectivity is re-verified. Then, the applied image tag, public URL, and rollback procedure (in case of emergency) are recorded as a release summary. Including rollback commands in the summary beforehand is a subtle but effective measure to prevent paralysis during an incident. Not leaving recovery procedures to be "figured out at the moment" reduces mean time to recovery.

Let's elaborate on the methods for each deployment type. For resident services, we perform a synchronous update specifying only the image, wait for the new revision to become receivable, and then check connectivity with a simple request. In case of failure, several retries and short waits absorb temporary conflicts; if it still fails, it's treated as a failure. For batch jobs, multiple targets are updated sequentially in a loop, also with retries, but no connectivity check is performed due to asynchronous execution. For static delivery, build artifacts are synchronized to object storage, including deletion of unnecessary objects, and then CDN caches are invalidated. The ability to handle these three systems in one pipeline comes from having the type as a manifest attribute.

Furthermore, we placed a lightweight authentication regression guard before deployment. It quickly verifies the entire OAuth 2.0 flow, from initiation to redirect chain, using unit tests that don't touch the database. Since authentication is a foundational dependency for almost all services, a release that breaks it is worth stopping at all costs. As a limitation, this design only handles schema forward progression and does not support migration rollbacks. Therefore, we lean towards "strict verification before release." Connectivity checks are also shallow; they cannot detect cases where a normal response is returned but the connection is broken deeper down, so deeper inspections are added in post-processing as needed.

  • Separate build and rollout, with migration in between.
  • Migration failure is a stop line for rollout. Prevent new code from touching old schema.
  • Handle 3 types (resident services / batch / static delivery) in one pipeline, using type-specific methods.
  • Given no rollback support, strengthen pre-release verification (auth guard, etc.).

Separating configuration and code into different paths stabilizes both.

The "shape of the environment"—such as environment variables, secrets, scaling settings, and network settings—is centrally managed with IaC (Terraform) and changed only via apply after review. On the other hand, daily deployments only update the container image of the execution environment. We leverage the behavior of the execution environment's update command, which preserves unspecified fields with existing values, to avoid touching settings other than the image.

Here, a bit of ingenuity is required. If IaC and daily deployments contend for the same "image" field, their changes will overwrite each other, leading to drift. Therefore, we declared that the IaC side should ignore changes to the image field, centralizing ownership of rollouts to the deployment side. IaC is exclusively responsible for the shape of the environment, and deployments are exclusively responsible for the code version.

The key is to clearly define which party owns which fields. Deployments own the image version, while IaC owns the rest of the environment's shape (environment variables, secret references, concurrency and scaling, network connections). If these responsibilities are clear, changes by one party will not revert the intentions of the other. Conversely, if both are designed to write to the same field, a confusing accident will occur where the deployed image is pulled back to an older declared value with each apply. The declaration to ignore is a measure to prevent such accidents by design.

Secret updates also benefit from this separation. Connection information and key replacements are handled via the IaC path, and daily deployments do not touch them at all. Since code releases and secret updates proceed at different times and with different approvals, accidents where one operation exposes the other's confidential information are less likely to occur. The separation of operational responsibilities by path directly ensures security.

The effect of this separation appears in the rhythm of operations. Changes to environment settings go through a careful path of pull requests, reviews, and apply. Code changes flow automatically from build to migration to deployment. By placing things that need careful handling and things that need rapid iteration on separate paths, both stability and delivery speed can be secured simultaneously.

Migration drift is absorbed by normalization and idempotent compensation.

When services are split and schemas evolve through multiple paths, a discrepancy arises between the "migration ledger" and the "actual database state." This is migration drift. If inconsistencies accumulate—such as a migration being applied in one environment but not recorded in the ledger, being partially applied and then interrupted, or having different interpretations of names across environments—the next migration cannot be safely executed. The main purpose of the working branch in this article was precisely to detect and automatically remediate this drift.

Let me elaborate on why drift occurs in the first place. During the splitting process, multiple working branches modify the schema in parallel, and the timing of application also varies across environments. The ledger records the "intended order," but the actual database is merely the "result of what was actually applied." These two can easily diverge due to manual intervention, interruptions, or environmental differences. That's why it's crucial not to blindly trust the ledger and overwrite, but rather to read the current state of the actual database and then converge the differences with the ledger in a safe direction. This design treats the actual state as correct and adjusts the record afterward.

The first measure is the normalization of identifier byte lengths. Database identifiers have a maximum byte length limit, and long table or column names are truncated at the boundary. If the name in the ledger and the truncated name in the actual database do not match, a false positive occurs where "the same object appears to be different." Therefore, the same normalization rules are applied to both the ledger and the actual entity before generating comparison keys to restore the correspondence. The key is truncation that respects character and byte boundaries.

The second measure is idempotent compensation for unrecorded or partially applied migrations. Migrations that are in the ledger but whose execution state is ambiguous are safely converged into several patterns after reading the current state of the actual database. If the target does not exist yet, it is safely applied and recorded; if the entity already exists and its content matches, only the record is added; if it is only partially applied, the missing operations are compensated; and if it is a virtually empty creation migration, it is safely recreated. All these paths are idempotent, meaning they produce the same result even if executed repeatedly, thus preventing double-application accidents during redeployment.

The third measure is data protection during service recreation. Services and connected resources may be rebuilt during differential deployment or infrastructure changes. However, "things that cannot be recovered if lost," such as primary database instances, their users, and connection string secrets, must never be deleted. Therefore, if a deletion operation on a protected resource is detected during the infrastructure's differential planning phase, the apply itself is stopped. We mechanically enforce the boundary that "services and connections can be recreated, but the actual database cannot" through plan inspection. In addition, we separated the client for schema migration and the client for seeding (initial data insertion), and organized the foreign keys at the root boundary, making the dependencies straightforward after splitting.

To support the auto-completion mechanism, we separated the client for running migrations from the client for inserting initial data. Mixing the two intertwines the responsibilities of schema changes and initial data insertion, where the failure of one can affect the state of the other. At the same time, we organized the foreign keys at the root boundary that arose during the splitting process, making them straightforward dependencies where references do not cycle between services. Automatic drift auto-completion only stabilizes after such preparatory work of "arranging the schema to be easily auto-completed." Aligning not only the mechanism but also the target schema design simultaneously leads to reproducible convergence.

As a limitation, failures that cannot be safely converged idempotently by merely reading the state, such as grammatical errors or unique constraint violations, are outside the scope of automatic auto-completion. Since these require human intervention, we have separately prepared an operational interface (job for manual operations) that can execute arbitrary scripts once, allowing for safe recovery and correction.

  • Identifiers are truncated by byte length. The ledger and the actual entity are normalized and matched using the same rules.
  • Unrecorded/partially applied states are converged idempotently by reading the current state and applying patterns.
  • Deletion of the primary database is detected and stopped at the planning stage. The boundary between recreatable and non-recreatable is mechanized.
  • A one-time manual operation path is retained for failures that cannot be automatically auto-completed.

API specifications are generated and integrated in a distributed manner, with implementation as a single source.

As services increase, handwritten API specifications inevitably become outdated faster than their implementations. Therefore, we have prepared a "distributed generation + merge" infrastructure where each service self-describes and delivers its own specification, which is then integrated into one place. Each backend provides its own specification endpoint, using the schema (Zod) it uses for request validation directly as the single source for OpenAPI specifications. Since validation logic and documentation originate from the same definition, dual management and drift are structurally eliminated.

To elaborate, domain-specific functionalities are implemented as libraries, which are then mounted onto service processes. A standalone library does not have a specification endpoint; instead, the service where it is mounted bundles and delivers it as its own specification. This division of labor, "functionality as a library, delivery as a service," allows for both feature reuse and independent delivery per service. Distributed generation of specifications naturally fits into this architecture.

For the adoption method, we chose to "append" descriptions to existing routes. While there was an option to completely rewrite the entire routing to a type-safe alternative, rewriting many services simultaneously would introduce a long period of drift during the transition. The appending method allows for gradual annotation while preserving the existing structure, and even in intermediate stages, an inventory can be taken, including empty items. This was a decision that prioritized migration safety and reversibility over the appeal of a complete rewrite that maximizes type safety.

The integrating aggregator collects and merges specifications from each service. There are several design decisions here. If the same path comes from multiple services, the first one takes precedence and is maintained, and conflicts are recorded as warnings. Schema name conflicts are avoided by namespacing with the service name (prefixing with the service name), and references within the specification are recursively re-linked. Each operation is tagged to indicate its origin, allowing traceability to the originating service. Specifications from unreachable services are skipped with a warning, without stopping the entire process.

On the delivery side, a dedicated service providing an integrated view collects each specification either server-side or at build time. The reason for not allowing browsers to fetch across services is that, under the authentication and public/private split topology described later, cross-domain fetching would face CORS and Cookie restrictions. By bundling them via a server-to-server path, these restrictions are avoided. The rollout proceeds in stages: preparing conventions and the aggregator, piloting with one service, inventorying and delivering all services, horizontally expanding annotations per domain, and finally retiring handwritten specifications.

We prioritized the 'first-win' approach for path conflicts to avoid integration halts. Strictly speaking, conflicts should be rectified, but if an error at the integration stage stops the entire process, a single conflict would make all service documents invisible. Therefore, we decided to continue integration while logging conflicts as warnings, with rectification handled at a later time. This decision prioritized keeping specifications 'always up-to-date and always viewable' over strictness. When API specifications are synchronized with implementation and always accessible, they become a common language for designing inter-service collaborations.

The source of specifications can be switched depending on the environment. If there's an environment variable to override it individually, that's used; for container-based platforms, an address over the internal network between services is used; and for local development, an address on the host is used. For common authentication method definitions, we avoid duplication and only import unregistered ones. The deployment stages also proceeded not all at once, but in sequence: establishing conventions and aggregators, piloting with one service, minimal delivery to all services, enriching annotations per domain, and finally retiring handwritten specifications. Maintaining a constantly working state at each migration stage is a condition for preventing long migrations from failing.

Validation protects the aggregator itself with unit tests. The accuracy of integration results from multiple services, reference re-linking due to namespacing, and skipping unreachable services are fixed by tests. As a limitation, full disclosure of the API structure can itself be an attack surface, so production integration documents are assumed to be placed behind administrator authentication.

  • Make validation schemas the single source of truth for specifications, eliminating duplication and drift.
  • Choose an append-only approach instead of a complete rewrite, prioritizing migration safety and reversibility.
  • For merges: path conflicts are first-win + warning, schemas are namespaced, operations have origin tags.
  • Integrate on the server side to avoid cross-domain acquisition restrictions.

AI assistants and RAG will also be placed on the same operational foundation.

This platform incorporates AI assistants that answer questions across business operations, chatbots that respond to inquiries, and RAG (Retrieval-Augmented Generation) functionality that searches internal knowledge and documents to formulate answers. While visually the most prominent feature, the operational design policy was quite the opposite: we thoroughly ensured 'no special treatment.' If AI features alone had their own deployment paths or monitoring, that part would become an operational island, eventually leading to no one being able to maintain it.

For example, the RAG knowledge base requires resynchronization every time its source materials or data are updated. This resynchronization is implemented not as a continuously running service that accepts requests, but as an asynchronous batch job, placed directly into the 'job' type provided by the deployment infrastructure from previous chapters. Declaring it as a job in the manifest allows existing mechanisms for differential execution based on change detection and retries upon failure to work as is. This was a decision not to create a separate pipeline just because it's AI.

The AI assistant's API, like other domains, exposes self-describing API specifications and operates on the same authentication and authorization foundation. Calls to external AI services and models are confined within the domain service, and management of keys and usage limits is directed to the IaC secret path. In this way, AI features are treated not as 'experiments that might work,' but as operable product features, including authorization, auditing, and deployment, placing them on the same footing as other domains. Beneath the flashiness, subtle operational discipline is at work.

On the other hand, difficulties inherent to AI features—non-determinism where responses are not always the same, latency and failures of external services, and costs that fluctuate with usage—cannot be solved by this cross-cutting design alone. These are addressed individually on the domain side by preparing for timeouts and fallbacks, and observing usage. We separate placing features on a common foundation from individually tackling the unique difficulties of those features as distinct tasks.

  • RAG resynchronization is declared as a job, not a resident service, and placed on existing differential deployments.
  • AI APIs also use self-describing specifications and common authentication/authorization, receiving no special treatment.
  • Non-determinism, external failures, and cost fluctuations cannot be solved at the foundation level and are handled individually on the domain side.

Authentication and publication are physically isolated by two-tiered subdomains.

The most critical aspect of the split was the boundary of authentication sessions. Using the cross-subdomain cookie feature of the authentication library, session cookies reach all subdomains under the parent domain. While convenient, if authenticated sessions reach embeddable public pages (forms or reservation entry points), it expands the security surface. Therefore, we separated the console groups requiring authentication into an authentication layer subdomain (equivalent to app.example.com) and the public portal for anonymous access into a public layer subdomain (equivalent to pub.example.com), confining the scope of session cookies to only the authentication layer.

The aim of this two-tier structure is to make the cookie scope itself the security boundary. Even if logged in at the authentication layer, that cookie will not reach the public layer. Public pages always operate anonymously and never receive authenticated user credentials. As a result, the attack surface via public pages is reduced, and session assignment to unconsenting visitors is avoided.

The path from the public portal to the backend is consolidated into a facade for public APIs and controlled by an origin allowlist. The allowlist is not hardcoded but centrally managed via environment variables, and entries are added in the configuration each time a public app is added. Since the facade returns raw responses, care must be taken regarding which layer applies CORS headers (they must be applied before response generation).

The public facade has another compromise. Since one facade bundles multiple public functions (forms, reservations, orders), instead of finely separating allowed origins for each function, a shared allowlist for the entire public layer is used. While convenient, it requires adding to the allowlist every time a public function is added, and fine-grained access control per function must be ensured at another layer. Simplifying boundaries makes operations easier, but granularity is sacrificed—a typical trade-off.

Cookie attributes also differ between production and development. Production assumes HTTPS, combining secure attributes and lenient same-site attributes to allow transmission between different subdomains. Development uses normal same-site attributes for plain text. The domain attribute is fixed to the parent domain of the authentication layer to prevent it from spreading further. If even one of these is mistaken, it will manifest as an inability to log in, or conversely, a cookie leak to the public layer, so the configuration values themselves are treated as review targets.

The trade-off is clear. Since the public layer cannot maintain authentication sessions, if customers want to maintain a logged-in state on the public portal, a separate design involving backend-issued tokens or invitation links is required. Hybrid pages that progressively log in become difficult to create under this separation. Also, moving the authentication start URL to a different subdomain requires re-registering the OAuth 2.0 callback URL with the authorization provider, incurring operational overhead for synchronization every time the subdomain is moved. This is a decision to accept these constraints in exchange for clear boundaries.

  • Confine the scope of session cookies to the authentication layer, physically isolating it from the public layer.
  • Public pages are always anonymous. Reduce the attack surface by not allowing them to receive authentication information.
  • Abandon login persistence on the public layer; if necessary, substitute with tokens or invitation links.

Front-end components are consolidated into a common shell, leaving only exceptions.

The domain front for the authentication layer has been unified into a common application shell (a layout with a sidebar, app switching, organization selection, personal settings, etc.). A single template implementation is referenced as the canonical source, and each domain places its own screens on top of it. This not only improves UI consistency but also centralizes common processes for authentication and navigation, making cross-domain changes easier.

However, not everything is forced into commonality. Apps with independent information architecture or authentication flows—such as independent web applications for different user segments—were left as exceptions outside the common shell. This is because the benefits of maintaining a unique experience and boundaries can outweigh the benefits of commonality. Having a clear demarcation of "unify by principle, explicitly define exceptions" prevents commonality from running rampant.

Which domain runs on which origin is centralized in an environment-driven registry. The console side receives a list of permissible apps and their origins from the environment, which it uses for app switching and navigation on the screen. By providing origins via the environment instead of embedding them in code, the same code can be deployed to different topologies for development, testing, and production. Conversely, missing environment settings directly lead to missing functionality, so the presence of all necessary origins is checked as a deployment prerequisite.

The common shell offers more than just a unified appearance. It provides fixed and auto-collapsing sidebars, draggable width adjustment, consolidated personal settings like theme, language, and display density, an organization selector with search, and consistent application of brand-specific color schemes. If each domain were to implement these individually, it would not only lead to redundant implementation but also subtle behavioral differences that confuse users. We've adopted a division of labor where cross-cutting UI and operational rules are encapsulated in one place, allowing each domain to focus on its business screens. The greatest benefit of commonality lies in these parts that "should be the same across all domains."

All origins referenced by each front-end are driven by environment variables, eliminating hardcoding. This is an essential design for a segmented topology but also introduces operational risks. If environment variables for origins are not set correctly during deployment, references will fall back to defaults, causing CORS errors or redirect loops in production. Injecting a complete list of origins is thus a prerequisite for stable operation.

Production wiring is secured by certificates and routing, while development is ensured by replicating the production topology.

Covering two layers of wildcards (everything under both the authentication layer and the public layer) with a single traditional certificate is not straightforward due to how certificate subject names are handled. Therefore, we adopted managed certificates with DNS validation, issuing separate certificates for the authentication layer and the public layer. Certificate mapping is wired to the HTTPS entry point, presenting the appropriate certificate based on the hostname. Routing aggregates serverless execution environments as backends for each domain, and the path from the entry point (certificate, proxy, serverless NEG, URL map, DNS) is declaratively configured.

The most difficult aspect to reproduce with this type of segmentation is cookie reachability in the development environment. Simple local port assignments cannot verify cookie behavior between subdomains. Therefore, we use a development domain that resolves to loopback with wildcards and a reverse proxy to set up hosts equivalent to the authentication and public layers. This allows us to physically confirm that cookies reach the authentication layer but not the public layer after login. Reproducing the production topology locally is the only realistic way to eliminate boundary design bugs before production.

Certificate design involves the constraints of traditional certificates. Since traditional certificates list subject hostnames, handling two layers of wildcards with a single certificate is not straightforward. Therefore, we switched to managed certificates using DNS ownership verification, issuing separate certificates for the authentication and public layers, and wired a mapping at the entry point to select the certificate to present based on the hostname. For development environment reproduction, a development domain that resolves to loopback with wildcards must be used, and that hostname must also be added to the allowlist on the development server. Forgetting this step will prevent connection due to hostname validation failure, so it is documented as a routine procedure for adding new applications.

Additionally, static landings were shifted to static site generation (prerendering) to lighten delivery. By placing pages with few dynamic elements on static delivery + CDN instead of an execution environment, both cost and robustness are improved.

The testing infrastructure will be rebuilt driven by manifests.

Since obsolete tests were retired in conjunction with the segmentation, rebuilding to fill coverage gaps is essential. Here too, the source of truth was made the manifest. Using the same selection logic as deployment, only the test target packages of services related to the change are collected, deduplicated, and executed in a single dependency installation. Both unit tests and end-to-end tests are restored, configured to run only the necessary scope in response to changes.

The philosophy of validation was placed on "observing how things break." Authentication regression guards before deployment, connectivity smoke tests during rollout, unit tests for API specification aggregators, and idempotency for migration completion. These are observation points designed to visualize anomalies early at each layer for the "places that can break" which have increased due to segmentation. Intentionally deciding where to automate and where to leave for manual confirmation is more effective than the sheer volume of tests.

We also decided to implement double validation. The same authentication guards and infrastructure difference checks are run both at the pull request stage and at the deployment stage after merging into the main branch. While duplication may seem wasteful, it provides a multi-layered defense where one catches changes that slip past the other. In particular, checks that prevent the deletion of protected resources are valuable to confirm through multiple gates, as they target irreversible operations.

In rebuilding, we also designed "when and to what extent to run tests." We run tests related to changes with each release, and heavy end-to-end tests across the entire system are run periodically with reduced frequency. Running all tests with every release, while seemingly ideal, leads to another failure: it takes too much time and eventually tests are not run at all. Keeping the volume manageable so tests can be continuously run is also part of test design. By clarifying which tests are run constantly, which periodically, and which are entrusted to manual verification, we avoid the state where "tests exist but no one looks at them."

For example, we did not automate migration rollbacks, instead opting to heavily pre-verify. We kept the connectivity smoke tests shallow, and only added deep inspections where necessary for post-processing. This is a prioritization of concentrating verification resources on high-risk stopping points (preventing new code from touching old schemas, preventing the main database from being deleted), rather than trying to automate everything.

We explicitly state the choices not adopted and the conditions under which this design is not suitable.

The design so far has intentionally discarded several attractive options. We do not have migration rollbacks, only forward movement. Reversible migrations tend to complicate operations, and we judged that investing in pre-release verification and protective guards was more robust at this scale. For API specifications, we chose an append-only model instead of a complete rewrite, prioritizing migration safety over maximizing type safety.

We also honestly list operational weaknesses. Rebuilding a shared package causes widespread recompilation, shallow rollout smoke tests, inability to retain authentication at the public layer, and the cost of continuously disciplining unidirectional dependencies in a monorepo. These are reflections of the design and unavoidable tradeoffs. The important thing is to recognize these weaknesses and prepare mitigation measures for each (exclusion specifications, deep post-processing inspections, token design, dependency direction inspection).

Let's also touch on the question, "Isn't a modular monolith sufficient in the first place?" If the goal is just to clarify boundaries, dividing modules within a single process simplifies deployment and data consistency. The benefits of physically splitting services only outweigh this when independent deployment, scaling, and fault isolation are truly necessary. In this case, the frequency of changes and load characteristics varied greatly by domain, and problems where heavy processing in one part affected the whole were actually occurring, so we proceeded with physical partitioning. Conversely, if there's no such need, it's wise to stick with a modular monolith. Partitioning is an investment only worthwhile when pain is real.

Another point is the cost of continuously maintaining unidirectional dependencies in a monorepo. If left unchecked, dependency directions will succumb to convenience and break down. There will always be situations where one wants to reference application concerns from a shared library, or directly connect functional packages. If this isn't continuously prevented by inspections, the premise of differential deployment will rot. The benefits of partitioning rest on the diligent operation of maintaining this discipline, and the moment discipline is abandoned, partitioning reverts to its original entanglement.

This design is suitable for systems with many diverse domains, where change frequency and teams are separated by domain, and the entire system cannot be stopped. Conversely, when there are few domains and changes can be managed integrally, the cross-cutting design for partitioning itself becomes an overinvestment. Partitioning only yields benefits when the operational design to support it is in place.

  • Pre-verification over rollback, append-only over complete rewrite — prioritizing reversibility and safety.
  • Acknowledge weaknesses (cascading rebuilds, shallow smoke tests, unauthenticated public layer) and have mitigation measures.
  • At stages with few domains and integral management, cross-cutting design can be overinvestment.

Partitioning is a means. The essence is cross-cutting design to prevent breakage.

Looking back, most of the value of this work was not in splitting the service itself, but in the cross-cutting design to prevent breakage after splitting. Differential deployment with a single manifest, fail-safe order of build→migrate→deploy, separation of configuration and code paths, idempotent automatic completion of migration drift, single source of API specifications, and authentication and public cookie boundaries. All of these are designed to proactively prevent "new ways of breaking" introduced by partitioning.

While I've focused on mechanisms, the success or failure of partitioning also depends on how teams are structured. Service boundaries are also boundaries of change responsibility. The fact that the manifest is the source of truth means that which team owns which service is also reflected there. Aligning technical and organizational boundaries within a reasonable scope makes partitioning sustainable. Even if only mechanisms are in place, services with ambiguous ownership will eventually be neglected by everyone.

For readers who are about to undertake a similar migration, I propose an order for solidifying your foundation. First, establish a manifest that declares a list of services and their attributes as the single source of truth. Next, fix the order of migrations and rollouts, creating an invariant that prevents schema-unreflected code from being deployed to production. Furthermore, prepare a mechanism to detect drift and idempotently compensate for it, along with protection guards to safeguard critical assets. Finally, physically design the boundaries of authentication sessions. By solidifying your foundation in this order, you can avoid a situation where the number of divisions only increases the number of vulnerabilities.

Microservices, the moment they become an end in themselves, erode operations. Before splitting, weave into the design how operations will continue after the split. We believe that this order is the key to transforming radical division from failure into progress.

Each of the mechanisms described here is unremarkable on its own: a single manifest, fixed order, route separation, drift compensation, single source of truth for specifications, and cookie boundaries. However, it is the totality of these unassuming cross-cutting designs that enables a multi-tenant business SaaS, which unifies everything from attendance management to AI assistants on a single platform, to continue operating daily without breaking, even with a small team. I record these designs, quietly effective beneath flashy features, here as the crystallization of the technology achieved through this division.

Technical documents

We will continue to increase technical documentation.

We will continue to organize our thoughts on AI, cloud, business app development, requirements definition, and operational design into documents.

Go to technical documentation list