# busradev/music-social-network architecture

> Architecture diagram of the GitHub repository busradev/music-social-network, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/busradev/music-social-network
- Repository: https://github.com/busradev/music-social-network

## Overview

This is a command-line music social network: users manage friendships and listening activity, and the system recommends popular songs into a primary user’s library. The main workflow enters through the terminal, parses commands, checks social distance for listens, tracks song popularity, then transfers top hits into the primary library. The graph and indexes are grounded in the excerpts and SOURCE INDEX; unsampled behavior is omitted where call ownership is not established.

Main entry points: [`Terminal.cpp`](https://github.com/busradev/music-social-network/blob/master/Terminal.cpp) (Command terminal), [`System.cpp`](https://github.com/busradev/music-social-network/blob/master/System.cpp) (Song system), [`BST.cpp`](https://github.com/busradev/music-social-network/blob/master/BST.cpp) (Song tree), [`Song.cpp`](https://github.com/busradev/music-social-network/blob/master/Song.cpp) (Song and listens)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Command interface"]
  node_terminal["Command terminal<br/>[Terminal.cpp]"]
  node_parser["Command parser<br/>[Parser.h]"]
end

subgraph group_social["Social network"]
  node_user_seed["User seed list<br/>[users.txt]"]
  node_graph["Friend graph<br/>[Graph.cpp]"]
  node_user_index["User tree<br/>[UBST.cpp]"]
  node_user_record["User record<br/>[User.cpp]"]
end

subgraph group_music["Music and recommendations"]
  node_song_seed["Song seed list<br/>[songs.txt]"]
  node_system["Song system<br/>[System.cpp]"]
  node_song_index["Song tree<br/>[BST.cpp]"]
  node_song["Song and listens<br/>[Song.cpp]"]
  node_hit_heap["Top-hit heap<br/>[Heap.cpp]"]
  node_primary["Primary library<br/>[PrimaryUser.cpp]"]
end

node_listener(("CLI user"))

node_listener -->|"enters commands"| node_terminal
node_terminal -->|"parses commands"| node_parser
node_terminal -->|"manages songs and hits"| node_system
node_terminal -->|"manages users and checks radius"| node_graph
node_terminal -->|"updates library"| node_primary
node_terminal -->|"loads songs"| node_song_seed
node_terminal -->|"loads users"| node_user_seed
node_graph -->|"indexes users"| node_user_index
node_user_index -->|"stores records"| node_user_record
node_system -->|"indexes catalog"| node_song_index
node_system -->|"ranks top hits"| node_hit_heap
node_song_index -->|"indexes songs"| node_song
node_hit_heap -->|"ranks song counts"| node_song
node_primary -->|"uses song tree"| node_song_index
node_terminal -->|"updates listen counts"| node_song

click node_terminal "https://github.com/busradev/music-social-network/blob/master/Terminal.cpp"
click node_parser "https://github.com/busradev/music-social-network/blob/master/Parser.h"
click node_song_seed "https://github.com/busradev/music-social-network/blob/master/songs.txt"
click node_user_seed "https://github.com/busradev/music-social-network/blob/master/users.txt"
click node_graph "https://github.com/busradev/music-social-network/blob/master/Graph.cpp"
click node_user_index "https://github.com/busradev/music-social-network/blob/master/UBST.cpp"
click node_user_record "https://github.com/busradev/music-social-network/blob/master/User.cpp"
click node_system "https://github.com/busradev/music-social-network/blob/master/System.cpp"
click node_song_index "https://github.com/busradev/music-social-network/blob/master/BST.cpp"
click node_song "https://github.com/busradev/music-social-network/blob/master/Song.cpp"
click node_hit_heap "https://github.com/busradev/music-social-network/blob/master/Heap.cpp"
click node_primary "https://github.com/busradev/music-social-network/blob/master/PrimaryUser.cpp"

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_terminal,node_parser,node_listener toneBlue
class node_user_seed,node_graph,node_user_index,node_user_record toneAmber
class node_song_seed,node_system,node_song_index,node_song,node_hit_heap,node_primary toneMint
```

## Components

### Command interface

- [Command terminal](https://github.com/busradev/music-social-network/blob/master/Terminal.cpp): `Terminal.cpp`
- [Command parser](https://github.com/busradev/music-social-network/blob/master/Parser.h): `Parser.h`

### Social network

- [User seed list](https://github.com/busradev/music-social-network/blob/master/users.txt): `users.txt`
- [Friend graph](https://github.com/busradev/music-social-network/blob/master/Graph.cpp): `Graph.cpp`
- [User tree](https://github.com/busradev/music-social-network/blob/master/UBST.cpp): `UBST.cpp`
- [User record](https://github.com/busradev/music-social-network/blob/master/User.cpp): `User.cpp`

### Music and recommendations

- [Song seed list](https://github.com/busradev/music-social-network/blob/master/songs.txt): `songs.txt`
- [Song system](https://github.com/busradev/music-social-network/blob/master/System.cpp): `System.cpp`
- [Song tree](https://github.com/busradev/music-social-network/blob/master/BST.cpp): `BST.cpp`
- [Song and listens](https://github.com/busradev/music-social-network/blob/master/Song.cpp): `Song.cpp`
- [Top-hit heap](https://github.com/busradev/music-social-network/blob/master/Heap.cpp): `Heap.cpp`
- [Primary library](https://github.com/busradev/music-social-network/blob/master/PrimaryUser.cpp): `PrimaryUser.cpp`

### Other components

- **CLI user**

## Connections

- CLI user → Command terminal: enters commands (evidence: `Terminal.cpp`)
- Command terminal → Command parser: parses commands (evidence: `Terminal.cpp`)
- Command terminal → Song system: manages songs and hits (evidence: `Terminal.cpp`)
- Command terminal → Friend graph: manages users and checks radius (evidence: `Terminal.cpp`)
- Command terminal → Primary library: updates library (evidence: `Terminal.cpp`)
- Command terminal → Song seed list: loads songs (evidence: `Terminal.cpp`)
- Command terminal → User seed list: loads users (evidence: `Terminal.cpp`)
- Friend graph → User tree: indexes users
- User tree → User record: stores records
- Song system → Song tree: indexes catalog
- Song system → Top-hit heap: ranks top hits
- Song tree → Song and listens: indexes songs
- Top-hit heap → Song and listens: ranks song counts (evidence: `Heap.cpp`)
- Primary library → Song tree: uses song tree
- Command terminal → Song and listens: updates listen counts (evidence: `Terminal.cpp`)
