# santhoshharsha375-afk/journalfs architecture

> Architecture diagram of the GitHub repository santhoshharsha375-afk/journalfs, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/santhoshharsha375-afk/journalfs
- Repository: https://github.com/santhoshharsha375-afk/journalfs

## Overview

JournalFS is a C filesystem stored in a regular disk-image file, exposed through both a FUSE mount and a command-line driver. The principal workflow is a user operation entering the driver, reaching filesystem operations, and persisting metadata atomically through the WAL before applying it to the image. Mount-time recovery replays committed work; formatting, checking, checkpointing, and journal inspection are supporting product capabilities. Some subsystem links are documented by the README rather than shown in sampled implementation excerpts.

Main entry points: [`src/transaction.c`](https://github.com/santhoshharsha375-afk/journalfs/blob/master/src/transaction.c) (Transaction Manager), [`src/disk.c`](https://github.com/santhoshharsha375-afk/journalfs/blob/master/src/disk.c) (Disk Image I/O), [`src/journal.c`](https://github.com/santhoshharsha375-afk/journalfs/blob/master/src/journal.c) (Write-Ahead Log), [`src/main.c`](https://github.com/santhoshharsha375-afk/journalfs/blob/master/src/main.c) (CLI and Mount Driver)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User Interfaces"]
  node_driver["CLI and Mount Driver<br/>[main.c]"]
  node_fuse["FUSE Operations<br/>[fuse_ops.c]"]
end

subgraph group_filesystem["Filesystem Core"]
  node_fs_ops["Filesystem Operations<br/>[filesystem.c]"]
  node_format["Image Format<br/>[journalfs.h]"]
end

subgraph group_durability["Durability"]
  node_transactions["Transaction Manager<br/>[transaction.c]"]
  node_journal["Write-Ahead Log<br/>[journal.c]"]
  node_recovery["Crash Recovery<br/>[recovery.c]"]
  node_checkpoint["Journal Checkpointing<br/>[checkpoint.c]"]
  node_disk[("Disk Image I/O<br/>[disk.c]")]
end

subgraph group_image_tools["Image Tools"]
  node_mkfs["Image Formatter<br/>[mkfs.c]"]
  node_fsck_cli["FSCK Command<br/>[fsck_journalfs.c]"]
  node_fsck["Consistency Checker<br/>[fsck.c]"]
  node_inspector["Journal Inspector<br/>[journal_inspect.c]"]
end

node_user(("User"))

node_user -->|"issues operation"| node_driver
node_driver -->|"dispatches operations"| node_fs_ops
node_driver -->|"starts mount"| node_fuse
node_fuse -->|"uses filesystem"| node_fs_ops
node_fs_ops -->|"commits metadata"| node_transactions
node_transactions -->|"writes WAL records"| node_journal
node_transactions -->|"applies home blocks"| node_disk
node_transactions -->|"requests replay"| node_recovery
node_transactions -->|"reclaims journal slots"| node_checkpoint
node_recovery -->|"scans committed records"| node_journal
node_recovery -->|"replays updates"| node_disk
node_checkpoint -->|"reclaims slots"| node_journal
node_mkfs -->|"creates image"| node_disk
node_fsck_cli -->|"checks image"| node_fsck
node_fsck -->|"reads image"| node_disk
node_inspector -->|"reads records"| node_journal
node_inspector -->|"opens image"| node_disk

click node_driver "https://github.com/santhoshharsha375-afk/journalfs/blob/master/src/main.c"
click node_fuse "https://github.com/santhoshharsha375-afk/journalfs/blob/master/src/fuse_ops.c"
click node_fs_ops "https://github.com/santhoshharsha375-afk/journalfs/blob/master/src/filesystem.c"
click node_format "https://github.com/santhoshharsha375-afk/journalfs/blob/master/include/journalfs.h"
click node_transactions "https://github.com/santhoshharsha375-afk/journalfs/blob/master/src/transaction.c"
click node_journal "https://github.com/santhoshharsha375-afk/journalfs/blob/master/src/journal.c"
click node_recovery "https://github.com/santhoshharsha375-afk/journalfs/blob/master/src/recovery.c"
click node_checkpoint "https://github.com/santhoshharsha375-afk/journalfs/blob/master/src/checkpoint.c"
click node_disk "https://github.com/santhoshharsha375-afk/journalfs/blob/master/src/disk.c"
click node_mkfs "https://github.com/santhoshharsha375-afk/journalfs/blob/master/src/mkfs.c"
click node_fsck_cli "https://github.com/santhoshharsha375-afk/journalfs/blob/master/tools/fsck_journalfs.c"
click node_fsck "https://github.com/santhoshharsha375-afk/journalfs/blob/master/src/fsck.c"
click node_inspector "https://github.com/santhoshharsha375-afk/journalfs/blob/master/tools/journal_inspect.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_driver,node_fuse,node_user toneBlue
class node_fs_ops,node_format toneAmber
class node_transactions,node_journal,node_recovery,node_checkpoint,node_disk toneMint
class node_mkfs,node_fsck_cli,node_fsck,node_inspector toneRose
```

## Components

### User Interfaces

- [CLI and Mount Driver](https://github.com/santhoshharsha375-afk/journalfs/blob/master/src/main.c): `src/main.c`
- [FUSE Operations](https://github.com/santhoshharsha375-afk/journalfs/blob/master/src/fuse_ops.c): `src/fuse_ops.c`

### Filesystem Core

- [Filesystem Operations](https://github.com/santhoshharsha375-afk/journalfs/blob/master/src/filesystem.c): `src/filesystem.c`
- [Image Format](https://github.com/santhoshharsha375-afk/journalfs/blob/master/include/journalfs.h): `include/journalfs.h`

### Durability

- [Transaction Manager](https://github.com/santhoshharsha375-afk/journalfs/blob/master/src/transaction.c): `src/transaction.c`
- [Write-Ahead Log](https://github.com/santhoshharsha375-afk/journalfs/blob/master/src/journal.c): `src/journal.c`
- [Crash Recovery](https://github.com/santhoshharsha375-afk/journalfs/blob/master/src/recovery.c): `src/recovery.c`
- [Journal Checkpointing](https://github.com/santhoshharsha375-afk/journalfs/blob/master/src/checkpoint.c): `src/checkpoint.c`
- [Disk Image I/O](https://github.com/santhoshharsha375-afk/journalfs/blob/master/src/disk.c): `src/disk.c`

### Image Tools

- [Image Formatter](https://github.com/santhoshharsha375-afk/journalfs/blob/master/src/mkfs.c): `src/mkfs.c`
- [FSCK Command](https://github.com/santhoshharsha375-afk/journalfs/blob/master/tools/fsck_journalfs.c): `tools/fsck_journalfs.c`
- [Consistency Checker](https://github.com/santhoshharsha375-afk/journalfs/blob/master/src/fsck.c): `src/fsck.c`
- [Journal Inspector](https://github.com/santhoshharsha375-afk/journalfs/blob/master/tools/journal_inspect.c): `tools/journal_inspect.c`

### Other components

- **User**

## Connections

- User → CLI and Mount Driver: issues operation (evidence: `README.md`)
- CLI and Mount Driver → Filesystem Operations: dispatches operations (evidence: `src/main.c`)
- CLI and Mount Driver → FUSE Operations: starts mount (evidence: `README.md`)
- FUSE Operations → Filesystem Operations: uses filesystem (evidence: `README.md`)
- Filesystem Operations → Transaction Manager: commits metadata (evidence: `src/filesystem.c`)
- Transaction Manager → Write-Ahead Log: writes WAL records (evidence: `README.md`)
- Transaction Manager → Disk Image I/O: applies home blocks (evidence: `README.md`)
- Transaction Manager → Crash Recovery: requests replay (evidence: `README.md`)
- Transaction Manager → Journal Checkpointing: reclaims journal slots (evidence: `README.md`)
- Crash Recovery → Write-Ahead Log: scans committed records (evidence: `README.md`)
- Crash Recovery → Disk Image I/O: replays updates (evidence: `README.md`)
- Journal Checkpointing → Write-Ahead Log: reclaims slots (evidence: `README.md`)
- Image Formatter → Disk Image I/O: creates image (evidence: `README.md`)
- FSCK Command → Consistency Checker: checks image (evidence: `tools/fsck_journalfs.c`)
- Consistency Checker → Disk Image I/O: reads image (evidence: `README.md`)
- Journal Inspector → Write-Ahead Log: reads records (evidence: `tools/journal_inspect.c`)
- Journal Inspector → Disk Image I/O: opens image (evidence: `tools/journal_inspect.c`)
