How crisbrav/desafio2 works
Project Type and Purpose
• This is a desktop C++ Qt application that simulates the core features of a music-streaming app.
• It uses object-oriented design (POO) to model songs, albums, artists, users, in-app ads, credits, and basic playback queues.
• The system reads and writes flat files (text data and OGG audio assets) in a local “data” directory.
File Structure Analysis
Top-level “Desafio-2” directory:
• Domain model classes (.cpp/.h):
– Album, Artista, Cancion, Usuario, Anuncio, Creditos, Plataforma
• Utility data structures: ArregloDinamico (dynamic array), PilaSimple (simple stack), Metricas
• UI boundary: UiReproductor.h (Qt user interface definitions)
• Entry point: main.cpp
• Build output:
– audio/ (OGG files)
– covers/ (album images)
– data/ (albums.txt, artistas.txt, canciones.txt, anuncios.txt, usuarios.txt, favoritos.txt)
– compiled objects, Makefiles, executable
Key Architectural Roles
a. Presentation Layer
– Qt UI definitions in UiReproductor.h
– main.cpp initializes QApplication and launches the UI.
b. Application/Service Layer
– Plataforma class orchestrates startup, data loading, event handling and exposes playback APIs to the UI.
c. Domain Model Layer
– Cancion, Album, Artista, Usuario, Anuncio, Creditos
– Relationships:
· Cancion has metadata (duration, bitrate) and belongs to an Album/Artista.
· Usuario has a list of favorite songs.
· Plataforma maintains collections of domain objects.
d. Data Access Layer (Flat-file persistence)
– Plataforma uses ArregloDinamico to load arrays of objects from TXT files in data/.
– Favorites are read/written via archivos favoritos.txt.
e. Playback Engine / Asset Layer
– OGG audio files in audio/
– UI layer calls into Plataforma to queue songs, advertisements (Anuncio), credits (Creditos).
a. Main Components
– UI Layer (Qt Reproductor)
– Service/Controller: Plataforma
– Domain Objects: Cancion, Album, Artista, Usuario, Anuncio, Creditos
– Data Structures: ArregloDinamico, PilaSimple, Metricas
– Persistence: File System (data/*.txt)
– Asset Store: audio/*.ogg, covers/
b. Relationships and Interactions
1. UI ➔ Plataforma
• Playback commands, navigation, user input
2. Plataforma ➔ Domain Objects
• Loads models into ArregloDinamico collections
• Applies business rules (e.g., insert Anuncio every N songs, show Creditos at end)
3. Plataforma ➔ Persistence (data files)
• Read on startup, write favorites on user action
4. Plataforma ➔ Playback Engine
• Streams OGG files from audio/ in ordered sequence
5. Domain Objects ↔ Utility Structures
• Cancion, Album, Artista stored in dynamic arrays
• Creditos pushed onto PilaSimple for end-of-session display
6. Metricas collects runtime statistics from Plataforma
c. Architectural Patterns & Principles
– Layered Architecture: UI, Service, Domain, Persistence, Assets
– Single Responsibility: each class has clear domain focus
– Dependency Inversion: high-level Plataforma depends on abstractions (file format)
– Composition: Plataforma composes dynamic arrays and stacks
d. Key Technologies & Frameworks
– C++17, Qt 6 GUI framework
– Standard I/O streams for file operations
– Custom templates for dynamic arrays and stacks