FR Demo

Classes

class Receipt modelA receipt is composed of items and VAT lines. Each value records where it came from.«dataclass»Receipt+ doc_type : str+ merchant_name : str [0..1]+ siret : str [0..1]+ date : str [0..1]+ currency : str [0..1]+ total_cents : int [0..1]+ discounts_cents : int+ prov : Map<str, str>+ to_dict() : Map+ from_dict(d) : Receipt«dataclass»Item+ raw_name : str+ qty : float [0..1]+ unit_price_cents : int [0..1]+ line_total_cents : int [0..1]+ weight_kg : float [0..1]+ vat_code : str [0..1]+ confidence : float+ bbox : float [0..4]«dataclass»VatLine+ code : str [0..1]+ rate : float [0..1]+ base_cents : int [0..1]+ vat_cents : int [0..1]«enumeration»Provenancereadcomputedinferredmissinguser«dataclass»Issue+ path : str+ kind : str+ severity : str+ candidates : List+ fixes : List*1*1provpoints atclass Receipt model
class Verification pipelineThe pipeline merges several readings, checks the arithmetic and returns the receipt with its doubts.«dataclass»Capture+ section : int+ image_b64 : str [0..1]+ mime : str+ text : str [0..1]«module»Pipeline+ process(captures : List, extractor) : Processed«interface»Extractor+ extract_image(b64, mime)+ extract_text(text)«module»Merge+ vote(reads) : VoteResult+ stitch(sections) : Receipt«dataclass»Processed+ receipt : Receipt+ issues : List<Issue>+ quality : float+ reads : int+ needs_review() : bool«module»Verify+ verify(receipt, price_lookup) : Result«dataclass»Dispute+ path : str+ candidates : List«dataclass»PiiReport+ removed : List«dataclass»PriceHint+ unit_price_cents : int+ samples : intreadscalls«create»usesuses«create»*usesclass Verification pipeline
class Product recognitionA printed line goes in; a product, a confidence and other candidates come out.Resolver- aliases : Map- shared : Map- catalog : List- judge : Judge [0..1]+ resolve(line) : Resolution+ key(raw_name) : str«dataclass»Line+ raw_name : str+ merchant_key : str+ weighed : bool+ vat_rate : float [0..1]+ section : str [0..1]«interface»Judge+ choose(line, candidates)«dataclass»Resolution+ product : str [0..1]+ category_id : str [0..1]+ confidence : float+ source : str+ signals : List<str>+ needs_question() : bool«dataclass»Normalized+ text : str+ tokens : List<str>+ size_value : float [0..1]+ size_unit : str [0..1]+ pack : int [0..1]+ organic : bool«dataclass»Candidate+ name : str+ category_id : str+ score : float+ source : strtakes0..1«create»11*1class Product recognition
class Interfaces and implementationsThe core only knows the interfaces. Cloudflare, browser and test versions implement them.«dataclass»Context+ db : Database+ blobs : Blobs+ mailer : Mailer+ extractor : Extractor [0..1]«interface»Database+ all(sql) : List+ batch(statements)«interface»Blobs+ put(key, bytes)+ delete_prefix(p)«interface»Mailer+ send(to, subject)«interface»Extractor+ extract_image()+ extract_text()D1DatabaseSqliteDatabaseR2BlobsFileBlobsResendMailerLogMailerWorkersAIExtractorDemoExtractorclass Interfaces and implementations
class RetrievalHybrid search joins keyword and meaning search. A LangChain retriever wraps it.HybridSearch- index : Index- embedder : Embedder- reranker : Reranker [0..1]+ search(user, query, k) : ListCostmapRetriever+ user_id : str+ k : int- _get_relevant_documents()«LangChain»BaseRetrieverIndex- db : SQLite with FTS5+ add(user, chunks, vectors)+ keyword(user, query)+ vector(user, qvec)+ delete_user(user)«interface»Embedder+ name : str+ dim : int+ embed(texts) : array«interface»Reranker+ score(query, texts)FastEmbedderHashEmbedderFastRerankeruses0..1class Retrieval