# ayushgupta208019/voice-command-shopping-assistant architecture

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

- Interactive diagram: https://gitdiagram.com/ayushgupta208019/voice-command-shopping-assistant
- Repository: https://github.com/ayushgupta208019/voice-command-shopping-assistant

## Overview

##### Project Type and Purpose
- This is a lightweight full-stack web application (Voice Command Shopping Assistant) built with Python (Flask) on the backend and a single HTML frontend.
- It lets users speak shopping commands (e.g., “add two apples to my cart”) in the browser, processes those commands server-side, and updates a simple cart/products data store (JSON files).

##### High-Level Architecture
- Presentation Layer (Browser/Frontend)
- index.html (templates/index.html)
- JavaScript to capture voice input via the Web Speech API
- Sends RESTful requests (e.g., POST /command) to the Flask backend
- Application Layer (Backend)
- app.py (Flask application)
- Routes: serves index.html, receives voice command payloads
- Business logic: Natural Language Processing (simple parsing or external library) → action mapping (add/remove/list items)
- Reads/writes cart.json & products.json
- Data Layer
- products.json – master list of available products and their metadata
- cart.json – current user’s shopping cart state
- External Services (optional/extension)
- Could integrate third-party speech-to-text API if browser API is insufficient
- Could use a database (e.g., SQLite/PostgreSQL) instead of JSON in production

##### Detailing Essentials
- Don’t omit the voice-to-text step (crucial for “Voice Command”)
- Both read and write operations to cart.json/products.json
- That requirements.txt governs dependencies in Flask
- If planning extensions (e.g., DB migration, external ASR), include placeholder components

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Layer
    User["User"]:::user
    subgraph "Frontend (Client)"
        Browser["Browser"]:::frontend
        FrontendJS["index.html + JS"]:::frontend
        TemplatesDir["templates/"]:::frontend
    end
    User -->|"speaks audio"| Browser
    Browser -->|"capture voice via Web Speech API"| FrontendJS

    %% Backend Layer
    subgraph "Backend (Server)"
        FlaskApp["Flask App (app.py)"]:::backend
        NLP["NLP Parser"]:::backend
        Requirements["requirements.txt"]:::backend
    end
    FrontendJS -->|"POST /command {text}"| FlaskApp
    FlaskApp -->|"invokes parsing"| NLP
    NLP -->|"returns action"| FlaskApp
    FlaskApp -->|"200 OK {cart data}"| FrontendJS

    %% Data Layer
    subgraph "Data Store"
        CartData[(cart.json)]:::datastore
        ProductsData[(products.json)]:::datastore
    end
    FlaskApp -->|"read/write cart"| CartData
    FlaskApp -->|"read products"| ProductsData

    %% External Services
    subgraph "External Services"
        ExternalASR["External ASR Service"]:::external
        Documentation["README.md"]:::doc
    end
    FrontendJS -->|"optional ASR request"| ExternalASR
    ExternalASR -->|"text response"| FrontendJS

    %% Click Events
    click FrontendJS "https://github.com/ayushgupta208019/voice-command-shopping-assistant/blob/main/templates/index.html"
    click TemplatesDir "https://github.com/ayushgupta208019/voice-command-shopping-assistant/tree/main/templates/"
    click FlaskApp "https://github.com/ayushgupta208019/voice-command-shopping-assistant/blob/main/app.py"
    click CartData "https://github.com/ayushgupta208019/voice-command-shopping-assistant/blob/main/cart.json"
    click ProductsData "https://github.com/ayushgupta208019/voice-command-shopping-assistant/blob/main/products.json"
    click Requirements "https://github.com/ayushgupta208019/voice-command-shopping-assistant/blob/main/requirements.txt"
    click Documentation "https://github.com/ayushgupta208019/voice-command-shopping-assistant/blob/main/README.md"

    %% Styles
    classDef user fill:#ccffcc,stroke:#333,stroke-width:1px;
    classDef frontend fill:#ccddff,stroke:#333,stroke-width:1px;
    classDef backend fill:#ffd699,stroke:#333,stroke-width:1px;
    classDef datastore fill:#ff9999,stroke:#333,stroke-width:1px;
    classDef external fill:#dddddd,stroke:#333,stroke-width:1px;
    classDef doc fill:#ffff99,stroke:#333,stroke-width:1px;
```
