Case study · proof of concept · public sector

Souverain Agentinstructing a municipal aid application with local AI

A municipal aid scheme (roads, street lighting, drinking water, sanitation, rivers) receives PDF applications filed by local authorities — communes, joint boards, intermunicipal bodies. Souverain Agent is a functional prototype that reads these files with OCR, analyses them with a language model run locally, applies an eligibility rules engine, and prepares the work of the instructing agent rather than deciding in their place.

Role
UX/UI design, eligibility rules, OCR/AI/n8n architecture
Status
Proof of concept, never deployed in production
Stack
Next.js 14 · Prisma/SQLite · Tailwind 4 · Docker
Pipeline
Local OCR → local LLM (n8n) → rules engine
23test filesfictitious, generated
10fictitious communes5 themes
50%funding capcoded rule, not guessed by the AI
6screensportal, instruction, analytics, PDF
Souverain Agent's instruction board: case queue on the left with the selected row highlighted, a compliant and eligible dossier shown on the right with its full audit report.
The instruction board. Every file arrives with an audit report already drafted by the rules engine — the instructing agent validates or corrects it, never starting from a blank page.
The problem

A grant application has to be read before it can be judged

A municipal aid application arrives as a PDF: a standard form, a project description, a costed funding plan. Before any decision, someone has to read the file, check that the amounts add up, that the commune is within the scheme's territory, that the project matches an eligible theme. It's repetitive reading work, not judgment work: the judgment comes after.

What repeats in every file

The funding ratio must not exceed a cap set by the scheme's regulation. The territory must be within the scheme's area. The project must fall under one of the covered themes. Three mechanical checks, done by hand on every file, before even reaching the real question: does this project deserve support.

The stance taken

Have the file read and checked by a chain of local OCR then local AI, to prepare an eligibility report — never to decide. The instructing agent remains the only one who approves or refuses: the machine reads, it does not rule.

Why local: a grant application holds data from public authorities and personal data about their representatives. Running OCR and the language model on infrastructure under our control, rather than sending every file to an external API, is the project's starting condition — not an option.

The pipeline

Four steps between filing and report

The file crosses a chain of four steps, orchestrated by containers (n8n for the sequencing, a dedicated language model and OCR service), before coming back as an eligibility report ready to be reviewed.

  1. Filing — public portal

    The local authority files its PDF application on a six-step portal (structure, project, finances, schedule, signature, summary), or enters it directly if it has no PDF on hand.

  2. Reading — local OCR

    The PDF's text is extracted by an OCR service that runs in a container, never leaving the local infrastructure. The raw text is kept alongside the structured data, so the instructor can always go back to the source.

  3. Analysis — local language model, orchestrated by n8n

    The extracted text is structured by a language model run locally (container orchestration via n8n) : identity of the project owner, project title and description, detailed funding plan. This step judges nothing, it turns free text into usable fields.

  4. Assisted decision — eligibility rules engine

    The structured fields pass through a rules engine that checks the funding cap, the territory and the theme, then computes a score and recommendations. The result is a report, not a decision: it awaits the instructing agent's validation.

What this changes in practice. The instructing agent opens a file that is already pre-filled, with an audit report and a list of points to check, rather than a PDF to pick apart field by field. The mechanical reading time shifts to the machine; the judgment stays human.

The eligibility rules

Three coded criteria, never guessed by the model

The eligibility engine is not a prompt hoping the model applies the regulation: it is a function that reads the structured fields and computes three criteria, each with its own verifiable logic.

CriterionWhat it checksWho decides it
ratio_financierThe requested grant amount does not exceed 50% of the project's total cost excl. tax.Direct calculation, no call to the model.
localisationThe local authority's address falls within the scheme's territory.Check on the address field extracted by OCR.
thematiqueThe project falls under one of the covered themes (road network, lighting, drinking water, sanitation, rivers).Presence of a non-empty, usable theme field.

Done myself

  • The three eligibility criteria and their weighting into a score
  • The screens and the filing and instruction flows
  • The pipeline's architecture (OCR, local model, n8n orchestration in containers)

What was generated by coding agents, under my direction

  • Most of the Next.js/TypeScript code and the Prisma schema
  • The Docker setup and the PDF generation scripts

The boundary that matters. The language model turns text into structured fields; it never computes the eligibility verdict itself. If the regulation changes its cap, one line of code changes — not a prompt that would need rewriting and blind re-testing.

The prototype

From the public filing to the instructed report

Six screens cover the full cycle: filing on the local-authority side, instruction on the agent side, statistical tracking, and the document generated at the end of the analysis.

Takeaways

What this prototype taught me

Separate extraction from decision, from the architecture onward

The language model reads and structures; a written, testable rules function decides. Holding this separation from the start avoids the temptation to let the model "judge" a regulatory criterion — a funding cap is a calculation, not an opinion, and it has to stay verifiable independently of whichever model is used.

An eligibility report has to say what it could not verify

The "to verify" banner, which precisely lists the fields the extraction could not confirm, is more useful than any overall score: it tells the instructor where to focus, instead of either trusting the extraction blindly or distrusting it wholesale.

From a fictitious dataset to a real pipeline, a step still remains

The portal, the rules engine and the instruction screens run on synthetic files; moving to real files means qualifying the OCR and the local model on PDFs messier than the ones generated for the demonstration — a separate step from the work already done.

Delivered

  • Functional prototype, never deployed in production
  • Six-step public filing portal, with direct entry or PDF upload
  • Local OCR → local AI (n8n orchestration) → rules engine pipeline
  • Three-criterion eligibility engine (ratio, territory, theme)
  • Instruction board, manual correction and PDF generation
  • Analytics dashboard over the test files

All case studies are gathered in the journal.