Skip to content

nitindavegit/BeatSphere

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🎡 Beatsphere

Beatsphere Logo

A modern music streaming application built with Flutter and FastAPI

Flutter FastAPI License PRs Welcome

πŸ“– Table of Contents

🎯 Overview

Beatsphere is a full-stack music streaming application that provides users with a seamless music listening experience. Built with Flutter for the mobile client and FastAPI for the backend, it offers features like music upload, playlist management, favorites, and high-quality audio playback with visual waveforms.

The application follows modern software architecture principles with clean separation of concerns, state management using Riverpod, and a RESTful API design.

✨ Features

🎧 Core Music Features

  • Music Streaming: High-quality audio playback with background support
  • Audio Visualization: Real-time waveform display during playback
  • Music Controls: Play, pause, skip, shuffle, and repeat functionality
  • Background Playback: Continue listening while using other apps

πŸ“± User Experience

  • User Authentication: Secure signup and login system
  • Personal Library: Organize and manage your music collection
  • Favorites System: Mark and access your favorite songs easily
  • Music Upload: Upload your own music files to the platform
  • Responsive UI: Beautiful Material Design interface

πŸ”§ Technical Features

  • Offline Storage: Local caching using Hive database
  • Cloud Storage: Media files stored securely on Cloudinary
  • JWT Authentication: Secure token-based authentication
  • Cross-Platform: Runs on Android and iOS devices

πŸ“± Screenshots

Sign In Screen Sign Up Screen Song Library
Music Player Upload Song

Experience the beautiful and intuitive interface of Beatsphere

πŸ—οΈ Architecture

Beatsphere follows a client-server architecture with clear separation of concerns:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    HTTP/REST API    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                 │◄──────────────────►│                 β”‚
β”‚  Flutter Client β”‚                    β”‚  FastAPI Server β”‚
β”‚                 β”‚                    β”‚                 β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                                       β”‚
         β–Ό                                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Local Storage  β”‚                    β”‚    Database     β”‚
β”‚ (Hive + SharedPrefs) β”‚                β”‚   (SQLAlchemy)  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                                                β”‚
                                                β–Ό
                                       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
                                       β”‚   Cloudinary    β”‚
                                       β”‚ (Media Storage) β”‚
                                       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Client Architecture (Flutter)

  • Presentation Layer: UI components and pages
  • Business Logic: ViewModels using Riverpod
  • Data Layer: Repositories for API and local storage
  • Models: Data models and DTOs

Server Architecture (FastAPI)

  • API Layer: FastAPI routes and endpoints
  • Business Logic: Service layer (implicit)
  • Data Layer: SQLAlchemy models and database operations
  • External Services: Cloudinary integration

πŸ› οΈ Tech Stack

Frontend (Flutter Client)

Technology Purpose Version
Flutter Mobile app framework 3.8.1
Dart Programming language Latest
Riverpod State management 2.6.1
just_audio Audio playback 0.10.4
audio_waveforms Audio visualization 1.3.0
Hive Local database 2.2.3
http HTTP client 1.4.0

Backend (FastAPI Server)

Technology Purpose
FastAPI Web framework
SQLAlchemy ORM
Pydantic Data validation
JWT Authentication
bcrypt Password hashing
Cloudinary Media storage
python-dotenv Environment management

Database & Storage

  • SQLAlchemy: Relational database ORM
  • Cloudinary: Cloud media storage
  • Hive: Local mobile storage

πŸš€ Getting Started

Prerequisites

Before you begin, ensure you have the following installed:

  • Flutter SDK (3.8.1 or higher)
  • Python (3.8 or higher)
  • Git
  • Android Studio or VS Code with Flutter extensions
  • Android SDK (for Android development)
  • Xcode (for iOS development, macOS only)

Installation

  1. Clone the repository

    git clone https://github.com/yourusername/beatsphere.git
    cd beatsphere
  2. Set up the Flutter client

    cd client
    flutter pub get
    flutter pub run build_runner build
  3. Set up the FastAPI server

    cd ../server
    pip install -r requirements.txt

Configuration

Server Configuration

  1. Create environment file

    cd server
    cp .env.example .env
  2. Configure environment variables in .env

    DATABASE_URL=sqlite:///./beatsphere.db
    JWT_SECRET_KEY=your-secret-key-here
    CLOUD_NAME=your-cloudinary-cloud-name
    API_KEY=your-cloudinary-api-key
    API_SECRET=your-cloudinary-api-secret

Client Configuration

  1. Update server URL in client/lib/core/constants/server_constants.dart
    class ServerConstants {
      static const String serverURL = "http://your-server-url:8000";
    }

Running the Application

  1. Start the FastAPI server

    cd server
    uvicorn main:app --reload --host 0.0.0.0 --port 8000
  2. Run the Flutter app

    cd client
    flutter run

The server will be available at http://localhost:8000 and the API documentation at http://localhost:8000/docs.

πŸ“š API Documentation

Authentication Endpoints

Method Endpoint Description
POST /auth/signup Register a new user
POST /auth/login User login
GET /auth/ Get current user data

Song Endpoints

Method Endpoint Description
POST /song/upload Upload a new song
GET /song/list Get all songs
POST /song/favourite Toggle song favorite
GET /song/list/favourites Get user's favorite songs

Example API Usage

User Registration:

curl -X POST "http://localhost:8000/auth/signup" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "John Doe",
    "email": "john@example.com",
    "password": "securepassword"
  }'

Upload Song:

curl -X POST "http://localhost:8000/song/upload" \
  -H "Authorization: Bearer YOUR_JWT_TOKEN" \
  -F "song=@path/to/song.mp3" \
  -F "thumbnail=@path/to/thumbnail.jpg" \
  -F "artist=Artist Name" \
  -F "song_name=Song Title" \
  -F "hex_code=FF5733"

For complete API documentation, visit http://localhost:8000/docs when the server is running.

πŸ“ Project Structure

beatsphere/
β”œβ”€β”€ client/                          # Flutter mobile application
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”œβ”€β”€ core/                   # Core utilities and shared code
β”‚   β”‚   β”‚   β”œβ”€β”€ constants/          # App constants
β”‚   β”‚   β”‚   β”œβ”€β”€ failure/           # Error handling
β”‚   β”‚   β”‚   β”œβ”€β”€ models/            # Core data models
β”‚   β”‚   β”‚   β”œβ”€β”€ provider/          # Global state providers
β”‚   β”‚   β”‚   β”œβ”€β”€ theme/             # App theming
β”‚   β”‚   β”‚   └── widgets/           # Reusable widgets
β”‚   β”‚   β”œβ”€β”€ features/              # Feature-based modules
β”‚   β”‚   β”‚   β”œβ”€β”€ auth/              # Authentication feature
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ model/         # Auth models
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ repositories/  # Data repositories
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ view/          # UI components
β”‚   β”‚   β”‚   β”‚   └── viewmodel/     # Business logic
β”‚   β”‚   β”‚   └── home/              # Home/Music feature
β”‚   β”‚   β”‚       β”œβ”€β”€ models/        # Music models
β”‚   β”‚   β”‚       β”œβ”€β”€ repository/    # Music repositories
β”‚   β”‚   β”‚       β”œβ”€β”€ view/          # Music UI components
β”‚   β”‚   β”‚       └── viewmodel/     # Music business logic
β”‚   β”‚   └── main.dart              # App entry point
β”‚   β”œβ”€β”€ assets/                    # Static assets
β”‚   β”‚   └── images/               # Image assets
β”‚   β”œβ”€β”€ android/                  # Android-specific code
β”‚   β”œβ”€β”€ ios/                      # iOS-specific code
β”‚   └── pubspec.yaml             # Flutter dependencies
β”œβ”€β”€ server/                       # FastAPI backend server
β”‚   β”œβ”€β”€ models/                   # SQLAlchemy database models
β”‚   β”‚   β”œβ”€β”€ base.py              # Base model class
β”‚   β”‚   β”œβ”€β”€ user.py              # User model
β”‚   β”‚   β”œβ”€β”€ song.py              # Song model
β”‚   β”‚   └── favourites.py        # Favorites model
β”‚   β”œβ”€β”€ routes/                   # API route handlers
β”‚   β”‚   β”œβ”€β”€ auth.py              # Authentication routes
β”‚   β”‚   └── song.py              # Song management routes
β”‚   β”œβ”€β”€ pydantic_schemas/         # Request/response schemas
β”‚   β”‚   β”œβ”€β”€ user_create.py       # User creation schema
β”‚   β”‚   β”œβ”€β”€ user_login.py        # User login schema
β”‚   β”‚   └── favourite_song.py    # Favorite song schema
β”‚   β”œβ”€β”€ middleware/               # Custom middleware
β”‚   β”‚   └── auth_middleware.py   # JWT authentication middleware
β”‚   β”œβ”€β”€ database.py              # Database configuration
β”‚   └── main.py                  # FastAPI app entry point
└── README.md                    # Project documentation

πŸ’‘ Usage

For Users

  1. Sign Up: Create a new account with your email and password
  2. Browse Music: Explore the available songs in the library
  3. Play Music: Tap on any song to start playback
  4. Manage Favorites: Heart songs to add them to your favorites
  5. Upload Music: Share your own music by uploading audio files
  6. Control Playback: Use the music player controls for full playback control

For Developers

Adding New Features

  1. Client-side: Create new features in the client/lib/features/ directory
  2. Server-side: Add new routes in the server/routes/ directory
  3. Database: Define new models in the server/models/ directory

State Management

The app uses Riverpod for state management. Key providers:

API Integration

HTTP requests are handled through repository classes:

  • AuthRemoteRepository - Authentication API calls
  • Music repository classes for song-related API calls

🀝 Contributing

We welcome contributions to Beatsphere! Please follow these steps:

  1. Fork the repository
  2. Create a feature branch
    git checkout -b feature/amazing-feature
  3. Make your changes
  4. Add tests (if applicable)
  5. Commit your changes
    git commit -m 'Add some amazing feature'
  6. Push to the branch
    git push origin feature/amazing-feature
  7. Open a Pull Request

Development Guidelines

  • Follow Flutter and Dart style guidelines
  • Use meaningful commit messages
  • Add documentation for new features
  • Ensure all tests pass
  • Update the README if needed

Code Style

  • Flutter: Follow the official Dart style guide
  • Python: Follow PEP 8 style guidelines
  • Use meaningful variable and function names
  • Add comments for complex logic

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ“ž Contact

Project Maintainer: Nitin Dave

Project Link: (https://github.com/nitindavegit/beatsphere)


Made with ❀️ by the Beatsphere team

⭐ Star this repo if you found it helpful!

About

Modern cross-platform music streaming app built with Flutter & FastAPI, featuring high-quality playback, playlists, and Cloud storage.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors