# devbynaveen/ciphervault architecture

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

- Interactive diagram: https://gitdiagram.com/devbynaveen/ciphervault
- Repository: https://github.com/devbynaveen/ciphervault

## Overview

**1) Overall shape**  
CipherVault is a **Java 21 desktop application** built with **JavaFX 21**. It is not networked: all state stays on the user’s machine. The main runtime path is a UI-driven client that talks to a local application service, which in turn coordinates crypto, filesystem storage, and a SQLite database.

**2) Top-level application boundary**  
`com.ciphervault.app` contains the launch boundary:
- `Launcher` is the executable entry point.
- `CipherVaultApp` is the JavaFX application class.

This is the UI shell that starts the desktop app and hands off to the rest of the system.

**3) Presentation layer**  
The UI is a JavaFX dashboard with styling in `src/main/resources/styles/app.css`. The repo structure suggests the UI is thin and delegates business actions outward rather than embedding storage or cryptography logic directly.

**4) Orchestration layer**  
`com.ciphervault.service.AppService` is the main coordination layer. It likely owns the user-facing workflows:
- first-time master password setup
- login verification
- file import
- file export
- deletion
- audit recording

This service is the central boundary between the UI and the lower-level subsystems.

**5) Security subsystem**  
`com.ciphervault.security` holds the core confidentiality logic:
- `PasswordService` and `PasswordHash` handle master password hashing/verification using PBKDF2.
- `CryptoService` and `EncryptedPayload` handle AES-GCM encryption/decryption for vault files.

The important architectural point is that file content is encrypted before persisting to disk and decrypted only in memory on export.

**6) Persistence subsystem: SQLite metadata store**  
`com.ciphervault.db` contains a small repository-based persistence layer:
- `DatabaseManager` manages the SQLite connection and setup
- `UserRepository` stores the master-password record
- `VaultFileRepository` stores metadata for vaulted files
- `AuditLogRepository` stores activity records

The database is the system of record for identity, vault metadata, and audit history, not for raw file contents.

**7) File storage subsystem**  
Encrypted file blobs live separately from the database under the user’s home directory, specifically `~/.ciphervault/vault/`. The database keeps references and metadata; the actual file payloads are stored as encrypted blobs on disk.

**8) Configuration and local paths**  
`com.ciphervault.config.AppPaths` centralizes filesystem locations under `~/.ciphervault/`, including:
- the SQLite database file
- the vault directory for ciphertext blobs

This is the main environment-specific boundary in the app.

**9) Data flow: setup and login**  
On first launch, the app creates a master password record. On subsequent launches, the entered password is verified against the stored hash. That password also derives the encryption key used by `CryptoService`. Successful authentication gates access to all vault operations.

**10) Data flow: import/export/delete**  
For import, file bytes are read, encrypted in memory, and written as ciphertext to the vault directory; metadata and an audit entry are then stored in SQLite. For export, the encrypted blob is read from disk, decrypted in memory, and written to a user-selected destination. Delete removes the stored blob and corresponding metadata, with the action logged.

**11) Audit trail**  
`AuditEntry` and `AuditLogRepository` indicate a built-in activity log for security-sensitive events. The audit trail covers login attempts and vault actions, giving the system traceability without involving any external service.

**12) Test coverage**  
Tests live under `src/test/java/com/ciphervault/security`, with unit coverage for:
- `CryptoService`
- `PasswordService`
- `AppService`

That suggests the most critical behavior is concentrated in security and orchestration logic rather than UI rendering.

**13) Architectural summary for a diagram**  
A good diagram would show: **JavaFX UI → AppService → {PasswordService/CryptoService, Repositories, AppPaths} → SQLite database + local encrypted vault files**. The key design constraint is that everything is local, and the sensitive file payloads are always encrypted at rest.

Main entry points: [`src/main/java/com/ciphervault/service/AppService.java`](https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/service/AppService.java) (AppService), [`src/main/java/com/ciphervault/app/CipherVaultApp.java`](https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/app/CipherVaultApp.java) (App Shell), [`src/main/java/com/ciphervault/security/CryptoService.java`](https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/security/CryptoService.java) (CryptoService), [`src/main/java/com/ciphervault/config/AppPaths.java`](https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/config/AppPaths.java) (App Paths)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_presentation["Presentation"]
  node_launcher["Launcher<br/>entry point<br/>[Launcher.java]"]
  node_app["App Shell<br/>javafx app"]
  node_ui_style["UI Style<br/>css<br/>[app.css]"]
end

subgraph group_orchestration["Orchestration"]
  node_app_service["AppService<br/>orchestrator<br/>[AppService.java]"]
end

subgraph group_security["Security"]
  node_password_service["PasswordService<br/>auth service"]
  node_crypto_service["CryptoService<br/>crypto service<br/>[CryptoService.java]"]
  node_password_hash["PasswordHash<br/>hash model<br/>[PasswordHash.java]"]
  node_encrypted_payload["Payload<br/>ciphertext model"]
end

subgraph group_persistence["Persistence"]
  node_db_manager["DB Manager<br/>sqlite setup"]
  node_user_repo["User Repo"]
  node_vault_repo["Vault Repo"]
  node_audit_repo["Audit Repo"]
end

subgraph group_storage["Local Storage"]
  node_sqlite_db[("SQLite DB<br/>local database")]
  node_vault_dir[("Vault Files<br/>local blobs")]
end

subgraph group_config["Configuration"]
  node_app_paths["App Paths<br/>path config<br/>[AppPaths.java]"]
end

subgraph group_models["Domain Models"]
  node_user_record["User Record<br/>domain record<br/>[UserRecord.java]"]
  node_vault_record["Vault Record<br/>domain record"]
  node_audit_entry["Audit Entry<br/>domain record<br/>[AuditEntry.java]"]
end

node_launcher -->|"starts"| node_app
node_app -->|"styles"| node_ui_style
node_app -->|"delegates"| node_app_service
node_app_service -->|"auth"| node_password_service
node_app_service -->|"encrypts"| node_crypto_service
node_password_service -->|"produces"| node_password_hash
node_crypto_service -->|"produces"| node_encrypted_payload
node_app_service -->|"uses"| node_db_manager
node_db_manager -->|"connects"| node_sqlite_db
node_app_service -->|"stores"| node_user_repo
node_app_service -->|"stores"| node_vault_repo
node_app_service -->|"logs"| node_audit_repo
node_user_repo -->|"maps"| node_user_record
node_vault_repo -->|"maps"| node_vault_record
node_audit_repo -->|"maps"| node_audit_entry
node_app_service -->|"resolves"| node_app_paths
node_app_paths -->|"points to"| node_vault_dir
node_app_paths -->|"points to"| node_sqlite_db
node_crypto_service -->|"reads/writes"| node_vault_dir
node_app_service -->|"imports/exports"| node_vault_dir
node_app_service -->|"records"| node_audit_entry

click node_launcher "https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/app/Launcher.java"
click node_app "https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/app/CipherVaultApp.java"
click node_ui_style "https://github.com/devbynaveen/ciphervault/blob/main/src/main/resources/styles/app.css"
click node_app_service "https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/service/AppService.java"
click node_password_service "https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/security/PasswordService.java"
click node_crypto_service "https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/security/CryptoService.java"
click node_password_hash "https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/security/PasswordHash.java"
click node_encrypted_payload "https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/security/EncryptedPayload.java"
click node_db_manager "https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/db/DatabaseManager.java"
click node_user_repo "https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/db/UserRepository.java"
click node_vault_repo "https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/db/VaultFileRepository.java"
click node_audit_repo "https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/db/AuditLogRepository.java"
click node_app_paths "https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/config/AppPaths.java"
click node_user_record "https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/model/UserRecord.java"
click node_vault_record "https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/model/VaultFileRecord.java"
click node_audit_entry "https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/model/AuditEntry.java"

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_launcher,node_app,node_ui_style,node_user_record,node_vault_record,node_audit_entry toneBlue
class node_app_service toneAmber
class node_password_service,node_crypto_service,node_password_hash,node_encrypted_payload toneMint
class node_db_manager,node_user_repo,node_vault_repo,node_audit_repo toneRose
class node_sqlite_db,node_vault_dir toneIndigo
class node_app_paths toneTeal
```

## Components

### Presentation

JavaFX desktop shell and styling

- [Launcher](https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/app/Launcher.java): entry point · Executable Java launch class · `src/main/java/com/ciphervault/app/Launcher.java`
- [App Shell](https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/app/CipherVaultApp.java): javafx app · JavaFX application bootstrap and UI host · `src/main/java/com/ciphervault/app/CipherVaultApp.java`
- [UI Style](https://github.com/devbynaveen/ciphervault/blob/main/src/main/resources/styles/app.css): css · Application styling for the desktop UI · `src/main/resources/styles/app.css`

### Orchestration

Application workflows and coordination

- [AppService](https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/service/AppService.java): orchestrator · Coordinates login, vault operations, and audit flow · `src/main/java/com/ciphervault/service/AppService.java`

### Security

Password and file cryptography

- [PasswordService](https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/security/PasswordService.java): auth service · Master password hashing and verification · `src/main/java/com/ciphervault/security/PasswordService.java`
- [CryptoService](https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/security/CryptoService.java): crypto service · Encrypts and decrypts vault file content · `src/main/java/com/ciphervault/security/CryptoService.java`
- [PasswordHash](https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/security/PasswordHash.java): hash model · PBKDF2 password hash representation · `src/main/java/com/ciphervault/security/PasswordHash.java`
- [Payload](https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/security/EncryptedPayload.java): ciphertext model · Encrypted file payload container · `src/main/java/com/ciphervault/security/EncryptedPayload.java`

### Persistence

SQLite-backed metadata and audit storage

- [DB Manager](https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/db/DatabaseManager.java): sqlite setup · Creates and manages the SQLite connection · `src/main/java/com/ciphervault/db/DatabaseManager.java`
- [User Repo](https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/db/UserRepository.java): repository · Stores the master-password record · `src/main/java/com/ciphervault/db/UserRepository.java`
- [Vault Repo](https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/db/VaultFileRepository.java): repository · Stores vaulted file metadata · `src/main/java/com/ciphervault/db/VaultFileRepository.java`
- [Audit Repo](https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/db/AuditLogRepository.java): repository · Persists security and activity audit events · `src/main/java/com/ciphervault/db/AuditLogRepository.java`

### Local Storage

Encrypted blobs and database files on disk

- **SQLite DB**: local database · Local metadata and audit store
- **Vault Files**: local blobs · Encrypted file blobs stored under the user profile

### Configuration

Filesystem location management

- [App Paths](https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/config/AppPaths.java): path config · Centralizes local filesystem locations · `src/main/java/com/ciphervault/config/AppPaths.java`

### Domain Models

Shared records used across layers

- [User Record](https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/model/UserRecord.java): domain record · Stored master-password metadata · `src/main/java/com/ciphervault/model/UserRecord.java`
- [Vault Record](https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/model/VaultFileRecord.java): domain record · Metadata for an encrypted vault file · `src/main/java/com/ciphervault/model/VaultFileRecord.java`
- [Audit Entry](https://github.com/devbynaveen/ciphervault/blob/main/src/main/java/com/ciphervault/model/AuditEntry.java): domain record · Log entry for authentication and vault actions · `src/main/java/com/ciphervault/model/AuditEntry.java`

## Connections

- Launcher → App Shell: starts · Launches the JavaFX application
- App Shell → UI Style: styles · Applies the desktop stylesheet
- App Shell → AppService: delegates · Hands user actions to the application service
- AppService → PasswordService: auth · Verifies and derives master-password state
- AppService → CryptoService: encrypts · Encrypts imported files and decrypts exports
- PasswordService → PasswordHash: produces · Creates and checks password hashes
- CryptoService → Payload: produces · Wraps encrypted file bytes and metadata
- AppService → DB Manager: uses · Opens and coordinates database access
- DB Manager → SQLite DB: connects · Manages the local SQLite database
- AppService → User Repo: stores · Reads and writes master-password records
- AppService → Vault Repo: stores · Persists vault file metadata
- AppService → Audit Repo: logs · Writes audit records for sensitive actions
- User Repo → User Record: maps · Persists user records
- Vault Repo → Vault Record: maps · Persists vault file records
- Audit Repo → Audit Entry: maps · Persists audit entries
- AppService → App Paths: resolves · Finds database and vault filesystem locations
- App Paths → Vault Files: points to · Locates the encrypted blob directory
- App Paths → SQLite DB: points to · Locates the SQLite file
- CryptoService → Vault Files: reads/writes · Stores encrypted file blobs on disk
- AppService → Vault Files: imports/exports · Coordinates file blob movement during vault actions
- AppService → Audit Entry: records · Creates audit events for login and vault operations
