Doksign
Fast, account-free digital contract signing & team document platform
When I took on the engineering for Doksign's, our biggest challenge was that we were moving from simple document signing into automated contract drafting with generative AI. Generating long legal clauses and reviewing complex PDF contracts uses a massive amount of AI computing power, meaning that without careful management, our AI server bills could easily outgrow our subscription revenue. At the same time, we needed a payment pipeline that never loses transactions, verifiable records for legal workflows, and large corporate customers expected instant, branded workspaces without waiting on manual engineering setup. All of that had to sit on a frontend fast and accessible enough for long, complex documents, so we could launch a paid product that felt effortless for every user.
Here is an understanding of what was broken, how I fixed it, and the results.
§1. Keeping AI Contract Drafting Profitable
Doksign introduced tools that actively help users draft contracts and write legal agreements from scratch rather than just reading documents. Because generating long contracts burns through massive amounts of AI tokens, letting users run unlimited drafting prompts on standard plans would quickly make the business lose money.
To make sure AI features stay profitable at any scale:
- ›I built a credit metering system that tracks token usage in real time, checking a user's credit balance before running requests so accounts never draft beyond their plan limits.
- ›I routed our high-volume contract writing through a cost-effective AI gateway that cut our operating costs dramatically while maintaining the high reasoning quality required for legal documents.
- ›I introduced instant credit top-ups, turning AI usage from an unpredictable expense into a profitable growth stream for the business.
Because of this system, our AI unit economics remain healthy and predictable, allowing the business to scale users without fear of runaway server bills. It also logs every single AI action against the credit ledger, giving us the data we need to eventually power document features with cheaper, specialized models of our own instead of expensive third parties.
§2. Letting Users Bring Their Own AI Keys Safely
Users often want to use their own AI provider accounts instead of our built-in one so as to take advantage of provider discounts, spend credits they already have or satisfy their own privacy and compliance requirements.
To support this for any user without putting our platform at risk:
- ›I built a secure credential vault where users can safely store their own API keys with full audit tracking.
- ›I made a deliberate architectural rule that user-provided keys are strictly used for interactive drafting sessions in the browser, keeping our heavy background processing queues on our own managed infrastructure.
This protected our servers from outside API outages or rate limits, giving users the flexibility they wanted without ever compromising platform stability.
§3. Making Sure Billing and Payments Never Fail
When it came time to launch paid subscription tiers, our checkout pipeline had to be completely dependable, yet early versions were vulnerable to network timing bugs, where a dropped connection during checkout could charge a customer's card without unlocking their Pro plan, or grant extra credits on accidental retries.
To ensure 100% billing accuracy, I overhauled the entire payment processing pipeline to verify every transaction cryptographically so that every purchase is processed exactly once even if payment providers send repeated notifications, set up strict verification rules so the system only unlocks features when an incoming payment matches a transaction our application actually started, and designed the subscription lifecycle to cleanly handle mid-cycle upgrades, seat additions, and automatic proration.
This eliminated billing mismatches and lost revenue, guaranteeing that every customer gets their paid features unlocked instantly with zero support tickets.
§4. Automating Instant Custom Domains
Any paid user can get a custom-branded web address (like acme.doksign.com) for their workspace, and enterprise clients expect theirs to be ready immediately. Manually configuring subdomains and waiting around for DNS updates was eating up engineering hours and slowing down signups across every plan.
To make onboarding instant:
- ›I built an automated workspace setup engine that automatically provisions subdomains and manages digital SSL security certificates in the background.
- ›I configured automated health checks that test the domain connection and unlock the isolated branded workspace the moment verification passes.
This removed engineers from the onboarding loop entirely, allowing new paid users to start drafting and signing contracts under their own brand immediately upon signing up.
§5. Keeping Verifiable Records of Every Action
In digital signing, legal teams and HR departments often need proof that a document was really sent and really signed on time not just a claim that an email went out. Ordinary activity logs were never enough to satisfy that kind of compliance.
To make our records trustworthy evidence:
- ›I built a permanent, tamper-proof audit trail that records every meaningful action—who sent a document, when, and when it was signed—so nothing can be quietly changed or deleted later.
- ›I made these records easy to produce on demand, so we can hand customers verifiable legal proof of their document workflows instead of a simple "email sent" log.
This turned the platform into a source of evidence our customers can rely on in audits or disputes, without us having to dig through scattered logs.
§6. Making the App Truly Accessible
Business software should be usable by everyone, regardless of how they navigate the web, and in document signing, accessible interfaces are also a legal requirement for enterprise clients.
To make accessibility a guarantee rather than an afterthought:
- ›I made sure the entire contract viewer and signature flow can be operated completely with just a keyboard.
- ›I set up proper focus trapping on modals, meaningful screen-reader announcements when document states change, and strict color contrast standards across all themes.
- ›I integrated accessibility linting into our frontend builds so accessible design is enforced from the start instead of drifting over time.
As a result, every user can draft, review, and sign documents using whichever tools work best for them, and we meet the accessibility expectations our enterprise clients are held to.
§7. Handling Long PDF Contracts Without Freezing
Loading 50-page legal PDFs and interactive drafting tools can easily freeze a browser if not handled carefully, which quickly turns heavy documents into a frustrating experience.
To keep things smooth even on modest hardware:
- ›I made sure heavy rendering and text extraction happen off the main UI thread using web workers.
- ›I added smart virtualization so the browser only renders the contract pages and clause items currently visible on the screen.
This keeps scrolling butter-smooth at 60fps, even on low-end laptops and mobile devices, so large contracts never feel heavy.
§8. Building a Shared, Reusable Component System
When engineers build buttons, modals, and dropdowns from scratch in different parts of an app, you end up with visual inconsistencies and subtle bugs that are expensive to find later.
To give the team a solid foundation:
- ›I established a shared design system with accessible, reusable UI primitives.
- ›Every component comes with keyboard support, smooth micro-interactions, and clear state handling for loading, disabled, and error built right in.
This meant any engineer on the team could assemble complex new flows in hours instead of days, with consistent quality and zero guesswork.
§9. Keeping Users Informed During Heavy Tasks
Users hate staring at frozen screens with no feedback when something takes a few seconds, and AI-powered drafting can take longer than that.
To keep the interface honest and reassuring:
- ›I designed clear, optimistic UI states and real-time progress indicators for heavy jobs like AI clause generation and document conversion.
- ›If a network blip occurs or an external API stumbles, the interface handles it gracefully with automatic retries and clear, human-readable messages instead of generic error popups.
This keeps users confident that their work is progressing, even when a request takes a while or hits a temporary hiccup.
§10. Reliable Testing and Launching on Schedule
Preparing for the public launch meant coordinating contract drafting tools, PDF reading utilities, and automated signing reminder emails all at once, with very little room for surprises.
To make sure everything shipped without surprises:
- ›I built the core tool that reads PDFs and helps users quickly draft, review, and comment on legal agreements.
- ›I added automated email reminders that keep signing deadlines on track so documents don't sit forgotten in inboxes.
- ›I wrote comprehensive automated tests across our billing, AI processing, and authentication flows, and set up end-to-end checks for our most critical user flows like signing a contract and upgrading a subscription.
- ›Before going live, I made sure the team documented exactly what had been tested and which edge cases could still go wrong, so we shipped knowing the risks instead of just hoping for the best.
- ›I also tracked down and fixed a persistent issue that was making our test tooling crash randomly, saving the whole engineering team hours of frustration.
Thanks to this preparation, we launched the Pro plan on schedule with zero downtime, dependable payments, and a smooth experience for all our users.