# jaredfigdor/music-analyzer architecture

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

- Interactive diagram: https://gitdiagram.com/jaredfigdor/music-analyzer
- Repository: https://github.com/jaredfigdor/music-analyzer

## Overview

##### Project Type and Purpose
- From the file tree and README, this is a full-stack web application called “Music Analyzer.”
- Purpose: Users upload audio files via a React/Next.js frontend; a Python/FastAPI backend performs audio analysis (BPM, key, energy, danceability, happiness, genre) and returns results to the UI.

##### File Structure
- Top-Level Directories:
- app/ – Next.js 13+ “app” router with pages, layout, global CSS
- backend/ – Python FastAPI server containing main.py (API routes) and music_analyzer.py (analysis logic)
- components/ and hooks/ – React UI elements (shadcn/ui) and custom hooks
- lib/ – shared utilities for the frontend
- public/, styles/ – static assets and Tailwind CSS config
- Configuration files: next.config.mjs, tailwind.config.ts, tsconfig.json, Python requirements.txt, uvicorn commands in README.

##### README for Additional Insights
- Confirms tech stack: Next.js/TypeScript/Tailwind/shadcn/ui on the frontend; FastAPI/Python + librosa + Hugging Face Transformers on the backend.
- Describes the flow: frontend POSTs file → backend processes locally (librosa) and via external API + Hugging Face → JSON response → UI display.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Top-level User
    User["User (Browser)"]:::external

    %% Frontend Layer
    subgraph "Frontend"
        direction TB
        NextJS_FE["Next.js Frontend"]:::frontend
        UI_COMPONENTS["shadcn/ui Components"]:::frontend
        CUSTOM_RESULTS["Results Display Component"]:::frontend
        CUSTOM_THEME["Theme Provider Component"]:::frontend
        HOOK_MOBILE["use-mobile Hook"]:::frontend
        HOOK_TOAST["use-toast Hook"]:::frontend
        UTILS["Utility Functions"]:::frontend
        CONFIG_TW["Tailwind Config"]:::frontend
        CONFIG_NX["Next.js Config"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend"
        direction TB
        FASTAPI["FastAPI Server"]:::backend
        ANALYZER["Audio Analysis Module"]:::backend
        REQ_TXT["requirements.txt"]:::backend
    end

    %% External Services
    subgraph "External Services"
        direction TB
        BEATSTORA["Beatstora API"]:::external
        HUGGINGFACE["Hugging Face Model"]:::external
    end

    %% Data Flow
    User -->|"Uploads Audio File"| NextJS_FE
    NextJS_FE -->|"POST /analyze (JSON)"| FASTAPI
    FASTAPI -->|"calls Analyzer"| ANALYZER
    ANALYZER -->|"HTTP Request"| BEATSTORA
    ANALYZER -->|"Model Inference"| HUGGINGFACE
    BEATSTORA -->|"API Response"| ANALYZER
    HUGGINGFACE -->|"Inference Result"| ANALYZER
    ANALYZER -->|"Aggregated JSON"| FASTAPI
    FASTAPI -->|"JSON Response"| NextJS_FE
    NextJS_FE -->|"Display Results"| User

    %% Click Events
    click NextJS_FE "https://github.com/jaredfigdor/music-analyzer/tree/main/app/"
    click UI_COMPONENTS "https://github.com/jaredfigdor/music-analyzer/tree/main/components/ui/"
    click CUSTOM_RESULTS "https://github.com/jaredfigdor/music-analyzer/blob/main/components/results-display.tsx"
    click CUSTOM_THEME "https://github.com/jaredfigdor/music-analyzer/blob/main/components/theme-provider.tsx"
    click HOOK_MOBILE "https://github.com/jaredfigdor/music-analyzer/blob/main/hooks/use-mobile.tsx"
    click HOOK_TOAST "https://github.com/jaredfigdor/music-analyzer/blob/main/hooks/use-toast.ts"
    click UTILS "https://github.com/jaredfigdor/music-analyzer/blob/main/lib/utils.ts"
    click CONFIG_TW "https://github.com/jaredfigdor/music-analyzer/blob/main/tailwind.config.ts"
    click CONFIG_NX "https://github.com/jaredfigdor/music-analyzer/blob/main/next.config.mjs"
    click FASTAPI "https://github.com/jaredfigdor/music-analyzer/blob/main/backend/main.py"
    click REQ_TXT "https://github.com/jaredfigdor/music-analyzer/blob/main/backend/requirements.txt"
    click ANALYZER "https://github.com/jaredfigdor/music-analyzer/blob/main/backend/music_analyzer.py"

    %% Styles
    classDef frontend fill:#add8e6,stroke:#000,stroke-width:1px;
    classDef backend fill:#90ee90,stroke:#000,stroke-width:1px;
    classDef external fill:#ffcc99,stroke:#000,stroke-width:1px;
```
