# karan-nevage/electronic-safe architecture

> Architecture diagram of the GitHub repository karan-nevage/electronic-safe, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/karan-nevage/electronic-safe
- Repository: https://github.com/karan-nevage/electronic-safe

## Overview

This is an Arduino-based electronic safe: a user enters a code or chooses an action on the keypad, the sketch checks or updates safe state, and the servo locks or unlocks the mechanism while the LCD reports status. The README documents these interactions, and SafeState.h confirms the state API. The main sketch and hardware wiring are not sampled, so wiring details and internal call order beyond the documented workflow are not shown.

Main entry points: [`Using Arduino Uno/safe_arduino.ino`](https://github.com/karan-nevage/electronic-safe/blob/main/Using%20Arduino%20Uno/safe_arduino.ino) (Safe controller), [`Using Arduino Uno/lib/SafeState.h`](https://github.com/karan-nevage/electronic-safe/blob/main/Using%20Arduino%20Uno/lib/SafeState.h) (SafeState)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interaction["User interface"]
  node_keypad["4x4 Keypad"]
  node_lcd["16x2 LCD"]
end

subgraph group_control["Safe control"]
  node_sketch["Safe controller<br/>[safe_arduino.ino]"]
  node_code_entry["Code entry<br/>[safe_arduino.ino]"]
  node_code_setup["Code setup<br/>[safe_arduino.ino]"]
  node_safe_state["SafeState<br/>[SafeState.h]"]
end

subgraph group_hardware["Safe hardware"]
  node_servo["Servo motor"]
  node_lock["Lock mechanism"]
end

node_user(("User"))

node_user -->|"enters choices"| node_keypad
node_keypad -->|"provides input"| node_sketch
node_sketch -->|"prompts for code"| node_code_entry
node_code_entry -->|"reads digits"| node_keypad
node_sketch -->|"checks code and state"| node_safe_state
node_safe_state -->|"returns result"| node_sketch
node_sketch -->|"starts code change"| node_code_setup
node_code_setup -->|"reads new codes"| node_keypad
node_code_setup -->|"sets matching code"| node_safe_state
node_sketch -->|"displays prompts and status"| node_lcd
node_sketch -->|"sets position"| node_servo
node_servo -->|"moves mechanism"| node_lock

click node_sketch "https://github.com/karan-nevage/electronic-safe/blob/main/Using%20Arduino%20Uno/safe_arduino.ino"
click node_code_entry "https://github.com/karan-nevage/electronic-safe/blob/main/Using%20Arduino%20Uno/safe_arduino.ino"
click node_code_setup "https://github.com/karan-nevage/electronic-safe/blob/main/Using%20Arduino%20Uno/safe_arduino.ino"
click node_safe_state "https://github.com/karan-nevage/electronic-safe/blob/main/Using%20Arduino%20Uno/lib/SafeState.h"

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_keypad,node_lcd,node_user toneBlue
class node_sketch,node_code_entry,node_code_setup,node_safe_state toneAmber
class node_servo,node_lock toneMint
```

## Components

### User interface

- **4x4 Keypad**
- **16x2 LCD**

### Safe control

- [Safe controller](https://github.com/karan-nevage/electronic-safe/blob/main/Using%20Arduino%20Uno/safe_arduino.ino): `Using Arduino Uno/safe_arduino.ino`
- [Code entry](https://github.com/karan-nevage/electronic-safe/blob/main/Using%20Arduino%20Uno/safe_arduino.ino): `Using Arduino Uno/safe_arduino.ino`
- [Code setup](https://github.com/karan-nevage/electronic-safe/blob/main/Using%20Arduino%20Uno/safe_arduino.ino): `Using Arduino Uno/safe_arduino.ino`
- [SafeState](https://github.com/karan-nevage/electronic-safe/blob/main/Using%20Arduino%20Uno/lib/SafeState.h): `Using Arduino Uno/lib/SafeState.h`

### Safe hardware

- **Servo motor**
- **Lock mechanism**

### Other components

- **User**

## Connections

- User → 4x4 Keypad: enters choices
- 4x4 Keypad → Safe controller: provides input
- Safe controller → Code entry: prompts for code
- Code entry → 4x4 Keypad: reads digits
- Safe controller → SafeState: checks code and state
- SafeState → Safe controller: returns result
- Safe controller → Code setup: starts code change
- Code setup → 4x4 Keypad: reads new codes
- Code setup → SafeState: sets matching code
- Safe controller → 16x2 LCD: displays prompts and status
- Safe controller → Servo motor: sets position
- Servo motor → Lock mechanism: moves mechanism
