Skip to content

overview architecture

Douwe de Vries edited this page Jul 1, 2026 · 1 revision

Architecture

CSV Anonymizer has three main layers: a React renderer, a Tauri command shell, and a Rust core crate. The frontend owns interaction state, the Tauri layer owns desktop access and background jobs, and crates/csv-anonymizer-core/src/service.rs owns detection, preview, transformation, and privacy reporting.

System map

graph LR
    User[User] -->|selects files or pastes data| Frontend[React UI]
    Frontend -->|invoke commands| Tauri[Tauri command shell]
    Tauri -->|authorize paths and jobs| Desktop[Desktop services]
    Tauri -->|call service APIs| Core[Rust core]
    Core -->|sample, detect, transform| Csv[CSV and pasted input]
    Core -->|optional provider calls| Smart[Smart replacement provider]
    Smart -->|localhost HTTP| Ollama[Ollama]
    Core -->|preview, output, report| Tauri
    Tauri -->|typed results| Frontend
Loading

The React app in frontend/src/App.tsx switches between the CSV file, paste sample, and quick data modes. Frontend command wrappers in frontend/src/tauri.ts call Tauri commands registered through src-tauri/src/tauri_command_list.rs and mounted in src-tauri/src/main.rs.

Layers and responsibilities

Layer Key files Responsibility
React frontend frontend/src/App.tsx, frontend/src/components/workflow/AnonymizerWorkflowView.tsx, frontend/src/hooks/useAnonymizerWorkflow.ts, frontend/src/tauri.ts UI state, forms, column selection, preview rendering, job polling, settings panel
Tauri shell src-tauri/src/main.rs, src-tauri/src/commands/csv.rs, src-tauri/src/path_access.rs, src-tauri/src/jobs.rs Command registration, file picker access grants, output path checks, blocking work offload, cancellation
Rust core crates/csv-anonymizer-core/src/service.rs, crates/csv-anonymizer-core/src/csv_io.rs, crates/csv-anonymizer-core/src/detection.rs, crates/csv-anonymizer-core/src/strategies/mod.rs CSV sampling, sensitive data detection, strategy application, streaming output, privacy reports
Local AI src-tauri/src/local_ai/provider.rs, src-tauri/src/local_ai/ollama.rs, crates/csv-anonymizer-core/src/smart.rs Ollama status checks, model download, prompt execution, replacement validation and fallback
Tooling package.json, frontend/package.json, scripts/check-contracts.mjs, .github/workflows/ci.yml Canonical checks, contract sync, package validation, release automation

CSV file flow

sequenceDiagram
    participant UI as React workflow
    participant Cmd as Tauri commands
    participant Access as PathAccess
    participant Core as AnonymizerService
    participant FS as File system

    UI->>Cmd: analyze_csv(filePath, sampleRowCount, suffix)
    Cmd->>Access: grant or authorize input path
    Cmd->>Core: analyze_csv_sampled()
    Core->>FS: read sample rows
    Core-->>Cmd: headers, metadata, selected columns
    Cmd-->>UI: AnalyzeResponse
    UI->>Cmd: preview_anonymization()
    Cmd->>Core: preview with controls
    Core-->>UI: samples and warnings
    UI->>Cmd: start_anonymize_job()
    Cmd->>Core: stream anonymize with progress control
    Core->>FS: write output atomically
    Core-->>Cmd: AnonymizeData and PrivacyReport
Loading

The full-file path stays streaming. crates/csv-anonymizer-core/src/csv_io.rs reads and writes rows while src-tauri/src/jobs.rs reports progress and lets the UI cancel through src-tauri/src/commands/job_commands.rs.

Data contracts

Rust DTOs are declared in crates/csv-anonymizer-core/src/types.rs and mirrored in frontend/src/types.ts. The repository does not generate these contracts; it checks them with scripts/check-contracts.mjs, which compares key enums and struct fields across both languages.

Source size snapshot

The source tree, excluding generated outputs and packaged release artifacts, is mostly Rust:

Language Files Lines
Rust 79 17,658
TSX 34 3,907
TypeScript 38 3,322
CSS 10 3,139
JavaScript 14 1,491
Python 4 1,400

See By the numbers for churn, test counts, bot-attributed commits, and hotspot data.

Clone this wiki locally