Skip to content

Schema Base de Donnees Scell.io

Version : 1.0 Derniere mise a jour : 2026-03-03 SGBD : PostgreSQL 17 ORM : Eloquent (Laravel 12)


Table des matieres


1. Vue d'ensemble

Le schema comporte 41+ tables reparties en 12 domaines fonctionnels. Toutes les tables suivent ces conventions :

  • Cles primaires : UUID v4 (trait HasUuids)
  • Timestamps : created_at et updated_at automatiques (sauf tables fiscales append-only)
  • Soft deletes : uniquement sur invoices, signatures et tenants
  • JSON : colonnes metadata, address, settings en JSONB PostgreSQL
  • Decimaux : DECIMAL(12,4) pour les montants financiers

Diagramme ER global

mermaid
erDiagram
    %% Core
    users ||--o{ companies : "possede"
    users ||--o| balances : "a"
    users ||--o{ api_keys : "cree"
    users ||--o{ transactions : "genere"
    users ||--o{ webhooks : "configure"

    %% Companies
    companies ||--o{ invoices : "emet"
    companies ||--o{ signatures : "demande"
    companies ||--o{ credit_notes : "emet"

    %% Multi-Tenant
    partners ||--o{ tenants : "onboarde"
    tenants ||--o{ sub_tenants : "gere"
    tenants ||--o{ companies : "contient"
    sub_tenants ||--o{ companies : "associe"
    tenants ||--o{ tenant_invoices : "facture"
    tenants ||--o{ tenant_transactions : "comptabilise"

    %% Facturation
    invoices ||--o{ invoice_lines : "contient"
    invoices ||--o{ credit_notes : "corrige"
    tenants ||--o{ invoice_sequences : "definit"

    %% Avoirs
    credit_notes ||--o{ credit_note_items : "contient"

    %% Signatures
    signatures ||--o{ signers : "implique"

    %% Onboarding
    partners ||--o{ onboarding_sessions : "initie"
    onboarding_sessions ||--o{ kyb_documents : "collecte"
    tenants ||--o{ kyb_documents : "fournit"

    %% Fiscal
    tenants ||--o{ fiscal_entries : "enregistre"
    tenants ||--o| fiscal_sequences : "numerote"
    tenants ||--o{ fiscal_closings : "cloture"
    tenants ||--o{ fiscal_attestations : "atteste"
    tenants ||--o{ fiscal_anchors : "ancre"
    tenants ||--o| fiscal_kill_switches : "controle"
    tenants ||--o{ fiscal_integrity_checks : "verifie"
    tenants ||--o{ fiscal_audit_log : "audite"
    tenants ||--o{ fiscal_rules : "applique"
    fiscal_entries ||--o{ fiscal_anchors : "horodate"
    fiscal_rules ||--o{ fiscal_rule_applications : "execute"

    %% Webhooks
    webhooks ||--o{ webhook_logs : "journalise"

    %% Integration
    users ||--o| openapi_configs : "configure"
    openapi_configs ||--o{ openapi_tokens : "genere"

    %% MCP
    tenants ||--o{ mcp_sessions : "utilise"

2. Tables Core

users

Table principale des utilisateurs du dashboard Scell.io.

ColonneTypeContraintesDescription
idUUIDPKIdentifiant unique
emailVARCHARUNIQUE, NOT NULLAdresse email
passwordVARCHARNOT NULLMot de passe (bcrypt)
google_idVARCHARUNIQUE, NULLABLEID OAuth Google
first_nameVARCHARNOT NULLPrenom
last_nameVARCHARNOT NULLNom
phoneVARCHARNULLABLETelephone
avatar_urlVARCHARNULLABLEURL avatar
roleENUMNOT NULLadmin, user, partner
is_activeBOOLEANDEFAULT trueCompte actif
last_login_atTIMESTAMPNULLABLEDerniere connexion
last_login_ipVARCHARNULLABLEIP derniere connexion
email_verified_atTIMESTAMPNULLABLEDate verification email
remember_tokenVARCHARNULLABLEToken "se souvenir de moi"
created_atTIMESTAMP
updated_atTIMESTAMP

Relations : companies (1:N), api_keys (1:N), balance (1:1), transactions (1:N), invoices (1:N), signatures (1:N), webhooks (1:N)

companies

Entites juridiques (personnes morales) associees a un utilisateur ou un tenant.

ColonneTypeContraintesDescription
idUUIDPKIdentifiant unique
user_idUUIDFK(users), NULLABLEProprietaire dashboard
tenant_idUUIDFK(tenants), NULLABLETenant d'appartenance
sub_tenant_idUUIDFK(sub_tenants), NULLABLESub-tenant d'appartenance
nameVARCHARNOT NULLRaison sociale
siretVARCHAR(14)NULLABLENumero SIRET
vat_numberVARCHARNULLABLENumero TVA intracommunautaire
legal_formVARCHARNULLABLEForme juridique (SAS, SARL, etc.)
address_line1VARCHARNOT NULLAdresse ligne 1
address_line2VARCHARNULLABLEAdresse ligne 2
postal_codeVARCHARNOT NULLCode postal
cityVARCHARNOT NULLVille
countryVARCHAR(2)NOT NULL, DEFAULT 'FR'Code pays ISO
phoneVARCHARNULLABLETelephone
emailVARCHARNULLABLEEmail de contact
websiteVARCHARNULLABLESite web
logo_urlVARCHARNULLABLEURL du logo
statusENUMNOT NULLactive, inactive, suspended
kyc_completed_atTIMESTAMPNULLABLEDate validation KYC
kyc_referenceVARCHARNULLABLEReference KYC
superpdp_idVARCHARNULLABLEID SuperPDP
metadataJSONBDEFAULT '{}'Donnees supplementaires
created_atTIMESTAMP
updated_atTIMESTAMP

Indexes : (user_id), (tenant_id), (sub_tenant_id), (siret)

Scopes : forTenant(?string), forSubTenant(?string)

api_keys

Cles d'authentification pour l'acces API externe.

ColonneTypeContraintesDescription
idUUIDPKIdentifiant unique
user_idUUIDFK(users)Proprietaire
company_idUUIDFK(companies)Entreprise associee
nameVARCHARNOT NULLNom de la cle
key_hashVARCHARNOT NULLHash SHA256 de la cle
key_prefixVARCHAR(8)NOT NULLPrefix visible (sk_live_, sk_test_)
environmentENUMNOT NULLsandbox, production
is_activeBOOLEANDEFAULT trueCle active
last_used_atTIMESTAMPNULLABLEDerniere utilisation
expires_atTIMESTAMPNULLABLEDate d'expiration
metadataJSONBDEFAULT '{}'Donnees supplementaires
created_atTIMESTAMP
updated_atTIMESTAMP

Indexes : (key_hash) UNIQUE, (key_prefix), (user_id), (company_id)


3. Tables Facturation

invoices

Table principale des factures emises et recues.

ColonneTypeContraintesDescription
idUUIDPK
user_idUUIDFK(users), NULLABLECreateur dashboard
company_idUUIDFK(companies)Entreprise emettrice
api_key_idUUIDFK(api_keys), NULLABLECle API utilisee
environmentENUMNOT NULLsandbox, production
external_idVARCHARNULLABLEID externe client
invoice_numberVARCHARNOT NULLNumero de facture
directionENUMNOT NULLoutgoing, incoming
input_formatVARCHARNULLABLEFormat source
output_formatVARCHARNULLABLEFormat cible
issue_dateDATENOT NULLDate d'emission
due_dateDATENULLABLEDate d'echeance
currencyVARCHAR(3)DEFAULT 'EUR'Devise
total_htDECIMAL(12,4)NOT NULLTotal HT
total_taxDECIMAL(12,4)NOT NULLTotal TVA
total_ttcDECIMAL(12,4)NOT NULLTotal TTC
seller_siretVARCHAR(14)NOT NULLSIRET vendeur
seller_nameVARCHARNOT NULLNom vendeur
seller_addressTEXTNOT NULLAdresse vendeur
buyer_siretVARCHAR(14)NOT NULLSIRET acheteur
buyer_nameVARCHARNOT NULLNom acheteur
buyer_addressTEXTNOT NULLAdresse acheteur
original_file_pathVARCHARNULLABLEChemin fichier source
original_file_hashVARCHARNULLABLEHash fichier source
converted_file_pathVARCHARNULLABLEChemin fichier converti
converted_file_hashVARCHARNULLABLEHash fichier converti
pdf_file_pathVARCHARNULLABLEChemin PDF
statusENUMNOT NULLdraft, submitted, accepted, rejected, paid, error
legal_statusENUMNULLABLEdonnee_fiscale, donnee_comptable, donnee_technique
submitted_atTIMESTAMPNULLABLEDate soumission PDP
paid_atTIMESTAMPNULLABLEDate paiement
paid_statusENUMNULLABLEpending, partial, complete
metadataJSONBDEFAULT '{}'
audit_trailJSONBNULLABLEHistorique d'audit
created_atTIMESTAMP
updated_atTIMESTAMP
deleted_atTIMESTAMPNULLABLESoft delete

Immutabilite NF525 : les champs total_ht, total_ttc, total_tax, invoice_number, issue_date, seller_*, buyer_*, currency, user_id, company_id sont verrouilles une fois status != 'draft'.

Indexes : (company_id), (user_id), (invoice_number, company_id) UNIQUE, (status), (direction)

invoice_lines

Lignes de detail d'une facture.

ColonneTypeContraintesDescription
idUUIDPK
invoice_idUUIDFK(invoices), ON DELETE CASCADEFacture parente
descriptionTEXTNOT NULLDescription
quantityDECIMAL(10,4)NOT NULLQuantite
unit_priceDECIMAL(12,4)NOT NULLPrix unitaire HT
total_htDECIMAL(12,4)NOT NULLTotal HT
tax_rateDECIMAL(5,2)NOT NULLTaux TVA
tax_amountDECIMAL(12,4)NOT NULLMontant TVA
total_ttcDECIMAL(12,4)NOT NULLTotal TTC
created_atTIMESTAMP
updated_atTIMESTAMP

invoice_sequences

Sequences de numerotation par tenant et sub-tenant.

ColonneTypeContraintesDescription
idUUIDPK
tenant_idUUIDFK(tenants)Tenant proprietaire
sub_tenant_idUUIDFK(sub_tenants), NULLABLESub-tenant
yearINTNOT NULLAnnee
monthINTNULLABLEMois (si numerotation mensuelle)
next_numberINTNOT NULL, DEFAULT 1Prochain numero
prefixVARCHARNULLABLEPrefixe (ex: "FA-")
suffixVARCHARNULLABLESuffixe
formatVARCHARNOT NULLFormat (ex: "YYYYNNNNN")
format_typeENUMNOT NULLnumeric, alphanumeric, custom
total_createdINTDEFAULT 0Total factures creees
statusENUMDEFAULT 'active'active, frozen
created_atTIMESTAMP
updated_atTIMESTAMP

Contrainte unique : (tenant_id, sub_tenant_id, year, month)


4. Tables Avoirs

credit_notes

Avoirs (notes de credit) associes a des factures.

ColonneTypeContraintesDescription
idUUIDPK
user_idUUIDFK(users), NULLABLECreateur
company_idUUIDFK(companies), NULLABLEEntreprise
tenant_idUUIDFK(tenants), NULLABLETenant
sub_tenant_idUUIDFK(sub_tenants), NULLABLESub-tenant
invoice_idUUIDFK(invoices), NULLABLEFacture d'origine
credit_note_numberVARCHARUNIQUENumero d'avoir
issue_dateDATENOT NULLDate d'emission
due_dateDATENULLABLEDate d'echeance
reasonTEXTNOT NULLMotif
subtotalDECIMAL(12,4)NOT NULLSous-total HT
tax_amountDECIMAL(12,4)NOT NULLMontant TVA
totalDECIMAL(12,4)NOT NULLTotal TTC
currencyVARCHAR(3)DEFAULT 'EUR'Devise
seller_nameVARCHARNOT NULLVendeur
seller_siretVARCHAR(14)NOT NULLSIRET vendeur
seller_addressTEXTNOT NULLAdresse vendeur
buyer_nameVARCHARNOT NULLAcheteur
buyer_siretVARCHAR(14)NOT NULLSIRET acheteur
buyer_addressTEXTNOT NULLAdresse acheteur
client_nameVARCHARNULLABLEClient final
client_siretVARCHAR(14)NULLABLESIRET client
client_addressTEXTNULLABLEAdresse client
items_countINTDEFAULT 0Nombre d'articles
statusENUMNOT NULLdraft, issued, sent, archived, cancelled
legal_statusENUMNULLABLEdonnee_fiscale, donnee_comptable
sent_atTIMESTAMPNULLABLE
archived_atTIMESTAMPNULLABLE
metadataJSONBDEFAULT '{}'
created_atTIMESTAMP
updated_atTIMESTAMP

Pas de soft delete (ADR-008 : conformite NF525). La suppression n'est autorisee que pour status = 'draft'.

credit_note_items

Lignes de detail d'un avoir.

ColonneTypeContraintesDescription
idUUIDPK
credit_note_idUUIDFK(credit_notes), ON DELETE CASCADEAvoir parent
descriptionTEXTNOT NULLDescription
quantityDECIMAL(10,4)NOT NULLQuantite
unit_priceDECIMAL(12,4)NOT NULLPrix unitaire HT
total_htDECIMAL(12,4)NOT NULLTotal HT
tax_rateDECIMAL(5,2)NOT NULLTaux TVA
tax_amountDECIMAL(12,4)NOT NULLMontant TVA
total_ttcDECIMAL(12,4)NOT NULLTotal TTC
created_atTIMESTAMP
updated_atTIMESTAMP

5. Tables Signatures

signatures

Demandes de signature electronique (eIDAS EU-SES).

ColonneTypeContraintesDescription
idUUIDPK
user_idUUIDFK(users)Createur
company_idUUIDFK(companies)Entreprise
api_key_idUUIDFK(api_keys), NULLABLECle API utilisee
environmentENUMNOT NULLsandbox, production
external_idVARCHARNULLABLEID externe client
titleVARCHARNOT NULLTitre du document
descriptionTEXTNULLABLEDescription
original_file_pathVARCHARNOT NULLChemin fichier original
original_file_hashVARCHARNOT NULLHash SHA256 fichier
original_file_nameVARCHARNOT NULLNom du fichier
original_file_sizeINTNOT NULLTaille en octets
signed_file_pathVARCHARNULLABLEChemin fichier signe
signed_file_hashVARCHARNULLABLEHash fichier signe
auth_methodENUMNOT NULLsms, email, biometric
signature_positionsJSONBNULLABLEPositions de signature
ui_configJSONBDEFAULT '{}'Configuration interface
statusENUMNOT NULLwaiting_signers, partially_signed, signed, error, cancelled, expired
status_messageTEXTNULLABLEMessage de statut
openapi_idVARCHARNULLABLEID OpenAPI.com
openapi_statusVARCHARNULLABLEStatut OpenAPI
openapi_responseJSONBNULLABLEReponse OpenAPI
signing_urlsJSONBNULLABLEURLs de signature
redirect_complete_urlVARCHARNULLABLEURL redirection apres signature
redirect_cancel_urlVARCHARNULLABLEURL redirection annulation
archive_enabledBOOLEANDEFAULT falseArchivage active
archive_statusVARCHARNULLABLEStatut archivage
archive_pathVARCHARNULLABLEChemin archive
archive_untilDATENULLABLEDate fin archivage
audit_trail_pathVARCHARNULLABLEChemin piste d'audit
transaction_idUUIDFK(transactions), NULLABLETransaction associee
amount_chargedDECIMAL(7,2)DEFAULT 0Montant debite (1.20 EUR)
expires_atTIMESTAMPNOT NULLDate expiration
completed_atTIMESTAMPNULLABLEDate completion
created_atTIMESTAMP
updated_atTIMESTAMP
deleted_atTIMESTAMPNULLABLESoft delete

signers

Signataires d'une demande de signature.

ColonneTypeContraintesDescription
idUUIDPK
signature_idUUIDFK(signatures), ON DELETE CASCADEDemande parente
emailVARCHARNOT NULLEmail signataire
phoneVARCHARNULLABLETelephone (pour SMS OTP)
first_nameVARCHARNOT NULLPrenom
last_nameVARCHARNOT NULLNom
signed_atTIMESTAMPNULLABLEDate de signature
auth_methodENUMNOT NULLsms, email, biometric
statusENUMNOT NULLwaiting, signed, cancelled
sms_code_sent_atTIMESTAMPNULLABLEDernier envoi SMS OTP
created_atTIMESTAMP
updated_atTIMESTAMP

6. Tables Multi-Tenant

tenants

Entreprises clientes de la plateforme (B2B).

ColonneTypeContraintesDescription
idUUIDPK
partner_idUUIDFK(partners), NULLABLEPartenaire d'onboarding
nameVARCHARNOT NULLNom commercial
slugVARCHARUNIQUEIdentifiant URL-friendly
legal_nameVARCHARNOT NULLRaison sociale
siretVARCHAR(14)NULLABLESIRET
vat_numberVARCHARNULLABLETVA intracommunautaire
billing_emailVARCHARNULLABLEEmail facturation
technical_emailVARCHARNULLABLEEmail technique
contact_emailVARCHARNULLABLEEmail contact
contact_phoneVARCHARNULLABLETelephone
addressJSONBNULLABLEAdresse structuree
api_key_hashVARCHARNOT NULLHash cle API tenant
api_key_prefixVARCHAR(12)UNIQUEPrefix (sk_live_, sk_test_)
publishable_key_hashVARCHARNULLABLEHash cle publique tenant
publishable_key_prefixVARCHAR(12)NULLABLE UNIQUEPrefix (pk_live_, pk_test_)
environmentENUMNOT NULLsandbox, production
kyb_statusENUMNOT NULLpending, documents_submitted, under_review, verified, rejected
kyb_verified_atTIMESTAMPNULLABLEDate verification KYB
kyb_rejection_reasonTEXTNULLABLEMotif de rejet
balanceDECIMAL(12,4)DEFAULT 0Solde disponible
stripe_customer_idVARCHARNULLABLEID client Stripe
webhook_urlVARCHARNULLABLEURL webhook
webhook_secretVARCHARNULLABLESecret webhook
settingsJSONBDEFAULT '{}'Parametres
metadataJSONBDEFAULT '{}'Donnees supplementaires
is_activeBOOLEANDEFAULT trueActif
statusENUMNOT NULLactive, inactive, suspended
deleted_atTIMESTAMPNULLABLESoft delete
created_atTIMESTAMP
updated_atTIMESTAMP

sub_tenants

Sous-entites gerees par un tenant (clients du tenant).

ColonneTypeContraintesDescription
idUUIDPK
tenant_idUUIDFK(tenants), NOT NULLTenant parent
external_idVARCHARNULLABLEID dans le systeme du partenaire
nameVARCHARNOT NULLNom
emailVARCHARNULLABLEEmail
contact_personVARCHARNULLABLEPersonne de contact
phoneVARCHARNULLABLETelephone
siretVARCHAR(14)NULLABLESIRET
vat_numberVARCHARNULLABLETVA
addressJSONBNULLABLEAdresse
statusENUMDEFAULT 'active'active, inactive
metadataJSONBDEFAULT '{}'
created_atTIMESTAMP
updated_atTIMESTAMP

Scope : forTenant(string $tenantId)

partners

Partenaires integrateurs (cabinets comptables, ERP, etc.).

ColonneTypeContraintesDescription
idUUIDPK
nameVARCHARNOT NULLNom
descriptionTEXTNULLABLEDescription
slugVARCHARUNIQUEIdentifiant
api_keyVARCHARNOT NULLCle API partenaire
webhook_urlVARCHARNULLABLEURL webhook
webhook_secretVARCHARNULLABLESecret webhook
is_activeBOOLEANDEFAULT trueActif
metadataJSONBDEFAULT '{}'
created_atTIMESTAMP
updated_atTIMESTAMP

tenant_invoices

Factures de facturation consolidee tenant (factures Scell.io vers tenant).

ColonneTypeContraintesDescription
idUUIDPK
tenant_idUUIDFK(tenants)Tenant facture
invoice_numberVARCHARNOT NULLNumero facture Scell.io
period_startDATENOT NULLDebut periode
period_endDATENOT NULLFin periode
issue_dateDATENOT NULLDate emission
due_dateDATENOT NULLDate echeance
invoices_countINTDEFAULT 0Nombre de factures traitees
invoices_amountDECIMAL(12,4)DEFAULT 0Montant factures
signatures_countINTDEFAULT 0Nombre de signatures
signatures_amountDECIMAL(12,4)DEFAULT 0Montant signatures
credit_notes_countINTDEFAULT 0Nombre d'avoirs
credit_notes_amountDECIMAL(12,4)DEFAULT 0Montant avoirs
subtotal_htDECIMAL(12,4)NOT NULLSous-total HT
discount_percentDECIMAL(5,2)NULLABLEPourcentage remise
discount_amountDECIMAL(12,4)NULLABLEMontant remise
total_htDECIMAL(12,4)NOT NULLTotal HT
vat_rateDECIMAL(5,2)DEFAULT 20Taux TVA
total_vatDECIMAL(12,4)NOT NULLTotal TVA
total_ttcDECIMAL(12,4)NOT NULLTotal TTC
statusENUMNOT NULLdraft, sent, paid, overdue, cancelled
sent_atTIMESTAMPNULLABLE
paid_atTIMESTAMPNULLABLE
payment_methodVARCHARNULLABLEMethode paiement
payment_referenceVARCHARNULLABLEReference paiement
stripe_invoice_idVARCHARNULLABLEID Stripe
pdf_pathVARCHARNULLABLEChemin PDF
metadataJSONBDEFAULT '{}'
created_atTIMESTAMP
updated_atTIMESTAMP

tenant_transactions

Journal des transactions financieres d'un tenant.

ColonneTypeContraintesDescription
idUUIDPK
tenant_idUUIDFK(tenants)Tenant
transaction_typeENUMNOT NULLinvoice_created, signature_created, credit_note_created, balance_topup, invoice_submitted, balance_debit
entity_typeVARCHARNULLABLEType entite associee
entity_idUUIDNULLABLEID entite
amountDECIMAL(12,4)NOT NULLMontant
currencyVARCHAR(3)DEFAULT 'EUR'Devise
running_balanceDECIMAL(12,4)NOT NULLSolde courant
statusENUMNOT NULLpending, completed, failed
metadataJSONBDEFAULT '{}'
created_atTIMESTAMP

7. Tables Onboarding

onboarding_sessions

Sessions du parcours d'onboarding B2B.

ColonneTypeContraintesDescription
idUUIDPK
partner_idUUIDFK(partners)Partenaire initiateur
external_referenceVARCHARNULLABLEReference partenaire
tenant_idUUIDFK(tenants), NULLABLETenant cree (apres completion)
redirect_urlVARCHARNULLABLEURL retour partenaire
siret_verified_atTIMESTAMPNULLABLEDate verification SIRET
vat_verified_atTIMESTAMPNULLABLEDate verification TVA
documents_submitted_atTIMESTAMPNULLABLEDate soumission documents
completed_atTIMESTAMPNULLABLEDate completion
verification_codeVARCHARUNIQUECode verification echange
verification_code_expires_atTIMESTAMPNOT NULLExpiration code
statusENUMNOT NULLin_progress, documents_requested, under_review, approved, rejected
rejection_reasonTEXTNULLABLEMotif rejet
metadataJSONBDEFAULT '{}'
created_atTIMESTAMP
updated_atTIMESTAMP

kyb_documents

Documents KYB (Know Your Business) fournis lors de l'onboarding.

ColonneTypeContraintesDescription
idUUIDPK
onboarding_session_idUUIDFK(onboarding_sessions), NULLABLESession d'onboarding
tenant_idUUIDFK(tenants), NULLABLETenant proprietaire
document_typeENUMNOT NULLidentity, business_license, proof_of_address, financial_statement
file_pathVARCHARNOT NULLChemin S3
file_hashVARCHARUNIQUEHash SHA256
mime_typeVARCHARNOT NULLType MIME
file_sizeINTNOT NULLTaille en octets
statusENUMDEFAULT 'pending'pending, approved, rejected
review_notesTEXTNULLABLENotes de review
reviewed_atTIMESTAMPNULLABLEDate review
reviewed_by_user_idUUIDFK(users), NULLABLERevieweur
metadataJSONBDEFAULT '{}'
created_atTIMESTAMP
updated_atTIMESTAMP

8. Tables Fiscales (NF525)

Ces tables implementent la conformite NF525 avec un grand livre immutable et une chaine de hachage cryptographique.

fiscal_entries

Grand livre fiscal immutable. Table centrale du module de conformite.

ColonneTypeContraintesDescription
idUUIDPK
tenant_idUUIDFK(tenants)Tenant
sequence_numberINTNOT NULLNumero sequence (par tenant)
entry_typeENUMNOT NULLinvoice, credit_note, payment, closing, adjustment
entity_typeVARCHARNULLABLEType entite source
entity_idUUIDNULLABLEID entite source
fiscal_dateDATENOT NULLDate fiscale
data_snapshotJSONBNOT NULLSnapshot complet de l'entite
data_hashVARCHAR(64)NOT NULLSHA256 du snapshot
previous_hashVARCHAR(64)NOT NULLHash de l'entree precedente
chain_hashVARCHAR(64)NOT NULLSHA256(data_hash + previous_hash + seq)
legal_statusENUMNOT NULLdonnee_fiscale, donnee_comptable, donnee_technique
environmentENUMNOT NULLsandbox, production
actor_typeENUMNOT NULLuser, system, partner
actor_idUUIDNULLABLEID acteur
ip_addressVARCHARNULLABLEAdresse IP
user_agentTEXTNULLABLEUser agent
metadataJSONBDEFAULT '{}'
created_atTIMESTAMPNOT NULLHorodatage (non modifiable)

Contrainte unique : (tenant_id, sequence_number)

Indexes : (tenant_id, sequence_number), (entity_type, entity_id), (tenant_id, fiscal_date)

Aucun updated_at : table append-only, jamais modifiee.

Triggers d'immutabilite : des triggers PostgreSQL empechent les UPDATE et DELETE.

fiscal_sequences

Compteurs de sequence atomiques par tenant.

ColonneTypeContraintesDescription
idUUIDPK
tenant_idUUIDFK(tenants), UNIQUETenant
last_sequence_numberINTNOT NULLDernier numero
last_sequence_dateTIMESTAMPNOT NULLDate dernier numero
lock_versionINTDEFAULT 0Verrouillage optimiste

fiscal_closings

Clotures periodiques (quotidienne, mensuelle, annuelle).

ColonneTypeContraintesDescription
idUUIDPK
tenant_idUUIDFK(tenants)Tenant
closing_dateDATENOT NULLDate de cloture
closing_typeENUMNOT NULLdaily, monthly, yearly
entries_countINTNOT NULLNombre d'ecritures
opening_balanceDECIMAL(12,4)NOT NULLSolde ouverture
closing_balanceDECIMAL(12,4)NOT NULLSolde cloture
total_operationsINTNOT NULLTotal operations
fec_export_pathVARCHARNULLABLEChemin export FEC
statusENUMNOT NULLpending, completed, verified, error
closed_atTIMESTAMPNOT NULLHorodatage cloture
created_atTIMESTAMP
updated_atTIMESTAMP

Contrainte unique : (tenant_id, closing_date, closing_type)

fiscal_attestations

Attestations annuelles de conformite.

ColonneTypeContraintesDescription
idUUIDPK
tenant_idUUIDFK(tenants)Tenant
yearINTNOT NULLAnnee
attestation_typeENUMNOT NULLannual, special
software_nameVARCHARNOT NULLNom logiciel
software_versionVARCHARNOT NULLVersion
editor_nameVARCHARNOT NULLNom editeur
editor_siretVARCHAR(14)NOT NULLSIRET editeur
license_numberVARCHARNULLABLENumero licence
market_release_dateDATENOT NULLDate mise sur marche
attestation_dateDATENOT NULLDate attestation
signed_atTIMESTAMPNULLABLEDate signature
pdf_pathVARCHARNULLABLEChemin PDF
created_atTIMESTAMP
updated_atTIMESTAMP

Contrainte unique : (tenant_id, year)

fiscal_anchors

Ancrages TSA RFC3161 pour horodatage legal.

ColonneTypeContraintesDescription
idUUIDPK
tenant_idUUIDFK(tenants)Tenant
entry_idUUIDFK(fiscal_entries)Entree ancree
anchor_typeENUMNOT NULLrfc3161_tsa, blockchain, none
anchor_timestampTIMESTAMPNOT NULLHorodatage TSA
anchor_referenceVARCHARNULLABLEReference ancrage
proof_pathVARCHARNULLABLEChemin preuve
statusENUMNOT NULLpending, verified, failed
created_atTIMESTAMP
updated_atTIMESTAMP

fiscal_kill_switches

Interrupteur d'urgence pour les operations fiscales.

ColonneTypeContraintesDescription
idUUIDPK
tenant_idUUIDFK(tenants), UNIQUETenant
statusENUMNOT NULLactive, inactive
activated_atTIMESTAMPNULLABLEDate activation
deactivated_atTIMESTAMPNULLABLEDate desactivation
activation_reasonTEXTNULLABLEMotif
activated_by_user_idUUIDFK(users), NULLABLEUtilisateur activateur
activated_by_ipVARCHARNULLABLEIP
metadataJSONBDEFAULT '{}'

fiscal_integrity_checks

Rapports de verification d'integrite de la chaine.

ColonneTypeContraintesDescription
idUUIDPK
tenant_idUUIDFK(tenants)Tenant
check_dateDATENOT NULLDate verification
entries_validatedINTNOT NULLEntrees validees
chains_verifiedINTNOT NULLChaines verifiees
anomalies_foundINTDEFAULT 0Anomalies detectees
statusENUMNOT NULLpassed, warning, failed
report_pathVARCHARNULLABLEChemin rapport
created_atTIMESTAMP
updated_atTIMESTAMP

fiscal_audit_log

Journal d'audit de conformite fiscale.

ColonneTypeContraintesDescription
idUUIDPK
tenant_idUUIDFK(tenants)Tenant
event_typeENUMNOT NULLmodification_attempt, deletion_attempt, deletion_blocked, access_denied, chain_break
event_sourceVARCHARNOT NULLSource (ex: nf525_guard, fiscal_system)
target_tableVARCHARNOT NULLTable cible
target_idUUIDNULLABLEID cible
severityENUMNOT NULLinfo, warning, critical
actor_typeVARCHARNULLABLEType acteur
actor_idUUIDNULLABLEID acteur
ip_addressVARCHARNULLABLEIP
user_agentTEXTNULLABLEUser agent
detailsJSONBDEFAULT '{}'Details evenement
created_atTIMESTAMPNOT NULL

Indexes : (tenant_id, created_at), (severity, created_at)

fiscal_rules

Regles de conformite configurables par tenant.

ColonneTypeContraintesDescription
idUUIDPK
tenant_idUUIDFK(tenants)Tenant
rule_keyVARCHARNOT NULLCle unique par tenant
rule_nameVARCHARNOT NULLNom lisible
rule_typeENUMNOT NULLalert, validation, correction
condition_jsonJSONBNOT NULLCondition d'application
action_jsonJSONBNOT NULLAction a executer
enabledBOOLEANDEFAULT trueActive
applied_countINTDEFAULT 0Nombre d'applications
last_applied_atTIMESTAMPNULLABLEDerniere application
created_by_user_idUUIDFK(users)Createur
metadataJSONBDEFAULT '{}'
created_atTIMESTAMP
updated_atTIMESTAMP

Contrainte unique : (tenant_id, rule_key)

fiscal_rule_applications

Journal d'application des regles fiscales.

ColonneTypeContraintesDescription
idUUIDPK
fiscal_rule_idUUIDFK(fiscal_rules)Regle appliquee
entry_idUUIDFK(fiscal_entries), NULLABLEEntree concernee
applied_atTIMESTAMPNOT NULLDate application
resultENUMNOT NULLpassed, failed, warning
detailsJSONBDEFAULT '{}'Details

9. Tables Webhooks

webhooks

Configuration des webhooks utilisateur.

ColonneTypeContraintesDescription
idUUIDPK
user_idUUIDFK(users)Proprietaire
company_idUUIDFK(companies), NULLABLEEntreprise
urlVARCHARNOT NULLURL endpoint
secretVARCHARNOT NULLSecret HMAC
eventsJSONBNOT NULLEvenements souscrits
is_activeBOOLEANDEFAULT trueActif
retriesINTDEFAULT 3Nombre de retries
max_retriesINTDEFAULT 5Maximum retries
backoff_multiplierINTDEFAULT 2Multiplicateur backoff
created_atTIMESTAMP
updated_atTIMESTAMP

Evenements disponibles : invoice.created, invoice.submitted, signature.created, signature.completed, credit_note.created

webhook_logs

Journal des envois de webhooks.

ColonneTypeContraintesDescription
idUUIDPK
webhook_idUUIDFK(webhooks)Webhook
event_nameVARCHARNOT NULLEvenement
payloadJSONBNOT NULLCorps envoye
statusENUMNOT NULLsuccess, failed
status_codeINTNULLABLECode HTTP
responseTEXTNULLABLECorps reponse
attemptINTDEFAULT 1Tentative
created_atTIMESTAMP

processed_webhooks

Deduplication des webhooks entrants (OpenAPI, SuperPDP).

ColonneTypeContraintesDescription
idUUIDPK
webhook_providerENUMNOT NULLopenapi, superpdp
external_idVARCHARNOT NULLID externe
statusVARCHARNOT NULLStatut traitement
processed_atTIMESTAMPNULLABLEDate traitement
metadataJSONBDEFAULT '{}'
created_atTIMESTAMP

Contrainte unique : (webhook_provider, external_id)


10. Tables Billing

balances

Solde de credits d'un utilisateur dashboard.

ColonneTypeContraintesDescription
idUUIDPK
user_idUUIDFK(users), UNIQUEProprietaire
available_balanceDECIMAL(12,4)DEFAULT 0Solde disponible
reserved_balanceDECIMAL(12,4)DEFAULT 0Solde reserve
total_balanceDECIMAL(12,4)DEFAULT 0Solde total
currencyVARCHAR(3)DEFAULT 'EUR'Devise
last_updated_atTIMESTAMPNULLABLEDerniere mise a jour
created_atTIMESTAMP
updated_atTIMESTAMP

transactions

Journal des transactions financieres (utilisateur dashboard).

ColonneTypeContraintesDescription
idUUIDPK
user_idUUIDFK(users)Proprietaire
company_idUUIDFK(companies), NULLABLEEntreprise
entity_typeVARCHARNULLABLEType entite (morph)
entity_idUUIDNULLABLEID entite
transaction_typeVARCHARNOT NULLType
amountDECIMAL(12,4)NOT NULLMontant
currencyVARCHAR(3)DEFAULT 'EUR'Devise
statusENUMNOT NULLpending, completed, failed
descriptionTEXTNULLABLEDescription
referenceVARCHARNULLABLEReference
created_atTIMESTAMP

11. Tables Integration

openapi_configs

Configuration OAuth2 pour l'integration OpenAPI.com.

ColonneTypeContraintesDescription
idUUIDPK
user_idUUIDFK(users)Proprietaire
client_idVARCHARNOT NULLOAuth2 Client ID
client_secretVARCHARNOT NULLOAuth2 Client Secret (chiffre)
webhook_urlVARCHARNULLABLEURL webhook OpenAPI
webhook_secretVARCHARNULLABLESecret webhook
is_activeBOOLEANDEFAULT trueActif
metadataJSONBDEFAULT '{}'
created_atTIMESTAMP
updated_atTIMESTAMP

openapi_tokens

Tokens OAuth2 pour OpenAPI.com.

ColonneTypeContraintesDescription
idUUIDPK
openapi_config_idUUIDFK(openapi_configs)Configuration
access_tokenTEXTNOT NULLToken d'acces (chiffre)
refresh_tokenTEXTNULLABLEToken de rafraichissement
expires_atTIMESTAMPNOT NULLDate expiration
scopesVARCHARNULLABLEScopes accordes
created_atTIMESTAMP
updated_atTIMESTAMP

sync_cursors

Curseurs de synchronisation pour les integrations.

ColonneTypeContraintesDescription
idUUIDPK
entity_typeVARCHARNOT NULLType entite synchronisee
last_synced_atTIMESTAMPNULLABLEDerniere sync
cursor_positionVARCHARNULLABLEPosition curseur
statusENUMNOT NULLStatut sync
metadataJSONBDEFAULT '{}'
created_atTIMESTAMP
updated_atTIMESTAMP

12. Tables MCP

mcp_sessions

Sessions du serveur MCP (Model Context Protocol) pour audit.

ColonneTypeContraintesDescription
idUUIDPK
tenant_idUUIDFK(tenants), NULLABLETenant associe
session_idVARCHARUNIQUEID session MCP
api_key_idUUIDFK(api_keys), NULLABLECle API utilisee
tools_accessedJSONBDEFAULT '[]'Outils utilises
statusENUMNOT NULLactive, expired, closed
expires_atTIMESTAMPNOT NULLDate expiration
metadataJSONBDEFAULT '{}'
created_atTIMESTAMP
updated_atTIMESTAMP

13. Tables Support

audit_trails

Piste d'audit generale pour toutes les modifications de modeles.

ColonneTypeContraintesDescription
idUUIDPK
user_idUUIDFK(users), NULLABLEAuteur
actionVARCHARNOT NULLAction (created, updated, deleted)
model_typeVARCHARNOT NULLType modele
model_idUUIDNOT NULLID modele
old_valuesJSONBNULLABLEAnciennes valeurs
new_valuesJSONBNULLABLENouvelles valeurs
ip_addressVARCHARNULLABLEIP
user_agentTEXTNULLABLEUser agent
created_atTIMESTAMP

sms_logs

Journal des envois SMS OTP (BulkGate).

ColonneTypeContraintesDescription
idUUIDPK
signer_idUUIDFK(signers)Signataire
phoneVARCHARNOT NULLNumero telephone
otp_codeVARCHAR(6)NOT NULLCode OTP
sent_atTIMESTAMPNOT NULLDate envoi
verified_atTIMESTAMPNULLABLEDate verification
attempt_countINTDEFAULT 1Nombre tentatives
created_atTIMESTAMP

rate_limit_overrides

Surcharges de rate limiting par utilisateur ou entreprise.

ColonneTypeContraintesDescription
idUUIDPK
user_idUUIDFK(users), NULLABLEUtilisateur
company_idUUIDFK(companies), NULLABLEEntreprise
limit_typeVARCHARNOT NULLType de limite
requests_per_minuteINTNOT NULLRequetes par minute
expires_atTIMESTAMPNULLABLEDate expiration
created_atTIMESTAMP
updated_atTIMESTAMP

14. Migrations

Les migrations sont ordonnees chronologiquement. Les migrations critiques sont marquees avec le symbole *.

Phase 1 -- Core (2026-01-11)

MigrationDescription
2026_01_11_000001_create_users_tableTable utilisateurs, roles, auth
2026_01_11_000002_create_companies_tableTable entreprises, SIRET, KYC
2026_01_11_000003_create_api_keys_tableCles API (hash, prefix, env)
2026_01_11_000004_create_billing_tablesTables balances et transactions
2026_01_11_000005_create_invoices_tableFactures et lignes de facture
2026_01_11_000006_create_signatures_tableSignatures et signataires
2026_01_11_000007_create_webhooks_tableWebhooks et logs
2026_01_11_000008_create_support_tablesAudit trails, SMS logs, rate limits
2026_01_11_223440_create_permission_tables* Tables Spatie Permission (roles/permissions)

Phase 2 -- Corrections (2026-01-12)

MigrationDescription
2026_01_12_155701_make_webhook_company_id_nullablecompany_id nullable sur webhooks

Phase 3 -- Avoirs (2026-01-19)

MigrationDescription
2026_01_19_000001_create_credit_notes_tableTable des avoirs
2026_01_19_000002_create_credit_note_items_tableLignes d'avoirs

Phase 4 -- Multi-Tenant (2026-01-22)

MigrationDescription
2026_01_22_000001_create_processed_webhooks_tableDeduplication webhooks entrants
2026_01_22_210000_create_tenants_table* Table tenants (coeur multi-tenant)
2026_01_22_210001_create_sub_tenants_table* Table sub-tenants
2026_01_22_210002_add_tenant_columns_to_companies* Ajout tenant_id/sub_tenant_id sur companies
2026_01_22_210003_create_kyb_documents_tableDocuments KYB
2026_01_22_210004_create_tenant_invoices_tableFacturation tenant consolidee
2026_01_22_210005_create_tenant_transactions_tableTransactions tenant

Phase 5 -- Onboarding & Integrations (2026-01-24)

MigrationDescription
2026_01_24_000001_create_partners_tableTable partenaires
2026_01_24_000001c_add_partner_and_onboarding_fields_to_tenants_table* Champs partenaire/onboarding sur tenants
2026_01_24_000002_create_onboarding_sessions_tableSessions d'onboarding
2026_01_24_000003_add_onboarding_session_id_to_kyb_documentsLien session <-> documents
2026_01_24_100001_create_openapi_configs_tableConfiguration OpenAPI OAuth2
2026_01_24_100002_create_openapi_tokens_tableTokens OpenAPI
2026_01_24_150001_add_paid_status_to_invoicesAjout statut paiement sur factures
2026_01_24_150002_create_sync_cursors_tableCurseurs de synchronisation
2026_01_24_214500_create_mcp_sessions_tableSessions MCP
2026_01_24_add_incoming_invoice_fieldsChamps factures entrantes

Phase 6 -- Extensions (2026-01-25/26)

MigrationDescription
2026_01_25_000001_add_tenant_fields_to_credit_notes_table* tenant_id/sub_tenant_id sur credit_notes
2026_01_26_000001_create_invoice_sequences_table* Sequences numerotation factures
2026_01_26_151113_make_user_id_nullable_for_tenant_entitiesuser_id nullable (entites tenant sans utilisateur)

Phase 7 -- Fiscal NF525 (2026-02-10)

MigrationDescription
2026_02_10_000001_create_fiscal_entries_table* Grand livre fiscal immutable
2026_02_10_000002_create_fiscal_sequences_table* Sequences atomiques fiscales
2026_02_10_000003_create_fiscal_closings_table* Clotures periodiques
2026_02_10_000004_create_fiscal_attestations_tableAttestations annuelles
2026_02_10_000005_add_fiscal_immutability_triggers* Triggers PostgreSQL d'immutabilite
2026_02_10_000006_add_legal_status_to_invoices_and_credit_notes* Ajout legal_status (donnee_fiscale/comptable)
2026_02_10_000007_create_fiscal_kill_switches_tableKill switch d'urgence
2026_02_10_000008_create_fiscal_integrity_checks_tableRapports d'integrite
2026_02_10_000009_create_fiscal_anchors_tableAncrages TSA RFC3161
2026_02_10_000010_create_fiscal_rules_tableRegles de conformite
2026_02_10_000011_create_fiscal_rule_applications_tableJournal application regles
2026_02_10_000012_add_anchor_reference_to_fiscal_anchors_tableAjout reference ancrage
2026_02_10_000012_fix_fiscal_isca_compliance* Corrections conformite ISCA
2026_02_10_000013_create_fiscal_audit_log_table* Journal d'audit fiscal
2026_02_10_100001_remove_soft_deletes_from_credit_notes* Suppression soft deletes (NF525)

Phase 8 -- MCP Multi-Tenant (2026-02-12)

MigrationDescription
2026_02_12_000001_add_tenant_id_to_mcp_sessionsLien tenant <-> sessions MCP

Phase 9 -- Renforcement Fiscal (2026-03-01)

MigrationDescription
2026_03_01_000001_fix_remaining_fiscal_fk_to_restrict_on_delete* FK RESTRICT sur tables fiscales
2026_03_01_000002_add_immutability_triggers_attestations_anchors* Triggers sur attestations et anchors
2026_03_01_000003_add_rls_policies_fiscal_tables* Policies RLS PostgreSQL sur tables fiscales

Documentation Scell.io