# nagraj-13/dhvani architecture

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

- Interactive diagram: https://gitdiagram.com/nagraj-13/dhvani
- Repository: https://github.com/nagraj-13/dhvani

## Overview

##### Main System Components

a) Input/Sensor Layer
- Camera input (for facial recognition)
- Microphone input (for speech recognition)
- Location sensors (indicated by location.json)

b) Core Processing Layer
- Face Recognition Module
- Speech Recognition Module
- Communication Handler
- Location & Weather Services
- Music Control System
- Data Management System

c) Output/Action Layer
- Alert System
- Music Playback
- Navigation Instructions
- Communication Actions (WhatsApp)

##### Component Relationships

a) Data Flow Paths:
- Camera → Face Recognition Module → Alert System
- Microphone → Speech Recognition → Command Processing
- Location Sensors → Location & Weather Services → Navigation Output

b) Storage Interactions:
- Connections to JSON data stores:
- patterns.json (communication patterns)
- car_maintenance_dataset.json
- jokes_dataset.json
- music_data.json
- location.json

##### Specific Implementation Details

- main.py (Central Controller)
- face_rec.py (Facial Recognition System)
- speech_recognition_response.py (Voice Interface)
- communication.py (Messaging System)
- location_weather.py (Location Services)
- data_management.py (Data Handler)
- utility.py (Utility Functions)

##### Technical Stack Representation

A section showing:
- Python as the base platform
- Key libraries: face_recognition, dlib, opencv-python, pyttsx3, pygame
- External services: WhatsApp integration, Weather services

##### Additional Elements

Include:
- System boundaries
- External service interfaces
- Error handling paths
- Backup/fallback mechanisms

- Real-time nature of the system
- Multiple input/output channels
- Data flow between components
- Safety-critical paths (drowsiness detection)

Remember to:
- Keep the critical path (drowsiness detection) visually prominent
- Clear separation between real-time and non-real-time components
- Error handling and fallback mechanisms

This architecture should be drawn to emphasize the safety-critical nature of the system while showing how auxiliary features (music, communication) integrate without compromising the core functionality.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Style Definitions
    classDef input fill:#90EE90,stroke:#333,stroke-width:2px
    classDef core fill:#87CEEB,stroke:#333,stroke-width:2px
    classDef output fill:#FFD700,stroke:#333,stroke-width:2px
    classDef storage fill:#D3D3D3,stroke:#333,stroke-width:2px
    classDef external fill:#FFA07A,stroke:#333,stroke-width:2px

    %% Input Layer
    subgraph Input
        CAM[Camera Input]:::input
        MIC[Microphone Input]:::input
        LOC[Location Sensors]:::input
    end

    %% Core Processing Layer
    subgraph Core
        MAIN[Central Controller]:::core
        FACE[Face Recognition Module]:::core
        SPEECH[Speech Recognition Module]:::core
        COMM[Communication Handler]:::core
        LOCW[Location & Weather Services]:::core
        MUSIC[Music Control System]:::core
        DATA[Data Management System]:::core
        UTIL[Utility Functions]:::core
        CARM[Car Maintenance System]:::core
    end

    %% Storage Layer
    subgraph Storage
        PATT[Communication Patterns]:::storage
        CARDB[Car Maintenance DB]:::storage
        JOKES[Entertainment DB]:::storage
        MUSICDB[Music System DB]:::storage
        LOCDB[Location Data]:::storage
        SONGS[Music Files]:::storage
        FMODEL[Face Recognition Model]:::storage
    end

    %% Output Layer
    subgraph Output
        ALERT[Alert System]:::output
        PLAY[Music Playback]:::output
        NAV[Navigation Instructions]:::output
        WHATS[WhatsApp Communication]:::output
    end

    %% External Services
    subgraph External
        WEATHER[Weather Services]:::external
        WHATSAPI[WhatsApp API]:::external
    end

    %% Connections
    CAM --> FACE
    MIC --> SPEECH
    LOC --> LOCW

    FACE --> ALERT
    SPEECH --> MAIN
    LOCW --> NAV
    COMM --> WHATS
    MUSIC --> PLAY
    
    MAIN --> |Controls| FACE
    MAIN --> |Controls| SPEECH
    MAIN --> |Controls| COMM
    MAIN --> |Controls| MUSIC
    MAIN --> |Controls| LOCW
    MAIN --> |Controls| DATA
    MAIN --> |Controls| CARM

    DATA --> PATT
    DATA --> CARDB
    DATA --> JOKES
    DATA --> MUSICDB
    DATA --> LOCDB
    
    MUSIC --> SONGS
    FACE --> FMODEL
    
    LOCW --> WEATHER
    COMM --> WHATSAPI

    %% Click Events
    click MAIN "https://github.com/Nagraj-13/Dhvani/blob/master/main.py"
    click FACE "https://github.com/Nagraj-13/Dhvani/blob/master/face_rec.py"
    click SPEECH "https://github.com/Nagraj-13/Dhvani/blob/master/speech_recognition_response.py"
    click COMM "https://github.com/Nagraj-13/Dhvani/blob/master/communication.py"
    click LOCW "https://github.com/Nagraj-13/Dhvani/blob/master/location_weather.py"
    click DATA "https://github.com/Nagraj-13/Dhvani/blob/master/data_management.py"
    click CARM "https://github.com/Nagraj-13/Dhvani/blob/master/car_maintainance.py"
    click UTIL "https://github.com/Nagraj-13/Dhvani/blob/master/utility.py"
    click PATT "https://github.com/Nagraj-13/Dhvani/blob/master/patterns.json"
    click CARDB "https://github.com/Nagraj-13/Dhvani/blob/master/car_maintenance_dataset.json"
    click JOKES "https://github.com/Nagraj-13/Dhvani/blob/master/jokes_dataset.json"
    click MUSICDB "https://github.com/Nagraj-13/Dhvani/blob/master/music_data.json"
    click LOCDB "https://github.com/Nagraj-13/Dhvani/blob/master/location.json"
    click SONGS "https://github.com/Nagraj-13/Dhvani/blob/master/song1.mp3"
    click FMODEL "https://github.com/Nagraj-13/Dhvani/blob/master/shape_predictor_68_face_landmarks.dat"

    %% Legend
    subgraph Legend
        L1[Input Components]:::input
        L2[Core Processing]:::core
        L3[Output Components]:::output
        L4[Storage Components]:::storage
        L5[External Services]:::external
    end
```
