# shariarratul/java-password-manager architecture

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

- Interactive diagram: https://gitdiagram.com/shariarratul/java-password-manager
- Repository: https://github.com/shariarratul/java-password-manager

## Overview

1. **Project type and runtime**
   - This is a small **Java console application** with a single-process, local-only architecture.
   - There is no web server, database, or external API; the entire app runs from `Main.java` and uses the local filesystem for persistence.

2. **Entry point / orchestration**
   - `Main.java` is the top-level controller.
   - It presents the menu-driven CLI, collects user input, and coordinates the two main actions:
     1. generate a password and save a credential record
     2. read and display previously saved credentials

3. **Password generation subsystem**
   - `PassGenerator.java` is responsible for creating random passwords.
   - The README indicates the user supplies a password length, and the generator returns a strong random string.
   - This is a pure utility-style component: it does not own storage or UI; it just produces password values for the rest of the app.

4. **Credential record model**
   - `SinglePass.java` appears to represent one saved credential entry.
   - The logical fields are the ones shown in the README: **website**, **email**, and **password**.
   - This class is the in-memory data boundary between UI/generation and persistence.

5. **Persistence subsystem**
   - `StoredPasswords.java` handles reading and writing the saved credentials.
   - The persistence format is plain text in `savedpass.txt`, with one record per line in comma-separated form, such as `example.com,user@example.com,pFQi2R_c7zs8`.
   - The storage location is the user’s **AppData/Local** folder, which is a local OS-specific boundary rather than an application-managed database.

6. **Data flow when saving a new password**
   - User input enters through `Main.java`.
   - `Main` sends the requested length to `PassGenerator`.
   - The generated password is combined with website and email into a `SinglePass` record.
   - `StoredPasswords` writes that record to `savedpass.txt` in AppData.

7. **Data flow when viewing saved passwords**
   - User selects the “see saved passwords” path from the CLI.
   - `Main.java` delegates to `StoredPasswords`.
   - `StoredPasswords` reads the text file, reconstructs records, and returns them for display in the console.

8. **Boundary between transient and durable data**
   - In-memory data is represented by `SinglePass`.
   - Durable state lives only in the text file under AppData.
   - There is no encryption, synchronization, or server-side storage, so the filesystem is the main persistence boundary.

9. **Security posture**
   - The README explicitly states that data is stored in **plain text**.
   - From an architecture standpoint, this means the app prioritizes simplicity over confidentiality and should be diagrammed as a local, unsecured credential store.

10. **Technology and packaging implications**
   - The repository appears to use the **default package** layout with separate `.java` source files rather than a layered package structure.
   - That suggests a lightweight, educational codebase with direct class-to-class calls instead of dependency injection or modular subsystems.

11. **What to show in an architecture diagram**
   - Draw one user-facing CLI boundary around `Main.java`.
   - Show `PassGenerator.java` as a utility called by `Main`.
   - Show `SinglePass.java` as the data object passed between components.
   - Show `StoredPasswords.java` connected to the local filesystem (`savedpass.txt` in AppData).
   - The key external dependency is the **local OS file system**, not any network service.

12. **Overall architecture summary**
   - This repository is a **small, three-layer logical design**:
     - UI/orchestration: `Main`
     - domain/utilities: `PassGenerator` and `SinglePass`
     - persistence: `StoredPasswords`
   - The main end-to-end flow is: **console input → password generation → record creation → file write/read → console output**.

Main entry points: [`Main.java`](https://github.com/shariarratul/java-password-manager/blob/main/Main.java) (Main), [`StoredPasswords.java`](https://github.com/shariarratul/java-password-manager/blob/main/StoredPasswords.java) (Storage), [`SinglePass.java`](https://github.com/shariarratul/java-password-manager/blob/main/SinglePass.java) (Credential), [`PassGenerator.java`](https://github.com/shariarratul/java-password-manager/blob/main/PassGenerator.java) (PassGen)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["CLI"]
  node_main["Main<br/>cli controller<br/>[Main.java]"]
end

subgraph group_core["Core"]
  node_passgen["PassGen<br/>password utility<br/>[PassGenerator.java]"]
  node_singlepass["Credential<br/>record model<br/>[SinglePass.java]"]
end

subgraph group_storage["Storage"]
  node_store[("Storage<br/>file persistence")]
  node_filesystem[("AppData file<br/>local filesystem")]
end

node_main -->|"generate"| node_passgen
node_main -->|"build"| node_singlepass
node_main -->|"save/read"| node_store
node_passgen -->|"value"| node_singlepass
node_store -->|"serialize"| node_singlepass
node_store -->|"write/read"| node_filesystem
node_main -.->|"display"| node_filesystem

click node_main "https://github.com/shariarratul/java-password-manager/blob/main/Main.java"
click node_passgen "https://github.com/shariarratul/java-password-manager/blob/main/PassGenerator.java"
click node_singlepass "https://github.com/shariarratul/java-password-manager/blob/main/SinglePass.java"
click node_store "https://github.com/shariarratul/java-password-manager/blob/main/StoredPasswords.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_main toneBlue
class node_passgen,node_singlepass toneAmber
class node_store,node_filesystem toneMint
```

## Components

### CLI

Console entry point and user interaction

- [Main](https://github.com/shariarratul/java-password-manager/blob/main/Main.java): cli controller · Menu-driven entry point that collects input and coordinates app actions · `Main.java`

### Core

Password generation and record model

- [PassGen](https://github.com/shariarratul/java-password-manager/blob/main/PassGenerator.java): password utility · Generates random passwords of requested length · `PassGenerator.java`
- [Credential](https://github.com/shariarratul/java-password-manager/blob/main/SinglePass.java): record model · In-memory credential entry with website, email, and password · `SinglePass.java`

### Storage

Local file persistence

- [Storage](https://github.com/shariarratul/java-password-manager/blob/main/StoredPasswords.java): file persistence · Reads and writes saved credentials as plain-text records · `StoredPasswords.java`
- **AppData file**: local filesystem · OS-local durable storage boundary for saved credentials

## Connections

- Main → PassGen: generate · Requests a password of the chosen length
- Main → Credential: build · Combines user input and generated password into a credential record
- Main → Storage: save/read · Delegates persistence and retrieval operations
- PassGen → Credential: value · Supplies generated password data used in the record
- Storage → Credential: serialize · Converts records to and from text lines
- Storage → AppData file: write/read · Persists plain-text credentials under the local AppData folder
- Main → AppData file: display · Shows persisted credentials after retrieval
