# 0shrihari0/shazam-cpp architecture

> Architecture diagram of the GitHub repository 0shrihari0/shazam-cpp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/0shrihari0/shazam-cpp
- Repository: https://github.com/0shrihari0/shazam-cpp

## Overview

Shazam-CPP is a browser-based music recognition product with an admin-managed song catalog. The main workflow records audio in the home page, submits samples for identification, fingerprints them through the engine bridge, and compares them with catalog fingerprints stored in MongoDB to return ranked matches. Separate branches cover catalog upload/listing, admin authentication, and documented operational APIs. Source excerpts show the identification and song API dependencies; some UI-to-API links and unsampled operational behavior are based on README descriptions.

Main entry points: [`shazam-app/src/pages/index.tsx`](https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/pages/index.tsx) (Record and results), [`shazam-app/src/pages/api/songs.ts`](https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/pages/api/songs.ts) (Song API), [`shazam-app/src/pages/api/auth/[...nextauth].ts`](https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/pages/api/auth/%5B...nextauth%5D.ts) (Authentication API), [`shazam-app/src/pages/api/identify.ts`](https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/pages/api/identify.ts) (Identify API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_home["Record and results<br/>[index.tsx]"]
  node_listen["Listen controls<br/>[ListenButton.tsx]"]
  node_visualizer["Audio visualization"]
  node_matchcards["Match cards<br/>[MatchCard.tsx]"]
  node_navigation["Navigation<br/>[Navigation.tsx]"]
  node_layout["Page layout<br/>[Layout.tsx]"]
end

subgraph group_recognition["Recognition engine"]
  node_identify["Identify API<br/>[identify.ts]"]
  node_bridge["Engine bridge<br/>[cpp-engine.ts]"]
  node_cpp["C++ fingerprint engine<br/>[main.cpp]"]
  node_fingerprint["TypeScript fingerprinting<br/>[fingerprint.ts]"]
end

subgraph group_catalog["Catalog management"]
  node_songapi["Song API<br/>[songs.ts]"]
  node_upload["Song upload<br/>[upload.tsx]"]
  node_library["Song library<br/>[songs.tsx]"]
  node_songmodel[("Song records<br/>[Song.ts]")]
  node_database[("MongoDB connection<br/>[mongodb.ts]")]
  node_deleteall["Delete all songs<br/>[delete-all.ts]"]
end

subgraph group_identity["Identity and operations"]
  node_login["Admin login<br/>[login.tsx]"]
  node_auth["Authentication API<br/>[&#91;...nextauth&#93;.ts]"]
  node_usermodel[("User records<br/>[User.ts]")]
  node_health["Health check<br/>[health.ts]"]
  node_seed["Catalog seeding<br/>[seed.ts]"]
  node_cleanup["Catalog cleanup<br/>[cleanup.ts]"]
end

node_listener(("Listener"))
node_admin(("Administrator"))
node_mongo[("MongoDB service")]

node_listener -->|"records with"| node_home
node_home -->|"renders"| node_listen
node_home -->|"renders"| node_visualizer
node_home -->|"renders"| node_matchcards
node_home -->|"submits audio"| node_identify
node_identify -->|"generates and matches"| node_bridge
node_bridge -->|"dispatches commands"| node_cpp
node_bridge -->|"falls back to"| node_fingerprint
node_identify -->|"loads catalog"| node_songmodel
node_identify -->|"returns matches"| node_home
node_admin -->|"manages catalog"| node_upload
node_upload -->|"posts song data"| node_songapi
node_songapi -->|"fingerprints audio"| node_bridge
node_songapi -->|"reads and writes"| node_songmodel
node_library -->|"lists songs"| node_songapi
node_songmodel -.->|"uses connection"| node_database
node_database -.->|"connects to"| node_mongo
node_admin -->|"signs in"| node_login
node_login -.->|"authenticates through"| node_auth
node_auth -->|"verifies credentials"| node_usermodel
node_auth -->|"connects"| node_database
node_songapi -->|"checks session"| node_auth
node_deleteall -->|"checks session"| node_auth
node_deleteall -->|"deletes records"| node_songmodel
node_health -.->|"checks service"| node_mongo
node_seed -.->|"seeds catalog"| node_mongo
node_cleanup -.->|"cleans data"| node_mongo
node_layout -->|"renders"| node_navigation

click node_home "https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/pages/index.tsx"
click node_listen "https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/components/ListenButton.tsx"
click node_visualizer "https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/components/AudioVisualizer.tsx"
click node_matchcards "https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/components/MatchCard.tsx"
click node_navigation "https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/components/Navigation.tsx"
click node_layout "https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/components/Layout.tsx"
click node_identify "https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/pages/api/identify.ts"
click node_bridge "https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/lib/cpp-engine.ts"
click node_cpp "https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/engine/src/main.cpp"
click node_fingerprint "https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/lib/fingerprint.ts"
click node_songapi "https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/pages/api/songs.ts"
click node_upload "https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/pages/admin/upload.tsx"
click node_library "https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/pages/songs.tsx"
click node_songmodel "https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/models/Song.ts"
click node_database "https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/lib/mongodb.ts"
click node_login "https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/pages/admin/login.tsx"
click node_auth "https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/pages/api/auth/%5B...nextauth%5D.ts"
click node_usermodel "https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/models/User.ts"
click node_health "https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/pages/api/health.ts"
click node_seed "https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/pages/api/seed.ts"
click node_cleanup "https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/pages/api/cleanup.ts"
click node_deleteall "https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/pages/api/songs/delete-all.ts"

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_home,node_listen,node_visualizer,node_matchcards,node_navigation,node_layout toneBlue
class node_identify,node_bridge,node_cpp,node_fingerprint,node_mongo toneAmber
class node_songapi,node_upload,node_library,node_songmodel,node_database,node_deleteall toneMint
class node_login,node_auth,node_usermodel,node_health,node_seed,node_cleanup toneRose
class node_listener,node_admin toneIndigo
```

## Components

### User experience

- [Record and results](https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/pages/index.tsx): `shazam-app/src/pages/index.tsx`
- [Listen controls](https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/components/ListenButton.tsx): `shazam-app/src/components/ListenButton.tsx`
- [Audio visualization](https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/components/AudioVisualizer.tsx): `shazam-app/src/components/AudioVisualizer.tsx`
- [Match cards](https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/components/MatchCard.tsx): `shazam-app/src/components/MatchCard.tsx`
- [Navigation](https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/components/Navigation.tsx): `shazam-app/src/components/Navigation.tsx`
- [Page layout](https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/components/Layout.tsx): `shazam-app/src/components/Layout.tsx`

### Recognition engine

- [Identify API](https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/pages/api/identify.ts): `shazam-app/src/pages/api/identify.ts`
- [Engine bridge](https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/lib/cpp-engine.ts): `shazam-app/src/lib/cpp-engine.ts`
- [C++ fingerprint engine](https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/engine/src/main.cpp): `engine/src/main.cpp`
- [TypeScript fingerprinting](https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/lib/fingerprint.ts): `shazam-app/src/lib/fingerprint.ts`

### Catalog management

- [Song API](https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/pages/api/songs.ts): `shazam-app/src/pages/api/songs.ts`
- [Song upload](https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/pages/admin/upload.tsx): `shazam-app/src/pages/admin/upload.tsx`
- [Song library](https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/pages/songs.tsx): `shazam-app/src/pages/songs.tsx`
- [Song records](https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/models/Song.ts): `shazam-app/src/models/Song.ts`
- [MongoDB connection](https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/lib/mongodb.ts): `shazam-app/src/lib/mongodb.ts`
- [Delete all songs](https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/pages/api/songs/delete-all.ts): `shazam-app/src/pages/api/songs/delete-all.ts`

### Identity and operations

- [Admin login](https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/pages/admin/login.tsx): `shazam-app/src/pages/admin/login.tsx`
- [Authentication API](https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/pages/api/auth/%5B...nextauth%5D.ts): `shazam-app/src/pages/api/auth/[...nextauth].ts`
- [User records](https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/models/User.ts): `shazam-app/src/models/User.ts`
- [Health check](https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/pages/api/health.ts): `shazam-app/src/pages/api/health.ts`
- [Catalog seeding](https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/pages/api/seed.ts): `shazam-app/src/pages/api/seed.ts`
- [Catalog cleanup](https://github.com/0shrihari0/shazam-cpp/blob/NEW-FRONTEND/shazam-app/src/pages/api/cleanup.ts): `shazam-app/src/pages/api/cleanup.ts`

### Other components

- **Listener**
- **Administrator**
- **MongoDB service**

## Connections

- Listener → Record and results: records with (evidence: `README.md`)
- Record and results → Listen controls: renders (evidence: `shazam-app/src/pages/index.tsx`)
- Record and results → Audio visualization: renders (evidence: `shazam-app/src/pages/index.tsx`)
- Record and results → Match cards: renders (evidence: `shazam-app/src/pages/index.tsx`)
- Record and results → Identify API: submits audio (evidence: `README.md`)
- Identify API → Engine bridge: generates and matches (evidence: `shazam-app/src/pages/api/identify.ts`)
- Engine bridge → C++ fingerprint engine: dispatches commands (evidence: `shazam-app/src/lib/cpp-engine.ts`)
- Engine bridge → TypeScript fingerprinting: falls back to (evidence: `shazam-app/src/lib/cpp-engine.ts`)
- Identify API → Song records: loads catalog (evidence: `shazam-app/src/pages/api/identify.ts`)
- Identify API → Record and results: returns matches (evidence: `README.md`)
- Administrator → Song upload: manages catalog (evidence: `README.md`)
- Song upload → Song API: posts song data (evidence: `shazam-app/src/pages/admin/upload.tsx`)
- Song API → Engine bridge: fingerprints audio (evidence: `shazam-app/src/pages/api/songs.ts`)
- Song API → Song records: reads and writes (evidence: `shazam-app/src/pages/api/songs.ts`)
- Song library → Song API: lists songs (evidence: `README.md`)
- Song records → MongoDB connection: uses connection
- MongoDB connection → MongoDB service: connects to
- Administrator → Admin login: signs in (evidence: `README.md`)
- Admin login → Authentication API: authenticates through (evidence: `README.md`)
- Authentication API → User records: verifies credentials (evidence: `shazam-app/src/pages/api/auth/[...nextauth].ts`)
- Authentication API → MongoDB connection: connects (evidence: `shazam-app/src/pages/api/auth/[...nextauth].ts`)
- Song API → Authentication API: checks session (evidence: `shazam-app/src/pages/api/songs.ts`)
- Delete all songs → Authentication API: checks session (evidence: `shazam-app/src/pages/api/songs/delete-all.ts`)
- Delete all songs → Song records: deletes records (evidence: `shazam-app/src/pages/api/songs/delete-all.ts`)
- Health check → MongoDB service: checks service
- Catalog seeding → MongoDB service: seeds catalog
- Catalog cleanup → MongoDB service: cleans data
- Page layout → Navigation: renders (evidence: `shazam-app/src/components/Layout.tsx`)
