Skip to content

AI in compliance without outsourcing the decision: what I learned building a PIF SaaS for European cosmetics

How I modeled Eurologado: AI for drafting and organizing, structured rules for validation, versioning, evidence and audit trails in a regulatory domain.

By 7 min read
  • artificial intelligence
  • compliance
  • nestjs
  • postgresql
  • saas

This project taught me that "looks correct" is not a compliance property

In Eurologado, the product helps cosmetics businesses organize information used in a Product Information File for the European market.

Passage link

That domain changed the way I think about AI-assisted software.

Passage link

A fluent paragraph is useful in marketing content. In compliance, fluency can become dangerous if it hides missing evidence, outdated source data or an unsupported statement.

Passage link

So the core design question was never "how do I make the model write better?". It was:

Passage link

how do I make the system distinguish generated language from verified facts and required evidence?

Passage link

The first separation: a document is not the data

A PDF is an output format. It should not be the only source of truth.

Passage link

If the only representation of a regulatory artifact is a long generated document, the application has a hard time answering structured questions:

Passage link
  • which required sections are missing?
  • which ingredient or product record produced this paragraph?
  • which version of the source data was used?
  • what changed between revisions?
  • which statement was written by AI and which was explicitly confirmed by a person?

I prefer storing structured domain data first and generating the document from that data.

Passage link
txt
structured product data
        ↓
validation rules
        ↓
AI-assisted drafting
        ↓
human review
        ↓
versioned document
Passage link

That order makes the system inspectable.

Passage link

AI drafts; rules decide

One of the strongest architecture principles in the project was to avoid turning an LLM into the compliance engine.

Passage link

The model can be good at:

Passage link
  • summarizing source material;
  • rewriting technical text;
  • suggesting a draft section;
  • classifying free text;
  • highlighting potential inconsistency.

But a deterministic requirement such as "field X must exist before this stage can be completed" belongs in code or schema.

Passage link
ts
const missing = requiredFields.filter(
  field => product[field] == null || product[field] === ''
)

if (missing.length > 0) {
  return {
    status: 'incomplete',
    missing,
  }
}
Passage link

The LLM can help a person understand the problem. It should not redefine whether the requirement exists.

Passage link

A better prompt cannot repair a weak data model

It is tempting to solve every AI problem by expanding the prompt:

Passage link
txt
Do not invent.
Do not omit mandatory data.
Use only provided facts.
If something is missing, say it is missing.
...
Passage link

Those instructions are useful, but they are not a substitute for structure.

Passage link

If product identity, responsible person, source documents, versions and validation states are all mixed into free text, the model is forced to infer the system's domain every time it runs.

Passage link

A good data model removes work from the prompt.

Passage link

I would rather give the model a compact structured context with explicit missing values than a giant document and ask it to "be careful".

Passage link

"Do not hallucinate" is not a safety mechanism

A model instruction is probabilistic. Compliance controls need stronger guarantees.

Passage link

So I separate concerns:

Passage link
txt
LLM output
   ↓
parse into schema
   ↓
validate types and required fields
   ↓
compare against source-of-truth data
   ↓
flag unsupported or missing items
   ↓
human review when required
Passage link

Pydantic, JSON Schema or equivalent contracts are useful here because they force generated output into a known shape.

Passage link

Schema validation does not prove a statement is true. It does, however, prevent "beautiful prose" from bypassing the rest of the software.

Passage link

Missing information is first-class data

A surprisingly important design choice is to represent absence explicitly.

Passage link

There is a major difference between:

Passage link
json
{
  "safetyReport": null,
  "safetyReportStatus": "missing"
}
Passage link

and a model silently producing language that makes the section look complete.

Passage link

Missing data should be queryable, filterable and visible on dashboards.

Passage link

Once absence becomes data, the product can answer useful questions:

Passage link
  • which customers have incomplete files?
  • which requirement blocks completion most often?
  • how long has an item been pending?
  • which source document still needs to be uploaded?

That is much more valuable than a chatbot apologizing that it could not find something.

Passage link

Versioning the document without versioning its sources is only half an audit trail

If revision 7 of a document was generated from product data that later changed, keeping only the final PDF is not enough.

Passage link

I want the system to know, at minimum:

Passage link
ts
type DocumentRevision = {
  id: string
  productId: string
  version: number
  generatedAt: Date
  sourceSnapshotId: string
  templateVersion: string
  modelId?: string
  promptVersion?: string
  reviewedBy?: string
  approvedAt?: Date
}
Passage link

Not every field is required for every product, but the principle matters: an output should be traceable to the inputs and logic that created it.

Passage link

That becomes especially valuable when a customer asks why a section changed months later.

Passage link

Human editing is not "AI failure"

I do not measure an AI workflow by how often a person touches the output.

Passage link

In high-stakes domains, human correction is part of the product design.

Passage link

A better question is whether the system makes the review efficient:

Passage link
  • show what changed;
  • highlight low-confidence or unsupported passages;
  • link claims back to source data;
  • preserve reviewer decisions;
  • avoid asking the same question twice when the answer is already known.

The goal is not to remove the specialist. It is to move their time away from repetitive assembly and toward judgment.

Passage link

Human feedback can become an improvement dataset

When a reviewer changes generated text, that correction can be valuable—if stored with context and permission.

Passage link

Instead of saving only the final paragraph, I can retain a structured record:

Passage link
txt
input context
model draft
human edit
reason / category
accepted final version
Passage link

Over time, that supports better prompts, regression tests and evaluation sets.

Passage link

I would not jump directly to fine-tuning. First I want to understand recurring error classes.

Passage link

Often the best improvement is a validation rule, a better source field or a clearer template, not a new model.

Passage link

Multi-tenant security cannot depend on the prompt

A prompt such as "only use documents from the current customer" is not authorization.

Passage link

Tenant boundaries belong in the application and database layers.

Passage link

The retrieval query should already be scoped before anything reaches the model.

Passage link
sql
SELECT *
FROM product_documents
WHERE tenant_id = $1
  AND product_id = $2;
Passage link

The AI should receive only the data it is allowed to see.

Passage link

This is one of the most important distinctions in enterprise AI: prompt instructions influence model behavior; authorization controls data access.

Passage link

They solve different problems.

Passage link

The model itself must remain replaceable

AI providers and model quality change quickly.

Passage link

I avoid coupling the business workflow to one provider-specific response format deep inside the domain.

Passage link

A boundary such as this is easier to evolve:

Passage link
ts
interface ComplianceDraftingService {
  draftSection(input: DraftSectionInput): Promise<DraftSectionResult>
}
Passage link

The adapter can use one provider today and another later. The domain should care about the contract, not the SDK.

Passage link

This also makes evaluation much easier because two models can be run against the same cases.

Passage link

Evaluation needs real domain cases

Generic benchmarks tell me very little about whether a model is safe enough for my workflow.

Passage link

I care about cases such as:

Passage link
  • required source missing;
  • contradictory values across documents;
  • outdated product information;
  • long input with one critical exception;
  • ambiguous wording that should be escalated instead of confidently rewritten;
  • complete case where the system should avoid inventing extra warnings.

An evaluation suite can score structured properties: missing-field detection, unsupported claims, extraction accuracy, schema validity and reviewer acceptance.

Passage link

That gives me a regression signal when prompts, models or parsers change.

Passage link

The biggest lesson was separating plausibility from compliance

European cosmetics regulation defines concrete obligations around the Product Information File and the information it contains. A system in this domain therefore needs more than text that sounds professional.

Passage link

What I took from Eurologado is a pattern I now reuse in other enterprise AI work:

Passage link
txt
AI for interpretation and drafting
code for invariants
schemas for contracts
evidence for explanation
humans for final authority when required
Passage link

That combination is less magical than "upload your documents to a chatbot".

Passage link

It is also much more useful when audits, regulatory risk or financial impact are involved.

Passage link

In practice, that is where AI starts becoming software instead of a demo.

Passage link

References

Reference with source and version

Download BibTeX

Suggest a correction

https://lagrotti.dev/blog/eurologado-ai-compliance-cosmetics-pif-europe · EN

Your text stays in this form until you prepare and open the draft. You review and publish the issue on GitHub.

Which topic should go deeper?

Results are unavailable right now

Share this article

LinkedInWhatsAppXEmail

Need someone for a challenge like this one?

I work end to end: architecture, development and running in production. I'm open to remote roles and custom projects.