You architect a web app by deciding, before you write much code, how the system splits into parts—client, server, data, and the seams between them—and then writing those decisions down as constraints the team can enforce. The key condition is that architecture follows requirements, not fashion: a two-person team shipping an internal tool needs a different shape than a company handling millions of concurrent users. Get the decomposition and boundaries roughly right early, and most later features slot in without rewrites.

The steps below run in a workable order, from understanding the problem to documenting and evolving the design. Each one produces an artifact—a list, a diagram, a measured number—so you can tell whether it worked. Examples lean on a representative case: a subscription scheduling app with accounts, billing, notifications, and a reporting dashboard. Adjust scale to your own situation; the sequence holds even when the shape changes.

Step 1: Pin Down the Requirements That Actually Change Architecture

Architecture responds to a small set of forces, and only a few of them are technical. Before drawing anything, write down what the app must do and for whom, using numbers wherever the number is knowable.

Prerequisites: access to whoever owns the product, plus any existing usage data or contracts.

1: List the core user journeys in one sentence each—"a customer books a slot," "an admin exports last month's invoices." 2: Attach scale figures: expected accounts at launch and in year two, peak concurrent users, read-versus-write ratio, and data volume per year. If nobody knows, mark the number as an assumption and note who will confirm it. 3: Write the latency and availability targets in plain terms. "Search results under 500 milliseconds for 95 percent of queries" and "checkout available during business hours" are architecture inputs; "fast" and "reliable" are not. 4: Record hard constraints: budget ceiling, team size and skills, regulatory rules about where data lives, existing systems it must talk to, and required browsers or devices. 5: Separate must-haves from nice-to-haves. Anything in the nice-to-have pile is not allowed to complicate the design yet.

Success check: a person who has never seen the project can read your list and predict which parts of the system will be under the most pressure. If everything is labeled critical, the list hasn't done its job—force a ranking.

The most common failure here is skipping the read/write split. A scheduling app where customers read availability constantly and write bookings rarely is shaped very differently from one where writes dominate. That single ratio, confirmed against the requirements list, will justify or rule out a lot of later choices.

Step 2: Choose the Overall Shape Before Choosing Tools

The system's shape—monolith, modular monolith, services—is the biggest lever, and it should be pulled based on team size and operational maturity rather than ambition.

A single deployable application containing all server logic is the right default for most new projects, especially with fewer than roughly a dozen engineers. It's simpler to run, simpler to debug, and lets you refactor across boundaries freely while the domain is still poorly understood. A modular monolith keeps that single deployment but enforces internal module boundaries—say, a billing module that never reaches directly into the scheduling module's tables—so you can split later without archaeology.

Microservices, where each capability deploys and scales independently, pay off when different parts of the system have genuinely different scaling or release rhythms, or when separate teams need to ship without coordinating. They cost you network calls, distributed failure modes, and operational overhead. Splitting a four-person team's app into eight services is a classic way to ship nothing.

The decision rule I'd apply: start monolithic, draw module boundaries as if they were service boundaries, and promote a module to a service only when a measured pressure—a scaling bottleneck, a conflicting release cadence, an organizational split—makes the overhead worthwhile. As a rough illustration, a modular monolith on one mid-sized server might handle tens of thousands of daily active users with plenty of headroom; the point is that the ceiling is usually higher than the instinct to split suggests.

Success check: you can name every place the client talks to the server (one API surface, in the monolith case) and explain what would have to change to extract a module later.

Step 3: Separate the Layers and Draw the Dependency Direction

Inside that shape, organize code into layers with an explicit rule about which way dependencies point. A workable four-layer split:

Presentation (the client app and any server-rendered views): renders state, handles input, calls the API. Application/API: validates requests, enforces authentication and authorization, orchestrates use cases. Domain: the business rules themselves—booking conflicts, proration math—independent of frameworks where practical. Infrastructure: database access, email and payment integrations, file storage, queues.

The rule that matters: domain logic depends on nothing outward. Infrastructure implements interfaces the domain defines. Presentation talks only to the API layer. This is what makes business rules testable without a database and replaceable without a rewrite.

A concrete illustration from the scheduling app: when a customer reschedules, the rule "a slot may be booked at most once, and reschedules inside 24 hours incur a fee" belongs in the domain layer. The HTTP handler parses the request and calls it; the database adapter saves the result. If the fee logic lives in a controller, you'll duplicate it, forget one copy, and discover the discrepancy in an invoice dispute.

Success check: pick a business rule at random and locate exactly one place in the codebase that enforces it. If you find two, the layering has leaked.

Step 4: Pick a Data Model and Database to Match the Access Pattern

Data decisions outlast everything else, so make them deliberately. Start from the questions the app must answer, then choose a database that answers them cheaply.

Prerequisites: the read/write ratios and data volumes from Step 1.

1: Model the entities and their relationships: accounts, slots, bookings, invoices, notification records. Write the relationships down explicitly—one account to many bookings, one booking to one invoice. 2: Write the five to ten most frequent queries in plain English, then sketch how each would run. "Show all available slots for a provider next week" and "sum billable hours per account per month" have different shapes. 3: For a relational workload—entities with relationships, transactions that must be atomic, reporting that joins across tables—choose a relational database. That covers most business applications, including this one. 4: Reach for a document store when the data is genuinely document-shaped and read as a unit, a key-value store for caching or session state, and a search engine when full-text relevance ranking is core rather than bolted on. 5: Decide the consistency you need. For anything involving money or double-booking, wrap the relevant writes in a transaction so partial failures can't leave two bookings on one slot.

Success check: your top queries each map to an index you can name, and the money-touching operations each sit inside a transaction boundary. If a critical write spans two systems with no compensation plan, stop and redesign that step—this is the point where further work needs someone experienced in distributed transactions, not more diagrams.

Schema design deserves its own pass. Normalize the transactional core so updates happen in one place, then denormalize deliberately for read-heavy reporting, documenting the trade-off. Migrations should be versioned and runnable in both directions from day one; retrofitting migration discipline onto a live database is painful.

Step 5: Design the API Contract as a Product

The API is the seam between client and server, so define it before implementation so both sides can proceed in parallel.

For most apps, HTTP resources with JSON—GET a collection, POST to create, PATCH to update—are a sound default: predictable, cacheable, well-supported by tooling. Choose a typed RPC style like gRPC when many internal services need high-throughput, strongly typed calls and you control both ends. GraphQL earns its keep when clients with varied data needs—say, a mobile app and a dashboard—would otherwise make many round trips; it costs you query complexity controls and caching nuance.

Practical rules that prevent most integration pain:

Version the API in the path (for example, /v1/) and treat published fields as promises. Use consistent status codes and one error envelope: a machine-readable code, a human message, and a request identifier for support. Paginate every list with a documented cursor scheme; unbounded lists are a denial-of-service waiting to happen. Return only the fields the caller needs; over-fetching leaks your schema and bloats payloads. Put idempotency keys on creation endpoints that handle payments or bookings, so a retried request doesn't double-charge.

Success check: a client developer who has never read your server code can integrate a new screen using the contract alone. If they need to ask what a field means, the contract is incomplete.

Step 6: Handle State, Sessions, and Authentication

Most web apps need to know who is making a request and what they're allowed to do. Decide this early because it threads through every layer.

Server-side sessions with an opaque session identifier stored in an HttpOnly, Secure, SameSite cookie are hard to beat for typical web apps: revocable instantly, invisible to JavaScript, simple to reason about. Store session data in the database or a shared cache—not in server memory—so it survives restarts and works across multiple server instances. Signed tokens (JWTs) suit stateless APIs and service-to-service calls, but revocation is the catch: a stolen token stays valid until expiry unless you maintain a denylist, which reintroduces state. Keep token lifetimes short and pair them with refresh tokens you can revoke.

For authorization, enforce checks server-side on every request, never only in the client. A pragmatic structure is role-based access for coarse permissions (admin, provider, customer) layered with resource-level checks ("does this booking belong to this account?"). The second check is the one that gets forgotten and the one attackers test.

Success check: removing all client-side JavaScript still leaves every protected action guarded. Test by calling the API directly with a different account's identifier—it should fail with a clear 403.

Step 7: Decide Where Rendering Happens

The rendering choice affects perceived speed, SEO, and how much state the client juggles.

Server-rendered pages that ship HTML are excellent when content must be indexed by search engines or when clients are underpowered—marketing pages, dashboards that must appear fast. A client-side single-page app gives rich interactivity and smooth transitions after the first load, at the cost of a larger initial bundle and a period where the shell is blank. Hybrid approaches—server-render the first paint, then hydrate into an interactive app—try to capture both, with added build complexity.

For the scheduling app, a sensible split: the public availability page and booking flow server-rendered for speed and search visibility, the admin console a single-page app because it's used repeatedly by a small group. Decide per surface, not per company.

Success check: measure first-contentful paint and time-to-interactive on a mid-range phone over a throttled network. If the marketing page takes more than a couple of seconds to show meaningful content, rendering strategy deserves another look.

Step 8: Make Failure, Caching, and Background Work Explicit

Systems fail in predictable places, and architecture is largely the practice of deciding what happens next.

Caching reduces load and latency but introduces staleness, so cache the layers where staleness is acceptable. HTTP cache headers on public, rarely changing responses; a shared in-memory or Redis-style cache for expensive queries with short time-to-live; client-side caching of reference data. Always name the invalidation trigger—time-based expiry, explicit eviction on write, or version tags in cache keys.

Background work belongs off the request path. Sending emails, generating reports, and syncing billing on every request will make latency unpredictable and failures user-visible. Push those tasks onto a queue with a worker that retries with backoff and records permanent failures for inspection. The request handler enqueues and returns; the queue is the buffer that absorbs spikes.

Resilience basics: set timeouts on every external call, add retries only where operations are idempotent, use circuit breakers so a slow payment provider doesn't tie up your capacity, and design health checks that distinguish "process alive" from "can serve traffic." Back up the database on a schedule and actually restore a backup into a test environment—an untested backup is a hope, not a plan.

Success check: kill the payment provider's availability in a test environment and confirm the app degrades gracefully (queue, retry, clear error) rather than hanging or corrupting state.

Step 9: Set Up Deployment, Observability, and Security Baselines

Architecture isn't finished until it can run and be seen running.

Containerize the app for a consistent image across environments. Separate configuration by environment variables, never committed secrets. Run at least two instances behind a load balancer when availability matters, and put the database in a managed service with automated backups if the budget allows—operating a database well is a specialty. Deploy through a pipeline that runs tests and runs migrations as a step with its own review. For rollouts, prefer strategies that let you reverse quickly: blue-green cutover or canary releases to a small share of traffic.

Observability means three things wired together: structured logs with request identifiers correlated across services, metrics for request rate, error rate, latency percentiles, and queue depth, and traces that follow one request across layers. Pick a single request identifier scheme and thread it everywhere. Alerts should fire on symptoms users feel (error rate, latency) rather than on raw CPU alone.

Security baseline, in order of payoff: use the framework's parameterized queries (SQL injection is a solved problem if you don't concatenate strings); escape output to prevent cross-site scripting; validate and encode on both sides; enforce the authorization checks from Step 6; set security headers; rate-limit the login and other sensitive endpoints; and keep dependencies patched with an automated update process. Store passwords with a modern adaptive hash (Argon2 or bcrypt) and never in reversible form.

Success check: you can answer "what was the slowest request in the last hour and why" and "which deployment introduced a given error" from your dashboards without SSH-ing anywhere.

Step 10: Document the Decisions and Evolve on Evidence

Write the architecture down as a short, living document: a one-page system diagram, the layer and module boundaries, the API surface, the data model, and a decision log. For each significant choice, record the context, the options considered, the decision, and the consequences—this is what prevents the same debate every six months and tells future teammates why the odd-looking thing exists.

Then let the design change on evidence. Watch the metrics from Step 9 for the signals that justify evolution: one module's traffic outgrowing the rest, a release cadence conflict, a query with an index that can't keep up. Promote to a service when the measured pressure is real; introduce the queue when latency spikes trace to synchronous work. The failure mode to avoid is evolving on fashion—rewriting into microservices with no bottleneck to justify it.

Success check: a new engineer can get oriented from the document alone, and the decision log has more entries than the architecture diagram has boxes. If it hasn't changed in a year on a live project, one of you is lying to the other.

Trade-offs to Recognize Before You Commit

A few decisions cause outsize downstream pain, so hold them consciously:

Monolith versus services: start together, split on pressure. Reunification is rare and painful. Relational versus NoSQL: relational defaults handle relationships and money safely; reach for other stores for specific strengths, not to escape schema work. Stateful sessions versus tokens: sessions simplify revocation; tokens simplify horizontal scale. Pick based on whether you run the servers and need instant logout. Client-side versus server rendering: interactivity versus first-paint speed. Often you want both, per surface. Build versus buy: authentication, payments, and email are well-served by specialists; the core differentiator is seldom one of these. Buy where the cost of getting it wrong exceeds the cost of adapting.

A Worked Illustration: Applying the Steps to the Scheduling App

Assuming roughly 10,000 accounts at launch, an expected 100 concurrent users at peak, reads outnumbering writes about 20 to 1, one team of six engineers, and a paid-subscription model. Following the steps: a modular monolith for the server, a relational database with transactional booking writes and indexed availability queries, a REST JSON API with versioning and an idempotency key on booking creation, session cookies for the customer surface, server-rendered public pages plus a single-page admin console, reads cached for a few seconds with explicit expiry, email and invoice generation queued, and two app instances behind a load balancer with health checks.

The interesting numbers are the constraints, not the stack. At 100 concurrent users and a 20-to-1 read ratio, a single well-indexed relational database with a small cache is comfortably within range—you would want to measure rather than trust that, and the observation is that traffic rarely arrives as modeled. The queue exists because sending email inline would add hundreds of milliseconds to a booking request and turn a mail outage into a booking outage.

What you should expect to check after launch: p95 latency on the availability query, queue depth during the daily report window, and session-store performance across instances. Those three measurements will tell you whether the next evolution is caching, indexing, or splitting the reporting module.

Common Mistakes That Cost the Most

Choosing tools before requirements. Pick the database after the queries, not before. Leaking business rules into controllers. They'll be duplicated, and the copies will diverge. Trusting client-side authorization. Every check must exist server-side. Ignoring migration strategy. Schema changes without a versioned path are how Saturday evenings get ruined. No observability until something breaks. Instrument during build, not during the incident. Over-splitting. Every service boundary between two people is a communication cost. Skipping the restore test. The backup isn't real until you've restored it in a test environment.

Where to Stop and Get Help

If your design requires strong consistency across a distributed write path, handling regulated personal or payment data, or a 99.99 percent availability commitment, that's a stop condition: bring in someone with direct experience in those constraints before committing, rather than after launch. Similarly, if you can't name an index for your top queries or a fallback for your payment provider outage, pause implementation on that piece. These are not disqualifications—they're the points where a few hours of expert review saves months.

Architecture is the set of decisions that are expensive to reverse, so the goal isn't a perfect design. It's a design that makes the cheap decisions regular and the expensive ones rare, visible, and documented. Build the smallest shape that satisfies the requirements you can defend, measure it in production, and let the evidence—not the mood of the room—drive the next change.