💡 Inspiration

Every founder building in Southeast Asia hits the same wall early: you need an NDA before a partner meeting, an employment contract before your first hire, a service agreement before taking on a client. The options are all bad — a lawyer charges IDR 3–15 million / SGD 350–1,200 per document and takes days, while existing self-serve tools each cover only one jurisdiction. LegalZoom is US-only, Zegal is Singapore-only and subscription-locked, KontrakHukum is Indonesia-only and human-assisted.

But most SEA startups operate across both Indonesia and Singapore at once. We wanted one platform that drafts trustworthy, law-referenced documents for both — in minutes, not days.

⚙️ What it does

LexSEA generates three document types (NDA, fixed-term employment / PKWT, and service agreement) across two jurisdictions (Indonesia & Singapore). You pick a document and jurisdiction, answer a plain-language questionnaire, and download a sign-ready PDF.

The key idea: every binding clause is deterministically assembled from a validated clause library — never written by a language model. Each clause cites its legal basis (e.g. UU No. 30/2000 on Trade Secrets, Employment Act 1968), so the output is auditable and reproducible. AI is used for exactly one optional, non-binding thing — a short background recital — and it's fully fail-safe.

🛠️ How we built it

  • Frontend & API: Next.js 16 (App Router) + React 19, deployed on Vercel.
  • Database: Amazon RDS for PostgreSQL is the system of record — it stores the clause library, clause conditions, questionnaire fields, document types, jurisdictions, users, and an audit log.
  • Assembly engine: the /api/document/assemble route runs selectClauses (required clauses + conditional clauses whose conditions match the user's answers), interpolates {{placeholders}}, and stitches the document together.
  • AI recital: Anthropic's Claude generates an optional background paragraph, tightly constrained ("use only the provided facts, invent nothing, no operative clauses") with a 15-second timeout. If it's slow, unavailable, or refuses, it returns null and the document assembles anyway.
  • PDF: @react-pdf/renderer renders client-side with real legal typography — a materai stamp block and BANI arbitration for Indonesia, "for and on behalf of" signature blocks and SIAC for Singapore.
  • Auth: JWT via jose in an httpOnly cookie + bcryptjs, with a constant-time login compare. A Pro tier adds custom company letterhead and branding.

🧗 Challenges we ran into

  • Keeping legal content trustworthy. Our biggest design decision was not letting an LLM write binding text. We invested instead in a structured clause library and a deterministic selection engine — the LLM only ever touches a non-binding recital.
  • Turning flat text into a formatted legal PDF. We built a parser that classifies each paragraph (PASAL headings, numbered Singapore clauses, lettered sub-items, two-column signature blocks) and renders each with the correct typography.
  • Bilingual number-to-words. Indonesian contracts spell out amounts ("Delapan Juta Rupiah") — we wrote number-to-words converters for both Bahasa Indonesia and English.
  • Right-sizing the AWS database. We initially over-provisioned Aurora and watched the bill climb fast; learning to match the database tier to an actual workload was a real lesson.
  • Making AI a true add-on, not a dependency. We engineered the recital to never block or break document generation — graceful degradation was harder to get right than the happy path.

📚 What we learned

  • When not to use an LLM. For correctness-critical domains like legal text, deterministic assembly from a validated source beats generation every time — and it's auditable.
  • Fail-safe AI integration is a discipline. Treating the model as an optional enhancement (timeouts, null-handling, "skip on failure") makes the product robust rather than fragile.
  • Cloud cost is a design constraint. Choosing the right AWS database configuration matters as much as the schema.

🚀 What's next

  • Server-side PDF generation with watermarking to enforce the Free/Pro tiers.
  • More document types (loan agreements, founder/SAFE docs) and more jurisdictions (Malaysia, Vietnam).
  • Lawyer-reviewed clause versioning with change history.
  • Automated tests over the assembly pipeline (golden files per document × jurisdiction).

⚠️ LexSEA generates documents from a validated template library for informational purposes. It is not legal advice and LexSEA is not a law firm.

Built With

Share this project:

Updates