# nathang15/voice-recognition-authentication-system architecture

> Architecture diagram of the GitHub repository nathang15/voice-recognition-authentication-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nathang15/voice-recognition-authentication-system
- Repository: https://github.com/nathang15/voice-recognition-authentication-system

## Overview

##### Project type and purpose
- This is a standalone, AI-based voice authentication CLI tool written in Python.
- Purpose: allow users to register and log in by speaking a username and passphrase, rather than typing credentials.

##### File structure
- Top-level directory “Code/” contains 6 modules:
- credentials_setting.py   (handles reading/writing user credentials)
- hash_salt.py             (wraps bcrypt hashing and salting)
- main.py                  (orchestrates the overall flow)
- system_speak.py          (text-to-speech operations via pyttsx3)
- user_setup.py            (registration flow)
- verification.py          (login/verification flow)
- No web server or frontend framework—pure Python CLI.
- External dependencies are captured in README: Whisper (speech-to-text), pyttsx3 (text-to-speech), bcrypt (password hashing).

##### README for additional insights
- The system loops through a Q&A flow: TTS prompts → user speaks → Whisper transcribes → business logic (register/verify) → hash & store or compare against stored hash → TTS feedback.
- Credentials are stored locally (e.g., file or simple database).

##### Main components & their interactions
a. Components:
- Audio Input (microphone)
- Speech Recognition Module (OpenAI Whisper)
- Business Logic Layer
– Registration Service (user_setup.py + credentials_setting.py)
– Verification Service (verification.py + hash_salt.py)
- Data Storage (local credential store)
- Text-to-Speech Module (system_speak.py using pyttsx3)
- Orchestrator (main.py)
b. Data flows:
- Orchestrator → TTS prompts → Audio Input → Whisper → text
- Text → Business Logic → hashing/DB read-write → result
- Result → Orchestrator → TTS feedback → user
c. Architectural patterns:
- Pipeline style: audio in → recognition → logic → storage → TTS out
- Separation of concerns: speech I/O, hashing, storage, orchestration are in separate modules.
d. Key technologies:
- whisper (speech-to-text)
- pyttsx3 (text-to-speech)
- bcrypt (secure hash & salt)
- Python standard library (file I/O / CLI)

##### Detailed breakdown for the engineer
- Inside it, arrange horizontally:
[ User ] → (mic) → [ Whisper STT ] → [ Orchestrator (main.py) ] → branching to
├─ [ Registration Flow (user_setup.py + credentials_setting.py) ]
└─ [ Verification Flow (verification.py + hash_salt.py) ]
Both flows interact with → [ Local Credential Store ]
Orchestrator also → [ TTS (system_speak.py) ] → (speaker) → back to User
- Side note: “Whisper model is loaded at startup; bcrypt salts stored per-user.”

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Actors and I/O
    User["User"]:::external
    Microphone["Microphone (Audio Input)"]:::audio
    Whisper["Whisper STT"]:::audio
    Orchestrator["Orchestrator\n(main.py)"]:::logic
    TTS["Text-to-Speech\n(system_speak.py)"]:::audio
    Speaker["Speaker (Audio Output)"]:::audio

    %% Business Logic Flows
    subgraph "Business Logic"
        Registration["Registration Flow\n(user_setup.py)"]:::logic
        Credentials["Credentials Module\n(credentials_setting.py)"]:::logic
        Verification["Verification Flow\n(verification.py)"]:::logic
        HashSalt["Hashing & Salting\n(hash_salt.py)"]:::logic
    end

    %% Storage
    CredentialStore{{"Local Credential Store"}}:::storage

    %% Flow Connections
    User -->|"speaks"| Microphone
    Microphone -->|"audio"| Whisper
    Whisper -->|"text"| Orchestrator
    Orchestrator -->|"start registration"| Registration
    Registration -->|"invoke save"| Credentials
    Credentials -->|"write"| CredentialStore
    Orchestrator -->|"start verification"| Verification
    Verification -->|"invoke hash compare"| HashSalt
    HashSalt -->|"read/write"| CredentialStore
    Orchestrator -->|"prompt feedback"| TTS
    TTS -->|"audio"| Speaker
    Speaker -->|"hears"| User

    %% Click Events
    click Orchestrator "https://github.com/nathang15/voice-recognition-authentication-system/blob/main/Code/main.py"
    click Whisper "https://github.com/nathang15/voice-recognition-authentication-system/blob/main/Code/main.py"
    click TTS "https://github.com/nathang15/voice-recognition-authentication-system/blob/main/Code/system_speak.py"
    click Registration "https://github.com/nathang15/voice-recognition-authentication-system/blob/main/Code/user_setup.py"
    click Credentials "https://github.com/nathang15/voice-recognition-authentication-system/blob/main/Code/credentials_setting.py"
    click Verification "https://github.com/nathang15/voice-recognition-authentication-system/blob/main/Code/verification.py"
    click HashSalt "https://github.com/nathang15/voice-recognition-authentication-system/blob/main/Code/hash_salt.py"

    %% Styles
    classDef audio fill:#c6f5c6,stroke:#2d862d,color:#000;
    classDef logic fill:#c6d6f5,stroke:#2a3c81,color:#000;
    classDef storage fill:#f5ddb0,stroke:#a36f00,color:#000;
    classDef external fill:#dddddd,stroke:#888888,color:#000;
```
