Skip to content
LiveSaaSYargıtay · AYM · Danıştay · BAM

CestaLex

An AI legal assistant for lawyers: case-law search, drafting, contract review and UYAP in one app

Role
Backend & infrastructure
Period
2026 —
Status
Live

By the numbers

12M+
decisions from six official sources
12+
modules: search, drafting, contracts, calendar…
3
day free trial, no card needed
0
manual invoicing steps

Overview

cestalex.com tries to put a Turkish lawyer's daily work in one place. You search more than 12 million decisions from Yargıtay, the Constitutional Court, Danıştay and the regional courts in your own words, draft petitions in an editor that cites its sources, upload a contract and get the risky clauses flagged, and pull hearings and deadlines from UYAP into a calendar. I built the whole backend.

  • Search: decisions are stored as vectors in Qdrant and matched by meaning. Filters by chamber, year and field of law; citations copy in Turkish, APA 7 or OSCOLA format with one click.
  • Drafting editor: the assistant writes the draft, but not a single character changes until you approve it; old and new text sit side by side. Output is .docx, .udf or straight to UYAP.
  • Contract review: an uploaded contract is split into clauses, risky ones are flagged high, medium or low against the Code of Obligations, and missing standard clauses are listed.
  • Each firm sees only its own data. I didn't leave that to application code; it's enforced in the database with PostgreSQL Row-Level Security.
  • Payments through iyzico, invoices issued automatically as e-arşiv through Paraşüt. A 3-day trial, Standard and Pro plans, and an enterprise plan for firms.
  • Data stays in Türkiye and uploaded documents are never used for model training. The KVKK and GDPR texts are public on the site.

01

Problem

Lawyers spend most of their time on three things: finding the right precedent, placing citations correctly and tracking deadlines. Existing tools solved one of them; no product covered all of them in one place. Together with the lawyers on the team we set the scope: case-law search, a drafting editor, contract review, a calendar and UYAP integration in a single application.

On the technical side the critical requirement was data isolation. Dozens of firms keep client files on the same infrastructure, and one firm's data becoming visible to another is not an acceptable risk. Relying only on query filters in application code was not a sufficient guarantee.

The second requirement was search quality. Keyword search over 12 million decisions returns either far too much or nothing. We needed a search layer that matches a question written in plain language to the wording of a judgment.

02

Approach

I put isolation in three places. Tenant identity is written to the request context; the service layer refuses to run a query without it; and underneath there are PostgreSQL Row-Level Security policies. Even if the first two layers are bypassed, the database does not return another firm's row. I verified this with tests that confirm unfiltered queries return empty results.

For search we wrote the decisions into Qdrant as vectors. A separate Gemini-backed microservice does the semantic matching and results are filtered by chamber, year and field of law. The assistant streams its answer but never produces a sentence without a source; a citation it can't verify gets flagged.

Services talk over Kafka, but events don't go out directly; they leave through an outbox table. The event is written in the same transaction as the business data and a separate process relays it to Kafka. If the invoicing or notification service is unavailable at that moment, the event waits in the queue instead of being lost.

The audit log is hash-chained with SHA-256; every entry carries the digest of the previous one. The answer to 'who changed this document and when' had to be impossible to rewrite later.

The payment flow: the user pays through iyzico, an e-arşiv invoice is issued automatically through Paraşüt, the subscription state updates. There is no manual step. Documents are versioned on S3-compatible storage; a petition exports as .docx, .pdf or UYAP's .udf.

Deployment runs on Kubernetes and Coolify with multi-repo CI/CD. All three products share the infrastructure; a release is a single pipeline run.

03

Architecture

  1. Client
    • React SPA
    • Dilekçe editörü
    • UYAP e-imza eklentisi
  2. Edge
    • Nginx
    • JWT / OAuth2
    • 2FA · RBAC
  3. Services
    • Core API
    • Arama
    • RAG asistanı
    • Sözleşme analizi
    • Fatura
  4. Events
    • Outbox
    • Kafka
    • Denetim zinciri
  5. Data
    • PostgreSQL + RLS
    • Redis
    • Qdrant
    • S3
  6. Deployment
    • Docker
    • Kubernetes
    • Coolify
    • CI/CD
↓ Data flows top to bottom

04

Key decisions

  1. 01

    Push isolation down into the database

    Row-Level Security requires a separate policy for every table. I chose it anyway, because I did not want isolation to depend on application code being correct. The per-query overhead was too small to measure.

  2. 02

    Use an outbox table

    Publish straight to Kafka and there's a window where the row is saved but the message never left. The outbox closes that window. The cost is one table and one relay process.

  3. 03

    Keep the assistant in its own service

    A model call can take a few seconds. If that lived in the main API, every slow answer would lock up the pool. Separate microservice, streamed response.

  4. 04

    No answer without a source

    In legal work a wrong citation can have serious consequences. After the assistant answers, citations are checked against the sources; anything unverifiable is flagged.

Outcome

We launched in June 2026. Today the site offers a 3-day free trial, Standard and Pro plans and an enterprise plan for firms. More than 12 modules are running, including case-law search, the drafting editor, contract review, the Constitutional Court application editor, the hearing calendar, audio transcripts and the UYAP e-signature extension. The point raised most often in user feedback is that finding the precedent on the first page and having the citation inserted automatically shortens drafting time.

What I learned

“Two lessons from this project. First, security requirements belong in the database layer, not in application code; the policy stays in place even as the code changes. Second, legal software cannot be built without domain experts; we defined the module scope and naming together with the lawyers on the team.”

Related projects

  • SaaS
    Live

    CestaLaw

    An AI legal assistant built on ECHR case law: precedent matching, application forms, seven languages

    cestalaw.com is for lawyers preparing applications to the European Court of Human Rights. You upload your petition as a PDF, the system finds the closest precedents among more than 200,000 ECHR judgments, you talk strategy with the chatbot, and the assistant fills in the official application form for you to approve. It works in Turkish, English, German, French, Spanish, Italian and Russian. It's the first product we launched, in May 2026.

    200K+
    ECHR judgments
    7
    languages: TR, EN, DE, FR, ES, IT, RU
    • Java 21
    • Spring Boot
    • React
    • Kafka
    • Redis
    • PostgreSQL
  • SaaS
    Live

    NetKoçum

    Study tracking for Turkish university-exam (YKS) students and their coaches: finds weak topics, plans the week and links official resources to the exact page

    netkocum.com is a platform where a student preparing for Türkiye's university entrance exam (YKS) logs what they study, and the system works out which topics are weak and what to focus on this week. Mock exams, a mistake box, a review schedule, a weekly plan and a bank of 7,600 original questions live in one place, and the student's coach sees the same screens. I built every layer myself, from idea to launch.

    7.600
    original questions with explanations
    177
    official resources, linked to the page
    • Java 21
    • Spring Boot
    • PostgreSQL
    • Redis
    • Flyway
    • React
  • Backend
    Private repo

    Taskify

    Five microservices, sub-20ms real-time synchronization

    Task management across five decoupled microservices, with Redis and Kafka syncing state between active users at sub-20ms latency.

    5
    microservices
    <20ms
    sync latency
    • Java
    • Spring Boot
    • Redis
    • Kafka
    • PostgreSQL
    • Docker
    Open