# salmanulfaris/iitm-mad-1-music-app architecture

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

- Interactive diagram: https://gitdiagram.com/salmanulfaris/iitm-mad-1-music-app
- Repository: https://github.com/salmanulfaris/iitm-mad-1-music-app

## Overview

##### Project Type and Purpose
- The project is a web-based Music Streaming App built with Flask. It provides different user experiences for administrators, content creators, and end-users. The use of Bootstrap 5 in the frontend and SQLite as the backend database further positions this as a modern, lightweight full-stack application.
- The README confirms key functionalities such as user authentication (login/register), role-based interfaces (admin, creator, user), and API endpoints (documented externally via Postman).

##### Main Components of the System
- Web Server / Flask Application: This is the core container where everything runs. It’s responsible for handling routes, managing sessions, and binding the blueprints.
- Blueprints / Modules:
- Admin Module: (app/admin) – Contains routes for administrative functionalities like managing content or system settings.
- API Module: (app/api) – Manages REST API endpoints including input validation and external integrations.
- Creator Module: (app/creator) – Manages creator-specific actions such as uploading or editing songs/albums.
- Main Module: (app/main) – Likely manages the primary application views for end-users (e.g., home, song playback, playlists).
- Models and Extensions:
- Models: (app/models.py) – Defines database models that interact with the SQLite database.
- Extensions: (app/extensions.py) – Manages Flask extensions (e.g., SQLAlchemy, authentication libraries, etc.).
- Static Assets and Templates:
- Static Files: (app/static) is used for CSS (Bootstrap and miscellaneous styling) and images.
- Templates: (app/templates) are organized by function (admin, auth, creator, user) and form the view layer using Jinja templating.
- Storage:
- Media Storage: (app/storage) holds song files under songs, and related media thumbnails organized by album, song, and user.

##### Relationships and Interactions
- The client’s browser sends HTTP requests to the Flask web server which dispatches them to the respective blueprint based on the URL path.
- Each blueprint (admin, API, creator, main) encapsulates its domain logic and interacts with the database via the models.
- The templates render data for the user while static assets (CSS, images, JS) aid in the front-end presentation.
- The storage directory acts as a file server for multimedia content (songs and thumbnails) accessed via application routes.
- The API module might interact with external services or be used by third parties (as noted in the Postman documentation).

##### Architectural Patterns and Design Principles
- Modular Blueprint Pattern: Separates concerns by splitting routes among distinct modules (admin, api, creator, main).
- MVC-like Separation: While Flask is not strictly an MVC framework, you see a clear separation between business logic (models and routes) and presentation (templates).
- Lightweight full-stack structure: All components (server, database, static assets) live within a unified folder structure, simplifying deployment for a small to medium application.

##### Detailed Component Breakdown
- Flask App:
- This as the main container with sub-components for each blueprint (admin, api, creator, main).
- Database:
- Static and Template Layers:
- Paths to static directories (CSS, images) and separate template directories used by different blueprints.
- Media Storage:
- Depicting a separate ‘file storage’ component for songs and thumbnails, with clear interaction lines from the appropriate routes.
- External Interaction:

## Diagram (Mermaid)

```mermaid
flowchart TD
    Browser["Browser (HTTP Request)"]:::client
    FlaskApp["Flask Application"]:::flask

    Browser -->|"HTTPRequest"| FlaskApp

    subgraph "Blueprints"
        Admin["Admin Module"]:::module
        API["API Module"]:::module
        Creator["Creator Module"]:::module
        Main["Main Module"]:::module
    end

    FlaskApp -->|"DispatchesTo"| Admin
    FlaskApp -->|"DispatchesTo"| API
    FlaskApp -->|"DispatchesTo"| Creator
    FlaskApp -->|"DispatchesTo"| Main

    Models["Models"]:::service
    Extensions["Extensions"]:::service
    SQLite["SQLite Database"]:::database

    FlaskApp -->|"Initializes"| Models
    FlaskApp -->|"Initializes"| Extensions
    Models -->|"MapsTo"| SQLite
    Extensions -->|"ConnectsTo"| SQLite

    Static["Static Assets"]:::static
    Templates["Templates"]:::templates

    FlaskApp -->|"Serves"| Static
    FlaskApp -->|"Renders"| Templates

    Media["Media Storage"]:::storage
    FlaskApp -->|"ProvidesMedia"| Media

    API_DOC["API Documentation"]:::external
    FlaskApp -->|"Exposes"| API_DOC

    click FlaskApp "https://github.com/salmanulfaris/iitm-mad-1-music-app/blob/main/app/__init__.py"
    click Admin "https://github.com/salmanulfaris/iitm-mad-1-music-app/blob/main/app/admin/__init__.py"
    click Admin "https://github.com/salmanulfaris/iitm-mad-1-music-app/blob/main/app/admin/routes.py"
    click API "https://github.com/salmanulfaris/iitm-mad-1-music-app/blob/main/app/api/__init__.py"
    click API "https://github.com/salmanulfaris/iitm-mad-1-music-app/blob/main/app/api/validation.py"
    click Creator "https://github.com/salmanulfaris/iitm-mad-1-music-app/blob/main/app/creator/__init__.py"
    click Creator "https://github.com/salmanulfaris/iitm-mad-1-music-app/blob/main/app/creator/routes.py"
    click Main "https://github.com/salmanulfaris/iitm-mad-1-music-app/blob/main/app/main/__init__.py"
    click Main "https://github.com/salmanulfaris/iitm-mad-1-music-app/blob/main/app/main/routes.py"
    click Models "https://github.com/salmanulfaris/iitm-mad-1-music-app/blob/main/app/models.py"
    click Extensions "https://github.com/salmanulfaris/iitm-mad-1-music-app/blob/main/app/extensions.py"
    click Static "https://github.com/salmanulfaris/iitm-mad-1-music-app/tree/main/app/static"
    click Templates "https://github.com/salmanulfaris/iitm-mad-1-music-app/tree/main/app/templates"
    click Media "https://github.com/salmanulfaris/iitm-mad-1-music-app/tree/main/app/storage"

    classDef client fill:#A2CEE3,stroke:#333,stroke-width:2px;
    classDef flask fill:#C2E699,stroke:#333,stroke-width:2px;
    classDef module fill:#F3B0C3,stroke:#333,stroke-width:2px;
    classDef service fill:#E2D1F9,stroke:#333,stroke-width:2px;
    classDef database fill:#F9D5E5,stroke:#333,stroke-width:2px;
    classDef static fill:#FFD700,stroke:#333,stroke-width:2px;
    classDef templates fill:#90EE90,stroke:#333,stroke-width:2px;
    classDef storage fill:#FFA07A,stroke:#333,stroke-width:2px;
    classDef external fill:#ADD8E6,stroke:#333,stroke-width:2px;
```
