# rishitsamala/voicesearch architecture

> Architecture diagram of the GitHub repository rishitsamala/voicesearch, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-02-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rishitsamala/voicesearch
- Repository: https://github.com/rishitsamala/voicesearch

## Overview

##### Project type & purpose (from file tree + README)
This is a **server-rendered Java web application** built with **Spring Boot + Spring MVC + Spring Security**, using **JSP views** and browser-side **Web Speech API** to:
- **voice input** (speech-to-text) in the browser,
- submit the resulting text as a **search request** to the server,
- return **search results** that are read back via **voice-over** (text-to-speech) in the browser.

It’s deployed (per README) on **AWS Elastic Beanstalk**.

##### Architecture implied by the file structure
Key layers/components visible in the repo:

##### Backend (Spring Boot / MVC / Security)
- `ApplicationConfig.java`, `ViewResolverConfig.java`: application + MVC view resolution (JSP).
- `SecurityConfig.java`, `SecurityUserDetailsService.java`: Spring Security authn/authz and user details integration.
- `web/SearchController.java`: MVC controller endpoints for the search pages/flows.
- `model/SearchForm.java`: MVC form-backing object / request model for search input.
- `domain/User.java`: persistent domain entity (likely JPA).
- `repo/UserRepo.java`: persistence adapter (Spring Data repository).
- `service/UserService.java`: business/service layer for user operations (and potentially used by security).

##### Frontend (JSP + JS)
- Views: `src/main/webapp/WEB-INF/views/*.jsp`
`login.jsp`, `dashboard.jsp`, `personSearch.jsp`, `vehicleSearch.jsp`
- JS (voice features):
`voiceSearch.js`, `voicePersonSearch.js`, `voiceVehicleSearch.js` (+ `all.js`)
- CSS: `bootstrap.min_2017.css`

##### Configuration / Build / Runtime
- `pom.xml`: Maven build, dependencies (Spring Boot, Spring Security, Spring MVC, JSP support, likely JPA).
- `application.properties`: environment configuration (server, DB, security, etc).

##### Web UI (JSP pages)
- `login.jsp`, `dashboard.jsp`, `personSearch.jsp`, `vehicleSearch.jsp`
##### Client Voice Layer (JavaScript)
- Web Speech API (SpeechRecognition + SpeechSynthesis) invoked by:
- `voiceSearch.js`
- `voicePersonSearch.js`
- `voiceVehicleSearch.js`
##### Spring Boot Application (Elastic Beanstalk instance)
- **Spring MVC**
- `SearchController`
- `SearchForm`
- `ViewResolverConfig`
- **Spring Security**
- `SecurityConfig`
- `SecurityUserDetailsService`
- **Service Layer**
- `UserService`
- **Repository Layer**
- `UserRepo`
- **Domain**
- `User`
##### AWS Elastic Beanstalk (hosting/runtime)
- ALB / EC2 / Auto Scaling as a single “Elastic Beanstalk Environment” boundary.

##### Architectural patterns to highlight (explicitly label them)
- **Layered architecture**: Controller → Service → Repository → DB
- **Server-side rendered MVC**: JSP via view resolver
- **Security as cross-cutting concern**: filter chain before MVC
- **Client-enhanced UI**: voice input/output is browser-side via Web Speech API; server does not do speech processing

##### Don’t overthink: split into more components rather than fewer
For this repo, accuracy comes from explicitly separating:
- **Voice capture/voice playback (browser)** from **search handling (server)**
- **Security filter chain** from **controller**
- **JSP rendering** from **controller logic**
- **User persistence** path (UserDetailsService → UserService → UserRepo → DB)

## Diagram (Mermaid)

```mermaid
flowchart TD

%% =========================
%% Diagram 1: Context / Containers
%% =========================
subgraph "Client (User Device)"
direction TB
    User["User"]:::external

    subgraph "Browser"
    direction TB
        WebUI["Web UI (JSP-rendered pages)"]:::frontend

        subgraph "JSP Views (DOM)"
        direction TB
            JSPViews["JSP Views (directory)"]:::frontend
            LoginJSP["login.jsp"]:::frontend
            DashboardJSP["dashboard.jsp"]:::frontend
            PersonJSP["personSearch.jsp"]:::frontend
            VehicleJSP["vehicleSearch.jsp"]:::frontend
        end

        subgraph "Client Voice Layer (JavaScript)"
        direction TB
            JSDir["JS (directory)"]:::frontend
            AllJS["all.js"]:::frontend
            VoiceSearchJS["voiceSearch.js"]:::frontend
            VoicePersonJS["voicePersonSearch.js"]:::frontend
            VoiceVehicleJS["voiceVehicleSearch.js"]:::frontend

            subgraph "Web Speech API (browser-only)"
            direction TB
                SpeechRec["SpeechRecognition (STT)"]:::frontend
                SpeechSyn["SpeechSynthesis (TTS)"]:::frontend
            end
        end

        CSS["bootstrap.min_2017.css"]:::frontend
    end
end

subgraph "AWS Elastic Beanstalk Environment"
direction TB
    subgraph "Spring Boot Application (server-rendered MVC)"
    direction TB

        subgraph "Configuration"
        direction TB
            Pom["Maven Build (pom.xml)"]:::config
            AppProps["application.properties"]:::config
            AppConfig["ApplicationConfig.java"]:::backend
            ViewConfig["ViewResolverConfig.java"]:::backend
        end

        subgraph "Spring Security (cross-cutting)"
        direction TB
            SecConfig["SecurityConfig.java (Filter Chain/Authz)"]:::security
            UDS["SecurityUserDetailsService.java (UserDetailsService)"]:::security
        end

        subgraph "Spring MVC"
        direction TB
            Controller["SearchController.java (Spring MVC)"]:::backend
            SearchForm["SearchForm.java (Form Model)"]:::backend
            JSPRender["JSP Rendering (ViewResolver)"]:::backend
        end

        subgraph "User Management (Layered)"
        direction TB
            UserService["UserService.java (Service Layer)"]:::backend
            UserRepo["UserRepo.java (Repository)"]:::backend
            UserEntity["User.java (Domain Entity)"]:::backend
        end
    end
end

DB[("RDBMS (configured via application.properties)")]:::database

%% =========================
%% Context Relationships (vertical)
%% =========================
User -->|"uses"| WebUI

%% Authentication flow
WebUI -->|"HTTPS GET /login"| SecConfig
SecConfig -->|"serves_view"| JSPRender
JSPRender -->|"renders"| LoginJSP
LoginJSP -->|"HTML/CSS/JS"| WebUI

WebUI -->|"POST /login (credentials)"| SecConfig
SecConfig -->|"authenticate"| UDS
UDS -->|"load_user"| UserService
UserService -->|"read/write"| UserRepo
UserRepo -->|"JPA_query"| DB
SecConfig -->|"on_success redirect"| DashboardJSP
SecConfig -->|"on_failure return"| LoginJSP

%% Protected pages
WebUI -->|"HTTPS GET /dashboard"| SecConfig
SecConfig -->|"authz_ok -> MVC"| Controller
Controller -->|"return_view"| JSPRender
JSPRender -->|"renders"| DashboardJSP

%% Voice search flow (client-side voice)
PersonJSP -->|"includes"| VoicePersonJS
VehicleJSP -->|"includes"| VoiceVehicleJS
DashboardJSP -->|"includes"| AllJS
PersonJSP -->|"styles"| CSS
VehicleJSP -->|"styles"| CSS
LoginJSP -->|"styles"| CSS

VoicePersonJS -->|"calls"| SpeechRec
VoiceVehicleJS -->|"calls"| SpeechRec
VoiceSearchJS -->|"calls"| SpeechRec

SpeechRec -->|"recognized_text"| VoicePersonJS
SpeechRec -->|"recognized_text"| VoiceVehicleJS

%% Search requests
WebUI -->|"HTTPS GET/POST /personSearch (query_text)"| SecConfig
SecConfig -->|"authz_ok"| Controller
Controller -->|"binds"| SearchForm
Controller -->|"return_view results"| JSPRender
JSPRender -->|"renders"| PersonJSP
PersonJSP -->|"results_text"| VoicePersonJS
VoicePersonJS -->|"speaks"| SpeechSyn

WebUI -->|"HTTPS GET/POST /vehicleSearch (query_text)"| SecConfig
SecConfig -->|"authz_ok"| Controller
Controller -->|"binds"| SearchForm
Controller -->|"return_view results"| JSPRender
JSPRender -->|"renders"| VehicleJSP
VehicleJSP -->|"results_text"| VoiceVehicleJS
VoiceVehicleJS -->|"speaks"| SpeechSyn

%% Config influences (dashed)
Pom -.->|"builds"| AppConfig
AppProps -.->|"configures"| AppConfig
ViewConfig -.->|"configures"| JSPRender
AppConfig -.->|"enables"| Controller
AppConfig -.->|"enables"| SecConfig
AppProps -.->|"db_settings"| DB

%% =========================
%% Click Events (from component_mapping)
%% =========================
click AppConfig "https://github.com/rishitsamala/voicesearch/blob/main/src/main/java/app/voicesearch/ApplicationConfig.java"
click ViewConfig "https://github.com/rishitsamala/voicesearch/blob/main/src/main/java/app/voicesearch/ViewResolverConfig.java"
click SecConfig "https://github.com/rishitsamala/voicesearch/blob/main/src/main/java/app/voicesearch/SecurityConfig.java"
click UDS "https://github.com/rishitsamala/voicesearch/blob/main/src/main/java/app/voicesearch/SecurityUserDetailsService.java"
click Controller "https://github.com/rishitsamala/voicesearch/blob/main/src/main/java/app/voicesearch/web/SearchController.java"
click SearchForm "https://github.com/rishitsamala/voicesearch/blob/main/src/main/java/app/voicesearch/model/SearchForm.java"
click UserEntity "https://github.com/rishitsamala/voicesearch/blob/main/src/main/java/app/voicesearch/domain/User.java"
click UserRepo "https://github.com/rishitsamala/voicesearch/blob/main/src/main/java/app/voicesearch/repo/UserRepo.java"
click UserService "https://github.com/rishitsamala/voicesearch/blob/main/src/main/java/app/voicesearch/service/UserService.java"
click JSPViews "https://github.com/rishitsamala/voicesearch/tree/main/src/main/webapp/WEB-INF/views/"
click LoginJSP "https://github.com/rishitsamala/voicesearch/blob/main/src/main/webapp/WEB-INF/views/login.jsp"
click DashboardJSP "https://github.com/rishitsamala/voicesearch/blob/main/src/main/webapp/WEB-INF/views/dashboard.jsp"
click PersonJSP "https://github.com/rishitsamala/voicesearch/blob/main/src/main/webapp/WEB-INF/views/personSearch.jsp"
click VehicleJSP "https://github.com/rishitsamala/voicesearch/blob/main/src/main/webapp/WEB-INF/views/vehicleSearch.jsp"
click JSDir "https://github.com/rishitsamala/voicesearch/tree/main/src/main/webapp/js/"
click VoiceSearchJS "https://github.com/rishitsamala/voicesearch/blob/main/src/main/webapp/js/voiceSearch.js"
click VoicePersonJS "https://github.com/rishitsamala/voicesearch/blob/main/src/main/webapp/js/voicePersonSearch.js"
click VoiceVehicleJS "https://github.com/rishitsamala/voicesearch/blob/main/src/main/webapp/js/voiceVehicleSearch.js"
click AllJS "https://github.com/rishitsamala/voicesearch/blob/main/src/main/webapp/js/all.js"
click CSS "https://github.com/rishitsamala/voicesearch/blob/main/src/main/webapp/css/bootstrap.min_2017.css"
click AppProps "https://github.com/rishitsamala/voicesearch/blob/main/src/main/resources/application.properties"
click Pom "https://github.com/rishitsamala/voicesearch/blob/main/pom.xml"

%% =========================
%% Styles
%% =========================
classDef external fill:#f2f2f2,stroke:#666,stroke-width:1px,color:#111
classDef frontend fill:#d9ecff,stroke:#2b6cb0,stroke-width:1.5px,color:#0b1f33
classDef backend fill:#d9f7e8,stroke:#1f7a4a,stroke-width:1.5px,color:#0b2b1a
classDef security fill:#ffe6cc,stroke:#c05621,stroke-width:1.5px,color:#3b1a00
classDef database fill:#ffe0e0,stroke:#b83232,stroke-width:1.5px,color:#2a0b0b
classDef config fill:#efe6ff,stroke:#6b46c1,stroke-width:1.5px,color:#1f103a
```
