Web Development

Web Application Architecture Explained: Monolith, Microservices and Serverless

The layers every web application has, the honest trade-offs of monoliths, microservices and serverless, and why a modular monolith is usually the right place to start.

  • DivTech editorial team
  • 7 min read
PresentationAPI and edgeApplication and domain logicData
Web Development · part 1 of 5

Most web applications run into organisational problems long before they hit technical limits, and architecture is where the two meet. The style you choose decides how many people can work on the code without stepping on each other, how you deploy, what you pay for hosting and how painful year three will be. This guide explains the three main styles, where each fits, and why we usually recommend starting with a modular monolith. If you are planning a new build, our web application development team works through exactly these questions during discovery.

The layers every web application has

Whatever the style, the same responsibilities exist. A monolith keeps them in one deployable unit; microservices and serverless spread them across many. Thinking in layers first makes the later packaging decision much clearer.

stackThe layers of a typical web application
L1
Presentation

The UI in the browser: a single-page app, server-rendered pages or a hybrid such as Next.js.

L2
API and edge

REST or GraphQL endpoints, authentication, rate limiting, caching and a CDN in front.

L3
Application and domain logic

Business rules, workflows, validation and background jobs. Most of the value and most of the complexity live here.

L4
Data

A relational database, plus a cache, search index, file storage or message queue where needed.

L5
Platform and operations

Hosting, CI/CD, logging, monitoring, backups and secrets management.

Architecture styles differ in how these layers are packaged and deployed, not in whether they exist.

DivTech System

Monolith: one codebase, one deployment

A monolith is built, tested and deployed as a single unit, usually backed by one database. It is the default output of most frameworks, from Django and Ruby on Rails to NestJS and Spring Boot, and it is a perfectly respectable architecture.

  • Strengths: simple local setup, one deployment pipeline, easy debugging with a single stack trace, database transactions that span the whole domain, and low hosting cost.
  • Weaknesses: as the code grows, unclear boundaries let every part depend on every other part. Build and test times grow, one bad release takes everything down, and scaling means scaling the whole application even if only one feature is busy.

The problem with most troubled monoliths is not that they are monoliths. It is that nobody enforced boundaries inside them.

Microservices: independent services, independent deployments

Microservices split the application into services that each own one business capability and its data, communicate over the network (HTTP, gRPC or a message broker) and are deployed independently. The main benefit is organisational: several teams can release on their own schedules without coordinating one big deployment, and each service can be scaled on its own.

The costs are just as real. Every function call that becomes a network call can fail or slow down. Data is spread across databases, so reports and transactions that span services need extra design such as events, sagas and read models. You need service discovery, distributed tracing, centralised logs, container orchestration and mature CI/CD before the first service goes live; our guide to Docker vs Kubernetes and our DevOps consulting service cover that platform work. Microservices pay off when several teams work on clearly separate domains, not when one team simply hopes to scale one day.

Serverless: functions and managed services

Serverless means you deploy functions or containers and the cloud provider runs, scales and patches the servers. You pay per request or per unit of execution time, and capacity can scale to zero when nothing is happening. AWS Lambda, Azure Functions and Google Cloud Run are common examples, usually combined with managed databases, queues and storage.

It shines for event-driven and spiky work: processing an image after upload, handling webhooks, generating scheduled reports, or an API with unpredictable traffic. It is weaker for long-running jobs (AWS Lambda, for example, caps a single invocation at 15 minutes), latency-sensitive paths affected by cold starts, and heavy steady traffic where an always-on server can cost less. Provider-specific triggers and configuration also make it harder to move clouds later.

comparisonMonolith vs microservices vs serverless
MonolithSimplest
  • One codebase and one deployment
  • Lowest operational overhead
  • Easy transactions and reporting
  • Scales as a whole unit
  • Risk: tangled code without internal boundaries
MicroservicesMost flexible
  • Independent releases per team
  • Scale and choose technology per service
  • Needs mature DevOps and observability
  • Distributed data and network failures to handle
  • Highest running and coordination cost
ServerlessPay per use
  • No servers to manage
  • Scales automatically, including to zero
  • Great for events, jobs and spiky APIs
  • Cold starts and execution time limits
  • Deeper tie-in to one cloud provider

verdictFor most new products built by one or two teams, a modular monolith with a few serverless functions for background work is the lowest-risk starting point.

DivTech System

The modular monolith: a sensible default

A modular monolith is deployed as one unit but organised internally as separate modules, each with a clear public interface and its own tables. You keep the operational simplicity of a monolith and gain boundaries that make later extraction possible. Frameworks such as NestJS and .NET have module systems that support this well, and the same discipline works in NestJS or Django.

  • Organise code by business capability (billing, catalogue, orders), not by technical layer.
  • Let modules talk only through public interfaces or internal events, never by reaching into each other's tables.
  • Enforce the rules automatically with architecture tests or lint rules, so boundaries survive deadlines.
  • Keep one database, but give each module its own schema or clearly owned tables.
  • Move slow or spiky work such as emails, exports and image processing to background workers or functions early.

How to choose for your situation

Two questions settle most decisions: how many teams will work on the system, and how uneven or event-driven is the workload?

decision matrixChoosing an architecture style
Spiky or event-driven workload (low to high) →
Modular monolith + functions

One team, uneven load. Keep the core together and push spiky jobs to serverless functions or queues.

Microservices + serverless

Several teams and event-heavy work. Split by domain and use managed, event-driven services where they fit.

Modular monolith

One team, steady traffic. The simplest option is also the cheapest to run and change.

A few well-bounded services

Several teams, steady load. Split along team boundaries, not into dozens of tiny services.

Number of teams working on the system (low to high) →
DivTech System

Also weigh your team's operating experience. A team that has never run distributed systems in production will move faster with a monolith, whatever the diagram says. Non-functional needs matter as much as structure: performance targets (see our Core Web Vitals guide), compliance, and multi-tenancy if you are selling one product to many customers (see SaaS web app must-haves).

Changing architecture later without a rewrite

If you already have a tangled monolith, a big-bang rewrite is rarely the answer. The strangler fig pattern is safer: put a routing layer in front of the old system, rebuild one capability at a time as a clean module or service, move traffic to it and retire the old code path. Each step is small enough to test and roll back. Start with the capability that hurts most or changes most often, and treat the clean-up as ongoing work, as described in our guide to managing technical debt.

Whatever you choose, record the decision in a short architecture decision record: the context, the options considered and why you picked one. When circumstances change, you will know exactly which assumptions to revisit.

Getting the foundation right

At DivTech we usually start new products as a modular monolith on Node.js or .NET, with clear module boundaries and background workers, and split out services only when a team or scaling need justifies it. If you would like a second opinion on your current architecture or a plan for a new build, request a quote and we will walk through the trade-offs for your product.

Frequently asked questions

Is a monolith bad for scalability?

No. A monolith can scale horizontally by running several copies behind a load balancer with a shared database and cache, and many large products run this way. The real limits are usually organisational, such as many teams in one codebase, or very uneven load across features, rather than raw traffic.

When should we move to microservices?

When there is a concrete reason: several teams blocked by a shared release process, one capability with very different scaling or security needs, or a part that must use a different technology. Team structure and domain boundaries matter more than traffic.

Can serverless be combined with a monolith?

Yes, and it is a common, practical setup. The core application runs as one service while background jobs, file processing, webhooks and scheduled tasks run as functions triggered by queues or events.

What is a modular monolith?

A single deployable application split internally into modules with clear interfaces and separate data ownership. It keeps operations simple while making it possible to extract modules into services later if needed.

  • Web architecture
  • Microservices
  • Serverless

free consultation

Need help with web development?

Talk to our Web Application Development team. We'll review your situation and suggest a practical next step, free.