# selvamraja700/topify architecture

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

- Interactive diagram: https://gitdiagram.com/selvamraja700/topify
- Repository: https://github.com/selvamraja700/topify

## Overview

#### Purpose and Runtime

This is a Vite-built React single-page music player. It presents a catalog of bundled songs, supports playback and synchronized lyrics, and includes client-side authentication, advertising, library/history-style pages, and responsive navigation. Browser storage is the likely persistence boundary; no backend or API integration is evident.

Entry points: `src/main.jsx` mounts the app, and `src/App.jsx` composes routing, providers, and page-level UI.

#### Application Shell and Navigation

`src/App.jsx` is the top-level control boundary for page selection and shared application composition. Desktop and mobile shells split navigation/layout concerns across `src/components/Sidebar/Sidebar.jsx`, `src/components/Navbar/Navbar.jsx`, `src/components/Layout/MobileLayout.jsx`, and `src/components/Navigation/BottomNav.jsx`.

Feature pages are organized under `src/pages`, including `src/pages/Home/Home.jsx`, `src/pages/Search/Search.jsx`, `src/pages/Library/Library.jsx`, and `src/pages/History/History.jsx`. Shared player UI remains available independently of catalog/page rendering.

#### Authentication and Access Boundary

Authentication state is centralized in `src/auth/AuthContext.jsx`. `src/auth/ProtectedRoute.jsx` gates routes or views requiring a signed-in user, while `src/pages/Auth/Login.jsx` provides the login entry flow.

This is a frontend-only authentication boundary based on the repository contents; no identity provider, server session, or remote user service is represented.

#### Playback State and Audio Engine

`src/context/PlayerContext.jsx` owns application-facing playback state and commands consumed by player and song-card components. `src/components/Player/Player.jsx` and `src/components/Cards/SongCard.jsx` are primary command/UI endpoints.

Playback execution is separated into an engine layer: `src/engine/AudioPlaybackController.js` controls audio lifecycle, `src/engine/CommandQueue.js` serializes or orders playback commands, and `src/engine/seeking/AudioSeekTransaction.js` isolates seek operations. `src/utils/PlaybackCoordinator.js` bridges orchestration concerns, reducing direct UI-to-audio coupling.

#### Lyrics Processing Pipeline

Lyrics are local assets, represented as timestamped LRC files in `src/lyrics/data/*.lrc` and associated song metadata in `src/data/songs.js`. The lyric pipeline is explicitly layered:

- `src/lyrics/LyricsRepository.js` retrieves lyric source data.
- `src/lyrics/LyricsParser.js` transforms LRC/text into timed lyric structures.
- `src/lyrics/LyricsCache.js` retains parsed results.
- `src/lyrics/LyricsController.js` coordinates playback-time lyric selection.
- `src/lyrics/BinarySearch.js` efficiently finds the active line.
- `src/lyrics/useLyrics.js` exposes this behavior to React UI, notably `src/components/Player/LyricsScreen.jsx`.

Playback time therefore flows from the audio/player layer into lyric lookup, then into synchronized rendering.

#### Advertising and Monetization Flow

Advertising is encapsulated under `src/ads`. `src/ads/AdContext.jsx` exposes ad state, `src/ads/AdManager.jsx` coordinates ad behavior, `src/ads/AdScheduler.js` determines display timing, and `src/ads/AdOverlay.jsx` renders the interruption layer. `src/ads/AdStorage.js` persists ad-related state locally.

Premium UX is represented by `src/pages/Premium/Premium.jsx`; no payment processor or external ad network adapter is present.

#### Data, Persistence, and Deployment

Catalog and lyric metadata are bundled locally through `src/data/songs.js` and `src/data/lyricsData.js`; `src/services/dataService.js` is the application data-access boundary. Local persistence is supported by `src/hooks/useLocalStorage.js`, with `src/engine/LRUCache.js` providing in-memory bounded caching.

The deployment/runtime stack is React, Vite, Tailwind/PostCSS, and Vercel (`vite.config.js`, `tailwind.config.js`, `vercel.json`). Browser audio APIs and local storage are the material platform services.

Main entry points: [`src/App.jsx`](https://github.com/selvamraja700/topify/blob/main/src/App.jsx) (Application shell), [`src/engine/AudioPlaybackController.js`](https://github.com/selvamraja700/topify/blob/main/src/engine/AudioPlaybackController.js) (Audio controller), [`src/ads/AdManager.jsx`](https://github.com/selvamraja700/topify/blob/main/src/ads/AdManager.jsx) (Ad manager), [`src/context/PlayerContext.jsx`](https://github.com/selvamraja700/topify/blob/main/src/context/PlayerContext.jsx) (Player state)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["React application"]
  node_main(("App mount<br/>React entry<br/>[main.jsx]"))
  node_app_shell["Application shell<br/>routing and composition<br/>[App.jsx]"]
  node_navigation["Responsive navigation<br/>layout UI<br/>[Sidebar.jsx]"]
  node_pages["Catalog pages<br/>page views<br/>[Home.jsx]"]
  node_auth["Authentication state<br/>React context<br/>[AuthContext.jsx]"]
  node_protected_route["Protected routes<br/>access gate<br/>[ProtectedRoute.jsx]"]
  node_login["Login page<br/>auth UI<br/>[Login.jsx]"]
end

subgraph group_playback["Playback and lyrics"]
  node_player_context["Player state<br/>React context<br/>[PlayerContext.jsx]"]
  node_player_ui["Player controls<br/>playback UI<br/>[Player.jsx]"]
  node_audio_controller{{"Audio controller<br/>audio engine"}}
  node_command_queue["Command queue<br/>playback ordering<br/>[CommandQueue.js]"]
  node_seek_transaction["Seek transaction<br/>seek engine"]
  node_coordinator["Playback coordinator<br/>orchestration bridge"]
  node_lyrics_pipeline["Lyrics pipeline<br/>local lyric processing"]
  node_lyrics_ui["Synchronized lyrics<br/>React hook and UI<br/>[LyricsScreen.jsx]"]
end

subgraph group_monetization["Advertising"]
  node_ad_system["Ad manager<br/>ad orchestration<br/>[AdManager.jsx]"]
  node_ad_context["Ad state<br/>React context<br/>[AdContext.jsx]"]
  node_ad_overlay["Ad overlay<br/>interruption UI<br/>[AdOverlay.jsx]"]
  node_premium["Premium page<br/>page view<br/>[Premium.jsx]"]
end

subgraph group_data["Local data and storage"]
  node_data_service["Data service<br/>data access boundary<br/>[dataService.js]"]
  node_catalog["Bundled song catalog<br/>local metadata<br/>[songs.js]"]
  node_browser_storage[("Browser storage<br/>local persistence<br/>[useLocalStorage.js]")]
end

node_main -->|"mounts"| node_app_shell
node_app_shell -->|"composes"| node_navigation
node_app_shell -->|"selects"| node_pages
node_app_shell -->|"provides"| node_auth
node_protected_route -->|"checks"| node_auth
node_login -->|"signs in"| node_auth
node_app_shell -->|"uses"| node_protected_route
node_app_shell -->|"provides"| node_player_context
node_player_ui -->|"issues commands"| node_player_context
node_player_context -->|"orchestrates"| node_coordinator
node_coordinator -->|"orders commands"| node_command_queue
node_command_queue -->|"executes"| node_audio_controller
node_audio_controller -->|"seeks through"| node_seek_transaction
node_audio_controller -->|"playback time"| node_lyrics_pipeline
node_lyrics_pipeline -->|"active line"| node_lyrics_ui
node_catalog -->|"supplies"| node_data_service
node_data_service -->|"serves catalog"| node_pages
node_catalog -->|"lyrics source"| node_lyrics_pipeline
node_app_shell -->|"provides"| node_ad_context
node_ad_context -->|"exposes state"| node_ad_system
node_ad_system -->|"displays"| node_ad_overlay
node_ad_system -->|"persists state"| node_browser_storage
node_premium -.->|"premium UX"| node_ad_context

click node_main "https://github.com/selvamraja700/topify/blob/main/src/main.jsx"
click node_app_shell "https://github.com/selvamraja700/topify/blob/main/src/App.jsx"
click node_navigation "https://github.com/selvamraja700/topify/blob/main/src/components/Sidebar/Sidebar.jsx"
click node_pages "https://github.com/selvamraja700/topify/blob/main/src/pages/Home/Home.jsx"
click node_auth "https://github.com/selvamraja700/topify/blob/main/src/auth/AuthContext.jsx"
click node_protected_route "https://github.com/selvamraja700/topify/blob/main/src/auth/ProtectedRoute.jsx"
click node_login "https://github.com/selvamraja700/topify/blob/main/src/pages/Auth/Login.jsx"
click node_player_context "https://github.com/selvamraja700/topify/blob/main/src/context/PlayerContext.jsx"
click node_player_ui "https://github.com/selvamraja700/topify/blob/main/src/components/Player/Player.jsx"
click node_audio_controller "https://github.com/selvamraja700/topify/blob/main/src/engine/AudioPlaybackController.js"
click node_command_queue "https://github.com/selvamraja700/topify/blob/main/src/engine/CommandQueue.js"
click node_seek_transaction "https://github.com/selvamraja700/topify/blob/main/src/engine/seeking/AudioSeekTransaction.js"
click node_coordinator "https://github.com/selvamraja700/topify/blob/main/src/utils/PlaybackCoordinator.js"
click node_lyrics_pipeline "https://github.com/selvamraja700/topify/blob/main/src/lyrics/LyricsController.js"
click node_lyrics_ui "https://github.com/selvamraja700/topify/blob/main/src/components/Player/LyricsScreen.jsx"
click node_ad_system "https://github.com/selvamraja700/topify/blob/main/src/ads/AdManager.jsx"
click node_ad_context "https://github.com/selvamraja700/topify/blob/main/src/ads/AdContext.jsx"
click node_ad_overlay "https://github.com/selvamraja700/topify/blob/main/src/ads/AdOverlay.jsx"
click node_premium "https://github.com/selvamraja700/topify/blob/main/src/pages/Premium/Premium.jsx"
click node_data_service "https://github.com/selvamraja700/topify/blob/main/src/services/dataService.js"
click node_catalog "https://github.com/selvamraja700/topify/blob/main/src/data/songs.js"
click node_browser_storage "https://github.com/selvamraja700/topify/blob/main/src/hooks/useLocalStorage.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_main,node_app_shell,node_navigation,node_pages,node_auth,node_protected_route,node_login toneBlue
class node_player_context,node_player_ui,node_audio_controller,node_command_queue,node_seek_transaction,node_coordinator,node_lyrics_pipeline,node_lyrics_ui toneAmber
class node_ad_system,node_ad_context,node_ad_overlay,node_premium toneMint
class node_data_service,node_catalog,node_browser_storage toneRose
```

## Components

### React application

- [App mount](https://github.com/selvamraja700/topify/blob/main/src/main.jsx): React entry · `src/main.jsx`
- [Application shell](https://github.com/selvamraja700/topify/blob/main/src/App.jsx): routing and composition · `src/App.jsx`
- [Responsive navigation](https://github.com/selvamraja700/topify/blob/main/src/components/Sidebar/Sidebar.jsx): layout UI · Sidebar, navbar, mobile layout, and bottom navigation. · `src/components/Sidebar/Sidebar.jsx`
- [Catalog pages](https://github.com/selvamraja700/topify/blob/main/src/pages/Home/Home.jsx): page views · Home, search, library, and history views. · `src/pages/Home/Home.jsx`
- [Authentication state](https://github.com/selvamraja700/topify/blob/main/src/auth/AuthContext.jsx): React context · Frontend-only signed-in state. · `src/auth/AuthContext.jsx`
- [Protected routes](https://github.com/selvamraja700/topify/blob/main/src/auth/ProtectedRoute.jsx): access gate · `src/auth/ProtectedRoute.jsx`
- [Login page](https://github.com/selvamraja700/topify/blob/main/src/pages/Auth/Login.jsx): auth UI · `src/pages/Auth/Login.jsx`

### Playback and lyrics

- [Player state](https://github.com/selvamraja700/topify/blob/main/src/context/PlayerContext.jsx): React context · Application playback commands and state. · `src/context/PlayerContext.jsx`
- [Player controls](https://github.com/selvamraja700/topify/blob/main/src/components/Player/Player.jsx): playback UI · Player and song-card command endpoints. · `src/components/Player/Player.jsx`
- [Audio controller](https://github.com/selvamraja700/topify/blob/main/src/engine/AudioPlaybackController.js): audio engine · Controls browser audio lifecycle. · `src/engine/AudioPlaybackController.js`
- [Command queue](https://github.com/selvamraja700/topify/blob/main/src/engine/CommandQueue.js): playback ordering · `src/engine/CommandQueue.js`
- [Seek transaction](https://github.com/selvamraja700/topify/blob/main/src/engine/seeking/AudioSeekTransaction.js): seek engine · `src/engine/seeking/AudioSeekTransaction.js`
- [Playback coordinator](https://github.com/selvamraja700/topify/blob/main/src/utils/PlaybackCoordinator.js): orchestration bridge · `src/utils/PlaybackCoordinator.js`
- [Lyrics pipeline](https://github.com/selvamraja700/topify/blob/main/src/lyrics/LyricsController.js): local lyric processing · Repository, parser, cache, controller, and active-line lookup. · `src/lyrics/LyricsController.js`
- [Synchronized lyrics](https://github.com/selvamraja700/topify/blob/main/src/components/Player/LyricsScreen.jsx): React hook and UI · `src/components/Player/LyricsScreen.jsx`

### Advertising

- [Ad manager](https://github.com/selvamraja700/topify/blob/main/src/ads/AdManager.jsx): ad orchestration · Coordinates scheduling and overlay behavior. · `src/ads/AdManager.jsx`
- [Ad state](https://github.com/selvamraja700/topify/blob/main/src/ads/AdContext.jsx): React context · `src/ads/AdContext.jsx`
- [Ad overlay](https://github.com/selvamraja700/topify/blob/main/src/ads/AdOverlay.jsx): interruption UI · `src/ads/AdOverlay.jsx`
- [Premium page](https://github.com/selvamraja700/topify/blob/main/src/pages/Premium/Premium.jsx): page view · `src/pages/Premium/Premium.jsx`

### Local data and storage

- [Data service](https://github.com/selvamraja700/topify/blob/main/src/services/dataService.js): data access boundary · `src/services/dataService.js`
- [Bundled song catalog](https://github.com/selvamraja700/topify/blob/main/src/data/songs.js): local metadata · Song and lyric metadata plus LRC assets. · `src/data/songs.js`
- [Browser storage](https://github.com/selvamraja700/topify/blob/main/src/hooks/useLocalStorage.js): local persistence · Used for application and ad state. · `src/hooks/useLocalStorage.js`

## Connections

- App mount → Application shell: mounts
- Application shell → Responsive navigation: composes
- Application shell → Catalog pages: selects
- Application shell → Authentication state: provides
- Protected routes → Authentication state: checks
- Login page → Authentication state: signs in
- Application shell → Protected routes: uses
- Application shell → Player state: provides
- Player controls → Player state: issues commands
- Player state → Playback coordinator: orchestrates
- Playback coordinator → Command queue: orders commands
- Command queue → Audio controller: executes
- Audio controller → Seek transaction: seeks through
- Audio controller → Lyrics pipeline: playback time
- Lyrics pipeline → Synchronized lyrics: active line
- Bundled song catalog → Data service: supplies
- Data service → Catalog pages: serves catalog
- Bundled song catalog → Lyrics pipeline: lyrics source
- Application shell → Ad state: provides
- Ad state → Ad manager: exposes state
- Ad manager → Ad overlay: displays
- Ad manager → Browser storage: persists state
- Premium page → Ad state: premium UX
