# gargmradul09/password_security_tool architecture

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

- Interactive diagram: https://gitdiagram.com/gargmradul09/password_security_tool
- Repository: https://github.com/gargmradul09/password_security_tool

## Overview

##### Project type and purpose
- This is a full-stack web application (“Password Security & Leak Detection Tool”).
- Purpose: let users enter passwords, evaluate strength (entropy), and check compromise status via Have I Been Pwned (HIBP) API without ever storing the raw password.

##### High-level file-structure analysis
- app.py: main Flask application / routing entry point
- breach_detection.py, password_hashing.py, password_security.py: core business-logic modules
- config.py: environment/configuration settings (e.g., HIBP key, rate-limit config)
- database.db, passwords.db, instance/passwords.db: SQLite stores (e.g., usage logs, rate-limiting counters)
- templates/*.html + index.html: presentation layer (user interface)
- Procfile & requirements.txt: deployment and dependency specs

##### Key insights from the README
- Backend: Python+Flask with SHA-1 k-anonymity to query HIBP
- Frontend: HTML/CSS/JS served either by Flask or via Vercel
- No raw-password persistence—privacy-first design
- Hosted on Render (backend) and Vercel (frontend)
- Security: rate-limiting, one-way hashing

a. Components
- User’s Web Browser (UI)
- Frontend (static HTML/CSS/JS)
- Flask Backend (app.py + service modules)
- SQLite Databases (instance/passwords.db, database.db)
- External Service: Have I Been Pwned (HIBP) API
- Configuration Store (config.py + instance folder)
- Deployment Platforms (Render, Vercel)
b. Relationships & Data Flows
1. User submits password → Frontend JS/form
2. HTTP POST → Flask Backend route (app.py)
3. app.py invokes password_hashing.py → compute SHA-1 prefix
4. breach_detection.py calls HIBP API (external HTTPS request)
5. HIBP responds with suffix list → breach_detection.py parses result
6. password_security.py evaluates entropy + breach result
7. Backend persists any rate-limit counters or logs to SQLite
8. Flask returns JSON or rendered template to Frontend
9. Frontend displays strength/breach status
c. Architectural patterns & design principles
- Layered architecture: Presentation Layer (templates),
Business-Logic Layer (service modules), Data Layer (SQLite)
- k-Anonymity design: secure‐by‐design pattern for external API calls
- Separation of concerns: routing vs. hashing vs. breach logic vs. config
- Minimal surface area: no raw‐password storage, ephemeral operations
d. Key technologies & frameworks
- Flask (routing + templating)
- Jinja2 templates (HTML views)
- Python modules for hashing & HTTP requests (requests library)
- SQLite (lightweight file‐based database)
- HIBP REST API (external service)
- Deployment: Render (backend) + Vercel (frontend hosting)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User and Frontend Tier
    User["User's Web Browser"]:::compute
    Vercel["Vercel CDN"]:::cloud
    subgraph "Presentation Layer"
        Index["index.html"]:::compute
        TemplateIndex["templates/index.html"]:::compute
        TemplateLogin["templates/login.html"]:::compute
    end

    %% Backend Tier
    subgraph "Backend Service"
        Render["Render (Backend)"]:::cloud
        subgraph "Routing Layer"
            App["app.py"]:::compute
        end
        subgraph "Service Layer"
            Hashing["password_hashing.py"]:::compute
            Breach["breach_detection.py"]:::compute
            Security["password_security.py"]:::compute
        end
        subgraph "Config Layer"
            Config["config.py"]:::compute
            InstanceDir["instance/"]:::db
        end
        subgraph "Data Layer"
            DB1["database.db"]:::db
            DB2["passwords.db"]:::db
            DB3["instance/passwords.db"]:::db
        end
    end

    External["Have I Been Pwned API"]:::external

    %% Data Flows
    User --> Vercel
    Vercel --> Index
    Vercel --> TemplateIndex
    Vercel --> TemplateLogin
    TemplateIndex --> App
    TemplateLogin --> App
    App --> Hashing
    Hashing --> Breach
    Breach --> External
    External --> Breach
    Breach --> Security
    Security --> DB1
    Security --> DB2
    Security --> DB3
    App --> Security
    App --> User
    Render --> App

    %% Click Events
    click App "https://github.com/gargmradul09/password_security_tool/blob/master/app.py"
    click Hashing "https://github.com/gargmradul09/password_security_tool/blob/master/password_hashing.py"
    click Breach "https://github.com/gargmradul09/password_security_tool/blob/master/breach_detection.py"
    click Security "https://github.com/gargmradul09/password_security_tool/blob/master/password_security.py"
    click Config "https://github.com/gargmradul09/password_security_tool/blob/master/config.py"
    click InstanceDir "https://github.com/gargmradul09/password_security_tool/tree/master/instance/"
    click DB1 "https://github.com/gargmradul09/password_security_tool/blob/master/database.db"
    click DB2 "https://github.com/gargmradul09/password_security_tool/blob/master/passwords.db"
    click DB3 "https://github.com/gargmradul09/password_security_tool/blob/master/instance/passwords.db"
    click Index "https://github.com/gargmradul09/password_security_tool/blob/master/index.html"
    click TemplateIndex "https://github.com/gargmradul09/password_security_tool/blob/master/templates/index.html"
    click TemplateLogin "https://github.com/gargmradul09/password_security_tool/blob/master/templates/login.html"
    click Procfile "https://github.com/gargmradul09/password_security_tool/tree/master/Procfile"
    click Requirements "https://github.com/gargmradul09/password_security_tool/blob/master/requirements.txt"
    click README "https://github.com/gargmradul09/password_security_tool/blob/master/README.md"

    %% Styles
    classDef compute fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef db fill:#90EE90,stroke:#333,stroke-width:1px
    classDef external fill:#FFA500,stroke:#333,stroke-width:1px
    classDef cloud fill:#D3D3D3,stroke:#333,stroke-width:1px
```
