# egbejoe06/musicgenre architecture

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

- Interactive diagram: https://gitdiagram.com/egbejoe06/musicgenre
- Repository: https://github.com/egbejoe06/musicgenre

## Overview

#### Purpose and Deployment Shape
Music Genre Classifier is a two-process application: a Vue 3 browser client captures or accepts audio, and an Express API submits it to Google Gemini for native audio-based genre analysis. The frontend runs through Vite; the backend is a Node.js service configured with a Gemini API key.
- `Frontend/src/main.js`
- `Backend/server.js`
- `Backend/.env.example`

#### Frontend Application Shell
The Vue application boots the root component and uses Vue Router to render the primary user workflow. `App.vue` provides the application shell, while the home view coordinates input, submission, loading/error state, and result presentation.
- `Frontend/src/main.js`
- `Frontend/src/App.vue`
- `Frontend/src/router/index.js`
- `Frontend/src/views/HomeView.vue`

#### Audio Acquisition Boundary
Audio enters the client through two interchangeable sources. The recorder uses browser microphone and Web Audio/media capabilities for recorded clips and waveform-oriented interaction; the uploader accepts existing audio files. Both produce an audio payload for the shared classification path, keeping browser media handling separate from API and AI concerns.
- `Frontend/src/components/AudioRecorder.vue`
- `Frontend/src/components/AudioUploader.vue`
- `Frontend/src/views/HomeView.vue`

#### API Client and Request Flow
The frontend API service is the network boundary. It sends the selected or recorded audio as `multipart/form-data` to the backend classification endpoint, using a configurable API URL via frontend environment settings. The expected response carries genre, subgenre, confidence, reasoning, acoustic analysis, and timestamp.
- `Frontend/src/services/api.js`
- `Frontend/.env.example`
- `Frontend/src/views/HomeView.vue`

#### Result Rendering
Classification output is isolated in a dedicated Vue component. It consumes the structured API response rather than interpreting raw model output in the UI, allowing the backend to own response normalization and error handling.
- `Frontend/src/components/GenreResult.vue`
- `Frontend/src/views/HomeView.vue`

#### Backend Ingestion and AI Orchestration
Express exposes `GET /api/health` for service checks and `POST /api/classify` for audio analysis. Multer handles multipart upload ingestion, with supported audio constrained to MP3, WAV, FLAC, and WebM and a stated 10 MB maximum. The server then invokes Google Generative AI/Gemini, relying on Gemini’s native audio understanding rather than local feature extraction, and returns normalized JSON to the client.
- `Backend/server.js`
- `Backend/package.json`
- `Backend/.env.example`

#### Runtime and External Dependencies
The primary runtimes are a modern Node.js backend and browser-hosted Vue/Vite frontend. Material external services and platform boundaries are Google Gemini via `GEMINI_API_KEY`, browser microphone permissions (HTTPS or localhost), and local HTTP communication between the Vite client and Express API. Styling is frontend-local via Tailwind and the main stylesheet.
- `Backend/server.js`
- `Frontend/vite.config.js`
- `Frontend/src/assets/main.css`

Main entry points: [`Frontend/src/views/HomeView.vue`](https://github.com/egbejoe06/musicgenre/blob/main/Frontend/src/views/HomeView.vue) (Classification workflow), [`Frontend/src/services/api.js`](https://github.com/egbejoe06/musicgenre/blob/main/Frontend/src/services/api.js) (API client), [`Backend/server.js`](https://github.com/egbejoe06/musicgenre/blob/main/Backend/server.js) (Express server), [`Frontend/src/main.js`](https://github.com/egbejoe06/musicgenre/blob/main/Frontend/src/main.js) (Vue bootstrap)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Vue Browser Client"]
  node_vite{{"Vite runtime<br/>frontend runtime<br/>[vite.config.js]"}}
  node_main["Vue bootstrap<br/>entrypoint<br/>[main.js]"]
  node_app["Application shell<br/>Vue component<br/>[App.vue]"]
  node_router["Vue Router<br/>routing<br/>[index.js]"]
  node_home["Classification workflow<br/>Vue view<br/>[HomeView.vue]"]
  node_recorder["Audio recorder<br/>Vue component<br/>[AudioRecorder.vue]"]
  node_uploader["Audio uploader<br/>Vue component<br/>[AudioUploader.vue]"]
  node_api_client["API client<br/>frontend service<br/>[api.js]"]
  node_result["Genre result<br/>Vue component<br/>[GenreResult.vue]"]
end

subgraph group_backend["Express API"]
  node_express{{"Express server<br/>API entrypoint<br/>[server.js]"}}
  node_upload["Multer ingestion<br/>multipart upload<br/>[server.js]"]
  node_gemini_client["Gemini orchestration<br/>AI integration<br/>[server.js]"]
end

subgraph group_external["Platform &amp; AI"]
  node_microphone(("Browser microphone<br/>browser platform"))
  node_gemini{{"Google Gemini<br/>external AI service"}}
end

node_vite -->|"serves"| node_main
node_main -->|"mounts"| node_app
node_app -->|"hosts"| node_router
node_router -->|"renders"| node_home
node_microphone -->|"audio capture"| node_recorder
node_recorder -->|"recorded audio"| node_home
node_uploader -->|"selected file"| node_home
node_home -->|"classify audio"| node_api_client
node_api_client -->|"POST /api/classify multipart"| node_express
node_express -->|"ingests request"| node_upload
node_upload -->|"validated audio"| node_gemini_client
node_gemini_client -->|"audio analysis"| node_gemini
node_gemini -->|"genre analysis"| node_gemini_client
node_gemini_client -->|"normalized JSON"| node_express
node_express -->|"classification response"| node_api_client
node_api_client -->|"structured result"| node_home
node_home -->|"renders result"| node_result

click node_vite "https://github.com/egbejoe06/musicgenre/blob/main/Frontend/vite.config.js"
click node_main "https://github.com/egbejoe06/musicgenre/blob/main/Frontend/src/main.js"
click node_app "https://github.com/egbejoe06/musicgenre/blob/main/Frontend/src/App.vue"
click node_router "https://github.com/egbejoe06/musicgenre/blob/main/Frontend/src/router/index.js"
click node_home "https://github.com/egbejoe06/musicgenre/blob/main/Frontend/src/views/HomeView.vue"
click node_recorder "https://github.com/egbejoe06/musicgenre/blob/main/Frontend/src/components/AudioRecorder.vue"
click node_uploader "https://github.com/egbejoe06/musicgenre/blob/main/Frontend/src/components/AudioUploader.vue"
click node_api_client "https://github.com/egbejoe06/musicgenre/blob/main/Frontend/src/services/api.js"
click node_result "https://github.com/egbejoe06/musicgenre/blob/main/Frontend/src/components/GenreResult.vue"
click node_express "https://github.com/egbejoe06/musicgenre/blob/main/Backend/server.js"
click node_upload "https://github.com/egbejoe06/musicgenre/blob/main/Backend/server.js"
click node_gemini_client "https://github.com/egbejoe06/musicgenre/blob/main/Backend/server.js"

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_vite,node_main,node_app,node_router,node_home,node_recorder,node_uploader,node_api_client,node_result toneBlue
class node_express,node_upload,node_gemini_client toneAmber
class node_microphone,node_gemini toneMint
```

## Components

### Vue Browser Client

Vite-hosted Vue 3 application.

- [Vite runtime](https://github.com/egbejoe06/musicgenre/blob/main/Frontend/vite.config.js): frontend runtime · `Frontend/vite.config.js`
- [Vue bootstrap](https://github.com/egbejoe06/musicgenre/blob/main/Frontend/src/main.js): entrypoint · `Frontend/src/main.js`
- [Application shell](https://github.com/egbejoe06/musicgenre/blob/main/Frontend/src/App.vue): Vue component · `Frontend/src/App.vue`
- [Vue Router](https://github.com/egbejoe06/musicgenre/blob/main/Frontend/src/router/index.js): routing · `Frontend/src/router/index.js`
- [Classification workflow](https://github.com/egbejoe06/musicgenre/blob/main/Frontend/src/views/HomeView.vue): Vue view · Coordinates input, submission state, and results. · `Frontend/src/views/HomeView.vue`
- [Audio recorder](https://github.com/egbejoe06/musicgenre/blob/main/Frontend/src/components/AudioRecorder.vue): Vue component · Captures microphone clips with browser media APIs. · `Frontend/src/components/AudioRecorder.vue`
- [Audio uploader](https://github.com/egbejoe06/musicgenre/blob/main/Frontend/src/components/AudioUploader.vue): Vue component · Accepts existing audio files. · `Frontend/src/components/AudioUploader.vue`
- [API client](https://github.com/egbejoe06/musicgenre/blob/main/Frontend/src/services/api.js): frontend service · Sends multipart audio to the classification API. · `Frontend/src/services/api.js`
- [Genre result](https://github.com/egbejoe06/musicgenre/blob/main/Frontend/src/components/GenreResult.vue): Vue component · Renders normalized classification output. · `Frontend/src/components/GenreResult.vue`

### Express API

Node.js audio classification service.

- [Express server](https://github.com/egbejoe06/musicgenre/blob/main/Backend/server.js): API entrypoint · Exposes health and classification endpoints. · `Backend/server.js`
- [Multer ingestion](https://github.com/egbejoe06/musicgenre/blob/main/Backend/server.js): multipart upload · Validates MP3, WAV, FLAC, and WebM uploads up to 10 MB. · `Backend/server.js`
- [Gemini orchestration](https://github.com/egbejoe06/musicgenre/blob/main/Backend/server.js): AI integration · Submits audio and normalizes the model response. · `Backend/server.js`

### Platform & AI

- **Browser microphone**: browser platform · Requires permission and HTTPS or localhost.
- **Google Gemini**: external AI service · Native audio-based genre analysis.

## Connections

- Vite runtime → Vue bootstrap: serves
- Vue bootstrap → Application shell: mounts
- Application shell → Vue Router: hosts
- Vue Router → Classification workflow: renders
- Browser microphone → Audio recorder: audio capture
- Audio recorder → Classification workflow: recorded audio
- Audio uploader → Classification workflow: selected file
- Classification workflow → API client: classify audio
- API client → Express server: POST /api/classify multipart
- Express server → Multer ingestion: ingests request
- Multer ingestion → Gemini orchestration: validated audio
- Gemini orchestration → Google Gemini: audio analysis · Uses GEMINI_API_KEY.
- Google Gemini → Gemini orchestration: genre analysis
- Gemini orchestration → Express server: normalized JSON
- Express server → API client: classification response
- API client → Classification workflow: structured result
- Classification workflow → Genre result: renders result
