Complete guide: Software architecture
Engineering12 min read

Software architecture for web applications: a practical guide for product teams

Architecture is not diagrams on a whiteboard. It is the handful of decisions that are expensive to change later, made deliberately and written down. This is how I approach them on CRMs, SaaS platforms and mobile backends.

Short answer

Good software architecture for web applications is a modular monolith on PostgreSQL with clear boundaries, a typed API, background jobs for slow work, and observability from day one. Split, cache or add infrastructure only when a measured problem asks for it.

01What software architecture for web applications means in practice

When people talk about software architecture for web applications, they often picture boxes and arrows: a load balancer, five services, a message bus. In practice, on a product team, architecture is much more modest and much more important. It is the set of decisions that are expensive to reverse once real users and real data depend on them.

Which framework renders the UI is reversible with effort. How tenants are separated, how records are identified, where business rules live and how data moves between systems are not. Those are the decisions I slow down for.

I have made these calls on call tracking platforms, healthcare CRMs, multi-branch reporting tools and an offline-capable expense tracker. The pattern that holds across all of them: start simple, make the boundaries explicit, and leave yourself room to change your mind. A scalable architecture is less about handling a million users on day one and more about not having to rewrite anything when you reach ten thousand.

  • Architecture is the set of decisions that are costly to reverse — identify them early and spend your thinking there.
  • Everything else should be easy to change, which is itself an architectural property.
  • The right architecture for a five-person team is different from the right architecture for a fifty-person team.

If you cannot name the three decisions in your system that would be hardest to undo, you have not done architecture yet — you have done setup.

02Layering and boundaries: where business rules should live

The single most useful architectural habit is deciding where business rules live, and keeping them there. In a typical Django or Node.js web application architecture I use three layers: a thin transport layer (views, controllers, API handlers), a service layer that holds the actual rules, and a data layer of models and queries.

Views parse input, call a service, and shape the response. They do not decide whether a lead is a duplicate or whether a payroll run can be approved. That logic lives in a service function that can be called from an API endpoint, a background job, an admin action or a test without dragging HTTP along with it.

This sounds like ceremony until the first time the same rule is needed in two places. A CRM that checks for duplicate leads in the web form but not in the CSV import, or a reporting tool that calculates a ranking one way on the dashboard and another way in the export, is almost always a system where rules leaked into views. One service function, called from everywhere, removes that whole class of bug.

Boundaries matter just as much between features as between layers. In a CRM, leads, policies, agents and billing are separate modules. Each owns its tables and exposes functions to the others. Billing does not reach into the leads tables and update a column directly; it calls the leads module. That one rule is what later makes a module extractable, testable and understandable by someone new.

  • Keep views and controllers thin: parse, authorise, delegate, respond.
  • Put business rules in plain service functions with explicit inputs, not in model save hooks or signals that fire invisibly.
  • Give each feature module ownership of its tables; other modules go through its public functions.
  • Treat cross-module imports as a design smell worth a second look in code review.

03Monolith vs microservices: why I start with a modular monolith

Every team eventually asks whether they should be using microservices. For small and medium teams my answer is almost always no — not yet. A well-structured monolith gives you one deploy, one database transaction, one place to search for code and one set of logs. Microservices trade all of that for independent deployment and scaling, which only pays off when you have independent teams and genuinely different scaling profiles.

What I build instead is a modular monolith: one deployable application with hard internal boundaries, as described above. It keeps the operational cost low while preserving the option to split later along lines you already drew. CallLoom, a large multi-tenant call tracking platform with dialers, recordings, QA, billing and webhooks, is one production system organised as backend modules — exactly this shape.

The full trade-off — including the concrete signals that mean it really is time to extract a service, and how to migrate without a big-bang rewrite — is in my deep dive on monolith vs microservices for small teams.

Microservices solve an organisational problem — many teams stepping on each other. If you do not have that problem, you are paying for a solution you cannot use.

04Data modelling with PostgreSQL: the decision that outlives the code

Code gets rewritten. Data stays. That is why I treat the database schema as the most important artifact in any system design, and why PostgreSQL is my default: real transactions, strong constraints, JSONB when you need flexibility, full-text and trigram search, and row-level security when you need a second line of defence.

A few rules have saved me repeatedly. Put constraints in the database, not only in application code — a unique constraint is enforced on every path, including the bulk import someone writes in a hurry. Use opaque identifiers such as UUIDs for anything visible in URLs or exports. Store money as integers or decimals, never floats. Record who changed what and when on any table that matters to a business process.

For SaaS products, the tenancy model is part of data modelling and the hardest decision of all to reverse. I wrote separately about choosing a multi-tenant isolation model because it deserves its own afternoon of thought.

Resist the urge to model for imagined future requirements. A generic "entity" table with key-value attributes looks flexible and becomes impossible to query, index or validate. Model the business as it actually is today, with real columns and real relationships, and use migrations to change it when the business changes. PostgreSQL migrations are cheap; a schema nobody understands is not.

  • Enforce uniqueness, foreign keys and not-null in the schema, not just in forms.
  • Design indexes from the queries you actually run, composite indexes in filter order.
  • Use migrations for every change, reviewed like code, and make them reversible where possible.
  • Keep an audit trail on business-critical tables from the start; retrofitting history is painful.

05API design: contracts that survive change

An API is a promise to every client that uses it — your own frontend, a mobile app, a partner integration. Breaking that promise is far more expensive than designing it carefully up front. I design APIs resource-first, with consistent naming, consistent error shapes and pagination on every list endpoint from day one.

Two details matter more than people expect. First, idempotency: any endpoint that creates something should accept a client-generated key, so a retry after a timeout does not create a duplicate. Second, versioning by addition: add fields, never repurpose them, and deprecate deliberately rather than silently changing meaning.

When the API talks to third parties rather than your own clients, the failure modes multiply. Retries, webhooks and reconciliation are covered in my notes on integrations that fail safely. If you need this built, my API development and integration service covers both internal and partner-facing APIs.

  • One error format across the whole API, with a machine-readable code and a human message.
  • Pagination, filtering and sorting on every list endpoint — never return unbounded lists.
  • Idempotency keys on creates; safe retries on everything.
  • Authorisation checked per object, not only per endpoint.

06Async jobs and queues: keeping requests fast

A request should do the minimum needed to answer the user and hand everything else to a background worker. Sending emails, generating PDFs, transcribing call recordings, processing file conversions, syncing with a third-party CRM — none of that belongs inside an HTTP request that someone is waiting on.

In Django I typically use Celery with Redis; in Node.js, BullMQ or a similar Redis-backed queue. The tool matters less than the discipline. Jobs must be idempotent because they will run twice. They must be small enough to retry cheaply. And they must be observable: you need to see what is queued, what failed and why, without opening a shell on a production server.

The trap is turning the queue into a hidden second application. If a job encodes business rules that do not exist anywhere else, you have split your logic in two. Keep the rule in the service layer and let the job just call it.

Scheduled work deserves the same care. Nightly reports, subscription renewals, reminder messages and data clean-ups all tend to start as a cron line on a server and end as a mystery when that server is replaced. Define schedules in code, alongside the jobs they trigger, and record each run so you can answer "did last night's billing job actually run?" without guessing.

Write every background job as if it will run twice and partially fail the first time. Eventually it will.

07Caching, search and pagination at scale

Caching is the most over-applied tool in web development. It makes things fast and it makes them wrong, and the second effect shows up later. I reach for it only after measuring, and I start with the cheapest layers: HTTP caching for public pages, then caching computed aggregates that change rarely, and only then caching query results with explicit invalidation.

More often, a slow page is a query problem, not a caching problem. A missing composite index, an N+1 loop in a serializer, or OFFSET pagination walking past thousands of rows will all disappear under a cache for a while and come back worse. Fix the query first.

Search and long lists are where this bites hardest. On Spendora I kept full-history search fast by switching to cursor-based pagination with matching indexes and trigram search — the full write-up with measurements is in keyset pagination for fast search in Django. The same approach applies to any CRM lead list or audit log that grows without limit.

  • Measure before caching; profile the query plan with EXPLAIN ANALYZE first.
  • Cursor pagination for large or fast-changing lists; OFFSET only for small, stable ones.
  • Count totals once, not on every page request.
  • Every cache entry needs a clear owner and a clear invalidation rule.

08Offline support and sync: designing for a bad network

Most web application architecture quietly assumes the network works. Mobile users, field agents and anyone on patchy connections prove otherwise. If your product will be used away from a desk, offline behaviour is an architectural decision, not a feature you add later, because it changes how identifiers are generated, how writes are applied and how conflicts are resolved.

The pattern I used for Spendora, an offline-capable expense tracker is an outbox: every change is written locally first, each new record gets a client-generated ID, and the server applies queued actions individually and idempotently. Nothing is lost when the connection drops, and nothing is duplicated when it comes back.

The details — queue design, conflict handling and what the server must guarantee — are in building an offline-first app with React Native and Django.

09Security by design, not as a final checklist

Security added at the end is mostly paint. The decisions that actually protect users are architectural: how sessions are stored, how authorisation is enforced, how tenants are isolated, what data you choose not to collect at all.

My defaults are deny-by-default permissions checked on every object, tenant scoping enforced in a default query manager rather than remembered per query, secrets kept out of code and logs, and the least data the product genuinely needs. For mobile clients, tokens go into the platform secure keystore, never plain storage.

Personal finance is a good stress test of these ideas, because users are rightly suspicious. I wrote a user-facing checklist on whether a personal finance app is safe that doubles as an architecture checklist for any app holding sensitive data.

Security also lives in the boring operational details: dependencies kept up to date, backups that are actually restored in a test now and then, separate credentials for staging and production, and admin tools that require the same authentication as the product. Most real incidents I have seen started with one of these, not with a clever attack.

  • Authorise per object, not just per route — "can this user see this record?" on every read.
  • Make tenant isolation the default, with an explicit escape hatch for admin queries.
  • Collect less: data you do not store cannot leak.
  • Rate-limit authentication and any endpoint that sends messages or costs money.
  • Log security-relevant events, but never log tokens, passwords or full payment details.

10Observability and decision records

You cannot operate what you cannot see. From the first deploy I want structured logs with a request ID that follows a call through the API and into background jobs, error tracking that groups exceptions, and a handful of metrics that matter to the business — not just CPU graphs. Alert on the absence of expected activity too: no webhooks in an hour is often a bigger problem than one failed webhook.

Good observability also changes how a team talks about performance and reliability. Instead of "the dashboard feels slow", you can say "the leads endpoint is slow for tenants with large histories because of one query", which is a problem someone can fix this afternoon. Without data, architecture discussions become opinions; with it, they become engineering.

The second half of operating a system over time is remembering why it looks the way it does. I keep short architecture decision records: one page per significant decision with the context, the options considered, what we chose and what would make us revisit it. They take ten minutes to write and save hours of re-arguing settled questions — and they are one of the clearest habits that mark what makes a senior developer different from a strong mid-level one.

A decision record does not need to be right forever. It needs to say what you knew at the time, so the next person can tell when the facts have changed.

11How architecture evolves — and how to work with me on yours

No architecture survives contact with growth unchanged, and it should not. The goal is evolvability: boundaries clean enough that you can extract a module, add a read replica, introduce a queue or move search to a dedicated engine without touching everything else. Evolve in response to measured pain, one step at a time, and record why.

A typical path I have seen work: a modular monolith on PostgreSQL, then background workers as slow tasks appear, then targeted caching and better indexes as data grows, then — only if team structure or scaling demands it — extracting one well-bounded service. Most products never need the last step, and that is a success, not a limitation.

If you are planning a new product or untangling an existing one, I design and build these systems end to end as a web application development service, with the backend on Django and PostgreSQL where it fits. For multi-tenant products, my SaaS development work starts with exactly these architecture decisions. Get in touch with a short description of what you are building and where it hurts today.

Topicssoftware architecture for web applicationsweb application architecturescalable architecturesystem design for web appsmodular monolithDjango PostgreSQL architecture

FAQ

Quick answers

For most new products, a modular monolith: one deployable application with clear internal module boundaries, a PostgreSQL database, a well-designed API and background workers for slow tasks. It is cheap to run, easy to change and can be split later if the team or load genuinely requires it.

When several independent teams need to deploy separately, or when one part of the system has a scaling or reliability profile very different from the rest. Without one of those pressures, microservices usually add operational cost without a matching benefit.

Yes. PostgreSQL handles transactions, constraints, JSON data, full-text search and row-level security well, and with proper indexing and pagination it comfortably supports the vast majority of business applications before any sharding or specialist database is needed.

A short document capturing one significant technical decision: the context, the options considered, the choice made and the conditions under which it should be revisited. It stops teams re-arguing settled questions and helps new developers understand why the system looks the way it does.

Measure first, then fix queries before adding caches: add indexes that match real filters, remove N+1 queries, use cursor pagination for long lists and move slow work into background jobs. Cache only what you can invalidate reliably.

Keep reading

All articles

Projects behind this article

The production systems where these decisions were made.

All case studies
  • CallLoom Dashboard — Call tracking SaaS project preview
    Call tracking SaaSDialer system

    CallLoom Dashboard

    An inbound and outbound call tracking SaaS with dialers, recordings, AI transcription, routing, Stripe billi…

    Read case studyLive
  • Spendora Expense Tracker App — Mobile app project preview
    Mobile appPersonal finance

    Spendora Expense Tracker App

    Spendora is an Android expense tracker and budget app built with Expo React Native and Django: income, expen…

    Read case studyLive
  • Healthcare Lead Generation CRM — SaaS project preview
    SaaSCRM

    Healthcare Lead Generation CRM

    A production CRM and lead tracking system for a US healthcare client, built with React, Django, Python, AI d…

    Read case studyLive
  • Veeivs Reporting Analytics Platform — SaaS reporting project preview
    SaaS reportingAnalytics dashboard

    Veeivs Reporting Analytics Platform

    A SaaS reporting and ranking platform for multi-branch performance: live centre stats, agent and team lead r…

    Read case studyLive

Related services

If this describes a problem you have right now, these are the ways I can help.

All services
  • Web Application Development

    A web application is different from a website: logged-in users, real data, permissions, and workflows that have to k…

    Explore service
  • Django & Backend

    The backend is where a product either scales or quietly rots. I design data models that match the business, APIs tha…

    Explore service
  • API & Integrations

    Integrations fail quietly. I build them with retries, logging and clear failure states, so when a third-party servic…

    Explore service
  • SaaS Development

    Taking a SaaS idea to paying customers means solving multi-tenancy, billing, permissions and analytics before you wr…

    Explore service