Lawfare Group → Knowledge Institute → Lawfare Academy
← CS 220 — Web Applications, SQL and Software Engineering
Weeks 15–16
Integrated application architecture and tradeoffs
Learning objectives
- Explain and trace the mechanisms in integrated application architecture and tradeoffs.
- Apply the method to the worked example and changed-condition exercise.
- Identify assumptions, failure cases and the evidence needed to justify a result.
Architecture allocates responsibilities across components. In a small web application, the browser presents information and captures input; the server validates requests and applies authorization; the database persists constrained records. Making the browser responsible for privileged rules exposes them to bypass. Making every operation one large server function can make changes difficult to reason about. Boundaries should follow responsibilities rather than fashionable terminology.
Caching improves performance only when stale data is acceptable under a specified policy. Public educational descriptions and private customer orders have different privacy and freshness requirements. A cache key missing the user identity can expose another account's response. Likewise, a static page export cannot replace a server application that depends on authenticated APIs and persistence. Deployment format is part of the architecture.
Evaluate alternatives using the actual workload. A single relational database and server can be more suitable than a collection of services for a modest application. Distributed components add partial failures, retries, identity propagation and observability needs. Describe when the simple design would stop meeting requirements. A readiness review should trace one request end to end, including an invalid input, a denial, a database error and a retry, then demonstrate that the resulting state remains coherent.
Worked reasoning The function illustrates a privacy-first classification, not a complete HTTP caching implementation. The route must actually attach the returned header and avoid another layer overriding it. A shared cache must never store private responses merely because the URL path is the same for all users. Test the real response headers as part of deployment validation.
Extended teaching and laboratory
A cache stores representations under keys. If two users request the same URL but receive private data, a shared cache keyed only by URL can cross the privacy boundary. Correctness therefore depends on cache policy, key design and authentication handling at every layer. A route returning private content should not rely on a visual sign-in screen to protect a previously cached response.
A deployment plan also needs operational evidence: detect failure, identify the affected version and recover consistently. A successful health response may prove only that a process is alive. Include a readiness check that exercises essential dependencies without exposing private data.
Worked problem Customer A loads /orders and a proxy caches the body publicly for ten minutes. Customer B opens the same URL. Explain the risk and a verification procedure.
Step-by-step reasoning 1. The proxy may serve A’s body before the origin checks B’s identity. Origin authorization cannot repair a response already returned from an unsafe shared cache.
- For the private response use an appropriate private/no-store policy and configure the shared layer consistently. Do not infer that one header controls every intermediary.
- Test with two authenticated accounts and separate sessions, verifying bodies and actual response headers through the public deployment.
- Invalidate unsafe cached objects if they existed. A future policy change alone may not remove content already retained.
Apply the idea
Customer A loads /orders and a proxy caches the body publicly for ten minutes. Customer B opens the same URL. Explain the risk and a verification procedure.
The homepage is healthy while every order request fails because the database is unavailable. What does the homepage check establish?
Read the worked reasoning
It establishes that the homepage can respond, not that the order workflow is ready. Add a bounded dependency/readiness check and a real synthetic order-read scenario using fictional data. Distinguish liveness from readiness, avoid logging credentials, and define rollback or degraded behavior when persistence is unavailable.
Check understanding
What should guide architecture choices first?
- Workload, constraints, trust boundaries and failure behavior
Feedback
Architecture should address concrete responsibilities and constraints.
- The largest possible number of services
Feedback
More components increase coordination cost and may not solve a need.
- Whatever hides the most errors from the visitor
Feedback
Failures need understandable recovery and diagnostic evidence.
Further reading
Study the complete on-site source sections below, then work the original example, changed-condition problem and transfer laboratory. Complete the remaining assigned CS50 Web and SQL project material. Build the Academy work-order application independently and explain each design choice.