"use client" import { useState } from "react" import { useQuery } from "@tanstack/react-query" import { getTracks, getStats } from "@/lib/api" import type { FilterParams } from "@/lib/types" export default function Home() { const [filters, setFilters] = useState({}) const [page, setPage] = useState(0) const limit = 50 const { data: tracksData, isLoading: isLoadingTracks } = useQuery({ queryKey: ['tracks', filters, page], queryFn: () => getTracks({ ...filters, skip: page * limit, limit }), }) const { data: stats } = useQuery({ queryKey: ['stats'], queryFn: getStats, }) return (
{/* Header */}

Audio Classifier

Intelligent music library management

{/* Main Content */}
{/* Stats */} {stats && (

Total Tracks

{stats.total_tracks}

Avg BPM

{stats.average_bpm}

Total Hours

{stats.total_duration_hours}h

Genres

{stats.genres.length}

)} {/* Tracks List */}

Music Library

{tracksData?.total || 0} tracks total

{isLoadingTracks ? (
Loading...
) : tracksData?.tracks.length === 0 ? (
No tracks found. Start by analyzing your audio library!
) : (
{tracksData?.tracks.map((track) => (

{track.filename}

{/* Primary metadata */}
{track.classification.genre.primary} {track.classification.mood.primary} {Math.round(track.features.tempo_bpm)} BPM {track.features.key} {Math.floor(track.duration_seconds / 60)}:{String(Math.floor(track.duration_seconds % 60)).padStart(2, '0')}
{/* Secondary moods */} {track.classification.mood.secondary && track.classification.mood.secondary.length > 0 && (
Also: {track.classification.mood.secondary.map((mood, i) => ( {mood} ))}
)} {/* Instruments */} {track.classification.instruments && track.classification.instruments.length > 0 && (
Instruments: {track.classification.instruments.slice(0, 6).map((instrument, i) => ( {instrument} ))} {track.classification.instruments.length > 6 && ( +{track.classification.instruments.length - 6} more )}
)}
))}
)} {/* Pagination */} {tracksData && tracksData.total > limit && (
Page {page + 1} of {Math.ceil(tracksData.total / limit)}
)}
{/* Instructions */}

Getting Started

  1. Make sure the backend is running (docker-compose up)
  2. Use the API to analyze your audio library:
                    {`curl -X POST http://localhost:8000/api/analyze/folder \\
      -H "Content-Type: application/json" \\
      -d '{"path": "/audio/your_music", "recursive": true}'`}
                  
  3. Refresh this page to see your analyzed tracks
) }