Technical
How CaseOps Delivers Private Case Documents Quickly and Securely
Why CaseOps uses one delivery path for order sheets and another for Vault documents, and what that means for law firms operating from Pakistan.
CaseOps Team
6 min readWhen a law firm opens a case document, the problem is not just storage.
The problem is storage, privacy, latency, preview behavior, upload reliability, and access control, all at the same time.
That matters even more when the product is being used from Pakistan while core application infrastructure sits in Singapore. Every avoidable round trip shows up in the user experience. Every weak access path shows up as risk.
That is why CaseOps does not force every file through one identical document pipeline.
Today, we use one path for order sheets and another for broader Vault documents such as pleadings, applications, evidence, and judgments.
Why there are two delivery paths
These two document types behave differently in practice.
Order sheets are tightly tied to the hearing workflow. They are uploaded quickly, reviewed repeatedly, and used to update the next date, the hearing record, and the operational state of the case. They are almost always under 50 MB.
Vault documents are a wider private case corpus. They can be up to 200 MB, are more varied in format, and are more likely to be opened for reading, previewing, and AI-backed extraction across the life of a case.
Those are not the same access patterns, so we do not treat them as if they are.
Order sheets: private Supabase storage with signed access
Order sheets live in a private Supabase Storage bucket.
The bucket is org-scoped, and access is controlled through storage policies that check the authenticated user against the current organization. The viewing flow then uses signed access on top of that private storage path.
The upload path is designed for reliability:
- uploads use the resumable TUS protocol with 6 MB chunks
- interrupted uploads can resume instead of restarting
- each file path includes a unique identifier so a replacement upload does not silently reuse an older object
That last point matters more than it sounds. Court-facing workflows are messy, and replacement files happen. Unique object names reduce cache confusion and make the current file easier to reason about.
On the read side, CaseOps generates signed URLs through Supabase Storage and caches them in Redis. The current setup uses:
- a 7-day signed URL lifetime from Supabase
- a 6-day Redis cache window to avoid serving nearly-expired links
That gives the hearing workflow a stable read path without regenerating the same URL on every page load. Batch fetching lets us resolve URLs for multiple hearings in a single Redis round trip.
Vault documents: private S3 with CloudFront signed reads
Vault documents follow a different path.
Uploads are initialized by the app, but the browser does not stream the full file through the application server. Instead, CaseOps creates a Vault document record, asks the worker for a multipart upload session, and the browser uploads 10 MB parts directly to S3 using short-lived presigned URLs (currently a 1-hour TTL per part).
That split matters for performance and reliability:
- the app handles authorization and document metadata
- S3 handles the heavy file transfer directly from the browser
- multipart uploads reduce the cost of retrying large files
- the presigned part URLs expire quickly so each one is scoped narrowly
The S3 bucket uses KMS encryption with an auto-rotating key. Public access is blocked entirely. The bucket policy restricts read access to a single CloudFront distribution, and the KMS key policy is scoped to match.
Once a Vault file exists, CaseOps generates a short-lived CloudFront signed URL after authenticating the user and authorizing access to the specific document row via RLS.
The Vault read path works like this:
- The app verifies the user and the case-scoped document access via RLS.
- The app resolves the immutable S3 object key for that document.
- The backend signs a CloudFront URL using an RSA private key it holds.
- CloudFront validates the signature and fetches from the private S3 origin via Origin Access Control.
- The S3 bucket policy and KMS permissions are scoped to that CloudFront distribution only.
That means Vault document reads stay private end to end while still supporting fast previews.
The signed URL lifetime is intentionally short: 10 minutes by default.
CaseOps proactively refreshes that URL before it expires using a client-side timer, so the user does not have to think about the rotation. The security model stays tight, but the preview experience does not degrade into manual reloading.
We also attach Content-Disposition metadata during the multipart upload
creation so PDFs and images render inline consistently, instead of behaving like
a generic opaque download.
What this means for users in Pakistan
For a Pakistan-based team, the architecture choice shows up in a few practical ways.
First, the authorization and data-layer work still happens close to the rest of the application stack. That keeps the control plane coherent while the file-delivery layer does the work of getting bytes closer to the user.
Second, the upload path for order sheets is intentionally forgiving. If someone in chambers, at court, or on a weak connection loses network mid-upload, the TUS protocol resumes the transfer instead of forcing a full restart.
Third, Vault previews stay private while still supporting inline viewing, rather than pushing every document into a download-first workflow. The CloudFront edge network serves these reads from the nearest available location.
Fourth, stale uploads are cleaned up automatically. An EventBridge rule sweeps for incomplete multipart uploads after 24 hours, so abandoned transfers do not accumulate silently in storage.
Why we think this tradeoff is worth it
A common instinct in product engineering is to unify everything behind one storage abstraction as early as possible.
We do not think that is always the right first move.
In CaseOps, the better question is whether a document path matches the job it has to do.
For order sheets, that means resilient upload, private storage, and stable signed access around the hearing workflow.
For Vault documents, that means direct multipart upload to S3, KMS encryption, private origin access through CloudFront, short-lived signed reads, and a better preview path for a larger long-lived case record.
The architecture is different because the workflows are different.
That is the principle underneath the implementation.