Core Concepts

System Architecture

How the Flutter frontend, FFI bridge, and native C backend work together.

Architecture Overview

Swipe uses a three-layer architecture: a Flutter UI, a Dart FFI bridge, and a native C shared library (libdriveinfo.so). All disk I/O happens in C; the UI is purely for display and user interaction.

Flutter UI Layer

Screens, Widgets, BLoC Cubits (Dart)

FFI Bridge

DriveInfoBindings — dart:ffi → libdriveinfo.so

Native C Backend

ATA, NVMe, SAT handlers • Wipe Engine • nwipe PRNG

Linux Kernel

ioctl() • /dev/sd* /dev/nvme* • /sys/block/

Backend — C Library (libdriveinfo)

The backend lives in swipe-cli/ and compiles to libdriveinfo.so. Key modules:

enumerate.c

Discovers all physical drives via libudev and populates drive_info_t structs.

ata.c / nvme.c / sat.c

Protocol-specific handlers using ioctl: HDIO for ATA, NVME_IOCTL for NVMe, SG_IO for SCSI/USB.

wipe.c + wipe_thread.c

Software wipe engine. Spawns dedicated threads per drive, writes patterns sector-by-sector.

purge_ata.c

Hardware-level purge via ATA Security Erase, ATA Sanitize, and NVMe Sanitize commands.

nwipe/

Pattern generators (ISAAC, Mersenne Twister, ALFG, XOR) integrated from nwipe project for randomized passes.

api.c

Public-facing C API used by FFI. Wraps all internal modules into clean function signatures.

Frontend — Flutter App (swip2.0)

The Flutter app uses a hybrid state management approach:

BLoC Cubits (Shared State)

ThemeCubit, DevicesCubit, WipeJobsCubit, NavigationCubit manage cross-screen state.

StatefulWidgets (Local State)

Individual screens use setState() for animations, form inputs, and complex UI interactions.

Services

DeviceRegistryService polls drives, WipeService wraps FFI, PdfService generates certificates.

FFI Bindings

DriveInfoBindings uses dart:ffi to call C functions directly — no MethodChannel, no Isolates.

Screen Map

Tab Screen Purpose
0 — Discovery DiscoveryScreen Lists connected drives, tap to see details
1 — Sanitize SanitizeTabScreen Active wipe jobs dashboard
2 — Capabilities DriveCapabilitiesScreen ATA security, hex viewer, NVMe management
3 — Settings SettingsScreen Theme toggle, about info