# pranavsurya77/smart-home-door-lock-system architecture

> Architecture diagram of the GitHub repository pranavsurya77/smart-home-door-lock-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-08). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/pranavsurya77/smart-home-door-lock-system
- Repository: https://github.com/pranavsurya77/smart-home-door-lock-system

## Overview

##### Main Components
- Hardware Block (embedded):
- RFID Reader (MFRC522)
- Arduino Uno (microcontroller)
- Servo Motor (door actuator)
- LEDs, Resistors, Buzzers (audio alerts)
- Software Block (host PC/RPi):
- Python Backend (`pyemail.py`)
– pyserial (Serial I/O)
– openpyxl (Excel logging)
– smtplib (Email alerts)
– pygame (Audio alerts)
- Excel File (`information.xlsx`)
- External Service:
- SMTP Email Server (e.g., Gmail)

##### Interactions & Data Flows
- RFID card presented → MFRC522 reads UID → Arduino
- Arduino logic (success/fail count) → sends status over USB‐Serial
- Python script listens on serial port
a. On “access granted” →
- Send “unlock” command back → Arduino actuates servo → door unlocks
- Log event row into `information.xlsx`
- Send email via SMTP → homeowner receives notification
- Play success audio via pygame
b. On “access denied” →
- Increment failure count → if ≥3, lockout logic
- Log failure in Excel
- Send “denied” or “lockout” command → Arduino signals LED/buzzer
- Send email alert (optional)
- Play failure audio

##### Architectural Patterns & Principles
- Hardware/firmware separation:
- Real-time control and sensor I/O on Arduino
- High-level processing (logging, email, audio) on host
- Single Responsibility:
- Arduino: I/O, servo control, basic state machine
- Python: user-notification, persistence, external comms
- Loosely coupled via serial interface

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Swimlanes
    subgraph "Hardware Components"
        direction TB
        RFID["RFID Reader (MFRC522)"]:::hardware
        Arduino["Arduino Uno"]:::hardware
        Servo["Servo Motor"]:::hardware
        Actuators["LEDs & Buzzer"]:::hardware
    end

    subgraph "Software Components"
        direction TB
        Python["Python Backend"]:::software
        Excel["information.xlsx"]:::datastore
        EmailServer["SMTP Email Server"]:::external
        Audio["Audio Alerts (pygame)"]:::software
    end

    %% Artifacts
    subgraph "Project Artifacts"
        direction TB
        README["Project Documentation"]:::artifact
        Report["System Design Report"]:::artifact
        PPT["System Design Presentation"]:::artifact
    end

    %% Data Flows
    RFID -->|"UID read"| Arduino
    Arduino -->|"Serial data"| Python
    Python -->|"grant"| Arduino
    Python -->|"deny/lockout"| Arduino
    Python -->|"log row"| Excel
    Python -->|"SMTP mail"| EmailServer
    Python -->|"play audio"| Audio

    %% Click Events
    click Arduino "https://github.com/pranavsurya77/smart-home-door-lock-system/blob/master/iot_project.ino"
    click README "https://github.com/pranavsurya77/smart-home-door-lock-system/blob/master/README.md"
    click Report "https://github.com/pranavsurya77/smart-home-door-lock-system/blob/master/Report.pdf"
    click PPT "https://github.com/pranavsurya77/smart-home-door-lock-system/blob/master/Smart Home Door Lock System.pptx"

    %% Styles
    classDef hardware fill:#d3d3d3,stroke:#333,stroke-width:1px
    classDef software fill:#add8e6,stroke:#333,stroke-width:1px
    classDef datastore fill:#ffa500,stroke:#333,stroke-width:1px
    classDef external fill:#ffff99,stroke:#333,stroke-width:1px
    classDef artifact fill:#e0e0e0,stroke:#666,stroke-width:1px,stroke-dasharray: 2 2
```
