# wemis/passman-linux architecture

> Architecture diagram of the GitHub repository wemis/passman-linux, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-02-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/wemis/passman-linux
- Repository: https://github.com/wemis/passman-linux

## Overview

##### Project Overview
- The Passman project is a command-line password manager written in C. It primarily focuses on managing passwords, where the main functional areas include encryption, database management, and a text-based user interface (TUI).
- The project's structure (with separate src, include, and build directories) and naming (e.g., cryptography, dbmanager, tui) suggest a clear separation of concerns into different modules that collaborate to provide the full functionality.

##### Analyzing the File Structure
- Top-level files:
- Makefile: The build system script used for compiling the project.
- README.md: Briefly announces the project ("Passman").
- Databases: It includes actual database files (passwords.db and passwords_demo.db).
- Subdirectories:
- src: Contains the source code for the main, cryptography, dbmanager, and tui modules.
- Contains header files that define the interfaces for the corresponding modules.
- build: Contains the compiled object files, final executable “passman,” and a database file which might be used during runtime or testing.
- These elements indicate that the application is compiled into a single main executable that integrates the separate modules for cryptography, database management, and a text-based interface.

##### Key Components
a. Main Application Executable:
- Represents the integration point where the “main” function resides and from which the modules are invoked.
b. Cryptography Module:
- Handles encryption/decryption. This is critical for securing passwords.
c. Database Manager Module:
- Manages interactions with the passwords database (e.g., reading, writing encrypted password data).
d. TUI (Text User Interface) Module:
- Provides the user interface layer for receiving input and displaying outputs.
e. Persistent Storage (Database Files):
- Represents the actual database files (passwords.db and passwords_demo.db) that hold password data.
f. Build System:

##### Relationships and Interactions
- The TUI component then communicates with the main application logic (main.c), which in turn leverages the cryptography and dbmanager modules:
- The cryptography module may be shown as an auxiliary service used by the dbmanager for encryption before saving and decryption after retrieval.
- The dbmanager interacts directly with the persistent storage, i.e., the database files.

##### Architectural Patterns and Design Principles
- Modularity: each module (TUI, Cryptography, DB Manager) has a clearly defined responsibility.
- Separation of concerns: the user interface, data persistence, and security aspects (encryption) are handled in distinct modules.
- Cohesion: these modules are composed together via the main executable.
- While this is a simple, monolithic C application, drawing connections between the modules helps in understanding the flow of data and the dependencies among them.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "User Interaction"
        U["User"]:::user
        TUI["TUI Module"]:::module
        U -->|"input"| TUI
    end

    subgraph "Application Core"
        MA["Main Application"]:::module
        TUI -->|"invoke"| MA
        CRYPTO["Cryptography Module"]:::module
        DBM["Database Manager"]:::module
        MA -->|"encryption"| CRYPTO
        MA -->|"CRUD"| DBM
        PS["Persistent Storage (passwords.db, passwords_demo.db)"]:::database
        DBM -->|"database"| PS
    end

    subgraph "Development"
        BUILD["Build System"]:::build
        BUILD -->|"compiles_to"| MA
    end

    click TUI "https://github.com/wemis/passman-linux/blob/main/src/tui.c"
    click TUI "https://github.com/wemis/passman-linux/blob/main/include/tui.h"
    click TUI "https://github.com/wemis/passman-linux/blob/main/build/tui.o"

    click MA "https://github.com/wemis/passman-linux/blob/main/src/main.c"
    click MA "https://github.com/wemis/passman-linux/tree/main/build/passman"

    click CRYPTO "https://github.com/wemis/passman-linux/blob/main/src/cryptography.c"
    click CRYPTO "https://github.com/wemis/passman-linux/blob/main/include/cryptography.h"
    click CRYPTO "https://github.com/wemis/passman-linux/blob/main/build/cryptography.o"

    click DBM "https://github.com/wemis/passman-linux/blob/main/src/dbmanager.c"
    click DBM "https://github.com/wemis/passman-linux/blob/main/include/dbmanager.h"
    click DBM "https://github.com/wemis/passman-linux/blob/main/build/dbmanager.o"

    click PS "https://github.com/wemis/passman-linux/blob/main/passwords.db"
    click PS "https://github.com/wemis/passman-linux/blob/main/passwords_demo.db"

    click BUILD "https://github.com/wemis/passman-linux/tree/main/Makefile"
    click BUILD "https://github.com/wemis/passman-linux/tree/main/build"

    classDef user fill:#cce5ff,stroke:#333,stroke-width:2px;
    classDef module fill:#d4edda,stroke:#333,stroke-width:2px;
    classDef database fill:#fff3cd,stroke:#333,stroke-width:2px;
    classDef build fill:#f8d7da,stroke:#333,stroke-width:2px;
```
