# whatdadogdoing/voiceproject architecture

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

- Interactive diagram: https://gitdiagram.com/whatdadogdoing/voiceproject
- Repository: https://github.com/whatdadogdoing/voiceproject

## Overview

VoiceProject is a voice-based authentication product with enrollment, challenge-based voice verification, anti-spoofing and email OTP, plus a companion Fake Voice Lab for testing defenses. The main path is password login, consent and voiceprint enrollment, then a fresh phrase (and optionally a code), server-side audio checks, risk evaluation, and OTP. The graph preserves recovery, fraud lockout, and re-enrollment capabilities documented in the README. Some links are documented at the product-flow level because the corresponding source was not excerpted.

Main entry points: [`backend/routers/voice_auth.py`](https://github.com/whatdadogdoing/voiceproject/blob/main/backend/routers/voice_auth.py) (Voice verification), [`backend/main.py`](https://github.com/whatdadogdoing/voiceproject/blob/main/backend/main.py) (FastAPI app), [`backend/models/db.py`](https://github.com/whatdadogdoing/voiceproject/blob/main/backend/models/db.py) (PostgreSQL data), [`backend/routers/enroll.py`](https://github.com/whatdadogdoing/voiceproject/blob/main/backend/routers/enroll.py) (Voice enrollment)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client and testing"]
  node_frontend["Web client<br/>[app.js]"]
  node_recorder["Voice recorder<br/>[voice-recorder.js]"]
  node_fake_lab["Fake Voice Lab<br/>[main.py]"]
end

subgraph group_api["API workflows"]
  node_api_app["FastAPI app<br/>[main.py]"]
  node_auth_routes["Login and logout<br/>[auth.py]"]
  node_enrollment["Voice enrollment<br/>[enroll.py]"]
  node_voice_routes["Voice verification<br/>[voice_auth.py]"]
  node_risk["Risk and fraud lockout<br/>[risk_engine.py]"]
  node_consent["Voice consent<br/>[consent.py]"]
  node_otp["Email OTP<br/>[otp.py]"]
  node_auth_service["Session and token auth<br/>[auth.py]"]
  node_tokens["Token handling<br/>[token.py]"]
end

subgraph group_voice["Voice analysis"]
  node_phrase_pool["Challenge phrases<br/>[phrases.py]"]
  node_phrase_check["Phrase and code check<br/>[phrase_check.py]"]
  node_audio["Audio processing<br/>[audio.py]"]
  node_speaker["Speaker matching"]
  node_antispoof["Anti-spoof detection<br/>[anti_spoofing.py]"]
  node_aasist["AASIST-L model<br/>[aasist_model.py]"]
end

subgraph group_state["Identity and state"]
  node_database[("PostgreSQL data<br/>[db.py]")]
  node_redis[("Redis state<br/>[redis_client.py]")]
end

node_user(("User"))

node_user -->|"uses"| node_frontend
node_frontend -->|"calls API"| node_api_app
node_frontend -->|"records audio"| node_recorder
node_api_app -->|"registers"| node_auth_routes
node_api_app -->|"registers"| node_voice_routes
node_api_app -->|"registers"| node_enrollment
node_api_app -->|"loads model"| node_antispoof
node_api_app -->|"loads encoder"| node_speaker
node_api_app -->|"opens pool"| node_database
node_auth_routes -->|"delegates"| node_auth_service
node_auth_service -->|"stores sessions"| node_redis
node_auth_service -->|"decodes tokens"| node_tokens
node_auth_service -->|"checks voiceprint"| node_database
node_enrollment -->|"gets phrases"| node_phrase_pool
node_enrollment -->|"checks speech"| node_phrase_check
node_enrollment -->|"embeds samples"| node_speaker
node_enrollment -->|"saves voiceprint"| node_database
node_voice_routes -->|"checks consent"| node_consent
node_voice_routes -->|"issues challenge"| node_phrase_pool
node_voice_routes -->|"checks challenge"| node_phrase_check
node_voice_routes -->|"converts audio"| node_audio
node_voice_routes -->|"scores speaker"| node_speaker
node_voice_routes -->|"scores spoofing"| node_antispoof
node_voice_routes -->|"evaluates scores"| node_risk
node_voice_routes -->|"sends and verifies"| node_otp
node_voice_routes -->|"reads and logs"| node_database
node_voice_routes -->|"uses challenge state"| node_redis
node_phrase_check -->|"uses phrase rules"| node_phrase_pool
node_phrase_check -->|"transcribes audio"| node_audio
node_speaker -->|"reads waveform"| node_audio
node_antispoof -->|"reads waveform"| node_audio
node_antispoof -.->|"uses model"| node_aasist
node_risk -->|"counts failures"| node_database
node_risk -->|"checks lockout"| node_redis
node_consent -->|"records consent"| node_database
node_otp -->|"stores OTP state"| node_redis
node_fake_lab -->|"attacks verify"| node_api_app

click node_frontend "https://github.com/whatdadogdoing/voiceproject/blob/main/frontend/app.js"
click node_recorder "https://github.com/whatdadogdoing/voiceproject/blob/main/frontend/voice-recorder.js"
click node_fake_lab "https://github.com/whatdadogdoing/voiceproject/blob/main/fake-voice-lab/main.py"
click node_api_app "https://github.com/whatdadogdoing/voiceproject/blob/main/backend/main.py"
click node_auth_routes "https://github.com/whatdadogdoing/voiceproject/blob/main/backend/routers/auth.py"
click node_enrollment "https://github.com/whatdadogdoing/voiceproject/blob/main/backend/routers/enroll.py"
click node_voice_routes "https://github.com/whatdadogdoing/voiceproject/blob/main/backend/routers/voice_auth.py"
click node_phrase_pool "https://github.com/whatdadogdoing/voiceproject/blob/main/backend/services/phrases.py"
click node_phrase_check "https://github.com/whatdadogdoing/voiceproject/blob/main/backend/services/phrase_check.py"
click node_audio "https://github.com/whatdadogdoing/voiceproject/blob/main/backend/services/audio.py"
click node_speaker "https://github.com/whatdadogdoing/voiceproject/blob/main/backend/services/speaker_verification.py"
click node_antispoof "https://github.com/whatdadogdoing/voiceproject/blob/main/backend/services/anti_spoofing.py"
click node_aasist "https://github.com/whatdadogdoing/voiceproject/blob/main/backend/services/aasist_model.py"
click node_risk "https://github.com/whatdadogdoing/voiceproject/blob/main/backend/services/risk_engine.py"
click node_consent "https://github.com/whatdadogdoing/voiceproject/blob/main/backend/services/consent.py"
click node_otp "https://github.com/whatdadogdoing/voiceproject/blob/main/backend/services/otp.py"
click node_auth_service "https://github.com/whatdadogdoing/voiceproject/blob/main/backend/services/auth.py"
click node_tokens "https://github.com/whatdadogdoing/voiceproject/blob/main/backend/services/token.py"
click node_database "https://github.com/whatdadogdoing/voiceproject/blob/main/backend/models/db.py"
click node_redis "https://github.com/whatdadogdoing/voiceproject/blob/main/backend/services/redis_client.py"

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_frontend,node_recorder,node_fake_lab,node_user toneBlue
class node_api_app,node_auth_routes,node_enrollment,node_voice_routes,node_risk,node_consent,node_otp,node_auth_service,node_tokens toneAmber
class node_phrase_pool,node_phrase_check,node_audio,node_speaker,node_antispoof,node_aasist toneMint
class node_database,node_redis toneRose
```

## Components

### Client and testing

- [Web client](https://github.com/whatdadogdoing/voiceproject/blob/main/frontend/app.js): `frontend/app.js`
- [Voice recorder](https://github.com/whatdadogdoing/voiceproject/blob/main/frontend/voice-recorder.js): `frontend/voice-recorder.js`
- [Fake Voice Lab](https://github.com/whatdadogdoing/voiceproject/blob/main/fake-voice-lab/main.py): `fake-voice-lab/main.py`

### API workflows

- [FastAPI app](https://github.com/whatdadogdoing/voiceproject/blob/main/backend/main.py): `backend/main.py`
- [Login and logout](https://github.com/whatdadogdoing/voiceproject/blob/main/backend/routers/auth.py): `backend/routers/auth.py`
- [Voice enrollment](https://github.com/whatdadogdoing/voiceproject/blob/main/backend/routers/enroll.py): `backend/routers/enroll.py`
- [Voice verification](https://github.com/whatdadogdoing/voiceproject/blob/main/backend/routers/voice_auth.py): `backend/routers/voice_auth.py`
- [Risk and fraud lockout](https://github.com/whatdadogdoing/voiceproject/blob/main/backend/services/risk_engine.py): `backend/services/risk_engine.py`
- [Voice consent](https://github.com/whatdadogdoing/voiceproject/blob/main/backend/services/consent.py): `backend/services/consent.py`
- [Email OTP](https://github.com/whatdadogdoing/voiceproject/blob/main/backend/services/otp.py): `backend/services/otp.py`
- [Session and token auth](https://github.com/whatdadogdoing/voiceproject/blob/main/backend/services/auth.py): `backend/services/auth.py`
- [Token handling](https://github.com/whatdadogdoing/voiceproject/blob/main/backend/services/token.py): `backend/services/token.py`

### Voice analysis

- [Challenge phrases](https://github.com/whatdadogdoing/voiceproject/blob/main/backend/services/phrases.py): `backend/services/phrases.py`
- [Phrase and code check](https://github.com/whatdadogdoing/voiceproject/blob/main/backend/services/phrase_check.py): `backend/services/phrase_check.py`
- [Audio processing](https://github.com/whatdadogdoing/voiceproject/blob/main/backend/services/audio.py): `backend/services/audio.py`
- [Speaker matching](https://github.com/whatdadogdoing/voiceproject/blob/main/backend/services/speaker_verification.py): `backend/services/speaker_verification.py`
- [Anti-spoof detection](https://github.com/whatdadogdoing/voiceproject/blob/main/backend/services/anti_spoofing.py): `backend/services/anti_spoofing.py`
- [AASIST-L model](https://github.com/whatdadogdoing/voiceproject/blob/main/backend/services/aasist_model.py): `backend/services/aasist_model.py`

### Identity and state

- [PostgreSQL data](https://github.com/whatdadogdoing/voiceproject/blob/main/backend/models/db.py): `backend/models/db.py`
- [Redis state](https://github.com/whatdadogdoing/voiceproject/blob/main/backend/services/redis_client.py): `backend/services/redis_client.py`

### Other components

- **User**

## Connections

- User → Web client: uses (evidence: `README.md`)
- Web client → FastAPI app: calls API (evidence: `README.md`)
- Web client → Voice recorder: records audio (evidence: `README.md`)
- FastAPI app → Login and logout: registers (evidence: `backend/main.py`)
- FastAPI app → Voice verification: registers (evidence: `backend/main.py`)
- FastAPI app → Voice enrollment: registers (evidence: `backend/main.py`)
- FastAPI app → Anti-spoof detection: loads model (evidence: `backend/main.py`)
- FastAPI app → Speaker matching: loads encoder (evidence: `backend/main.py`)
- FastAPI app → PostgreSQL data: opens pool (evidence: `backend/main.py`)
- Login and logout → Session and token auth: delegates (evidence: `backend/routers/auth.py`)
- Session and token auth → Redis state: stores sessions (evidence: `backend/services/auth.py`)
- Session and token auth → Token handling: decodes tokens (evidence: `backend/services/auth.py`)
- Session and token auth → PostgreSQL data: checks voiceprint (evidence: `backend/services/auth.py`)
- Voice enrollment → Challenge phrases: gets phrases (evidence: `backend/routers/enroll.py`)
- Voice enrollment → Phrase and code check: checks speech (evidence: `backend/routers/enroll.py`)
- Voice enrollment → Speaker matching: embeds samples (evidence: `backend/routers/enroll.py`)
- Voice enrollment → PostgreSQL data: saves voiceprint (evidence: `backend/routers/enroll.py`)
- Voice verification → Voice consent: checks consent (evidence: `backend/routers/voice_auth.py`)
- Voice verification → Challenge phrases: issues challenge (evidence: `backend/routers/voice_auth.py`)
- Voice verification → Phrase and code check: checks challenge (evidence: `backend/routers/voice_auth.py`)
- Voice verification → Audio processing: converts audio (evidence: `backend/routers/voice_auth.py`)
- Voice verification → Speaker matching: scores speaker (evidence: `backend/routers/voice_auth.py`)
- Voice verification → Anti-spoof detection: scores spoofing (evidence: `backend/routers/voice_auth.py`)
- Voice verification → Risk and fraud lockout: evaluates scores (evidence: `backend/routers/voice_auth.py`)
- Voice verification → Email OTP: sends and verifies (evidence: `backend/routers/voice_auth.py`)
- Voice verification → PostgreSQL data: reads and logs (evidence: `backend/routers/voice_auth.py`)
- Voice verification → Redis state: uses challenge state (evidence: `backend/routers/voice_auth.py`)
- Phrase and code check → Challenge phrases: uses phrase rules (evidence: `backend/services/phrase_check.py`)
- Phrase and code check → Audio processing: transcribes audio
- Speaker matching → Audio processing: reads waveform (evidence: `backend/services/speaker_verification.py`)
- Anti-spoof detection → Audio processing: reads waveform (evidence: `backend/services/anti_spoofing.py`)
- Anti-spoof detection → AASIST-L model: uses model
- Risk and fraud lockout → PostgreSQL data: counts failures (evidence: `backend/services/risk_engine.py`)
- Risk and fraud lockout → Redis state: checks lockout (evidence: `backend/services/risk_engine.py`)
- Voice consent → PostgreSQL data: records consent (evidence: `backend/services/consent.py`)
- Email OTP → Redis state: stores OTP state (evidence: `backend/services/otp.py`)
- Fake Voice Lab → FastAPI app: attacks verify (evidence: `README.md`)
