prod: UI Optimisée mise en production
- Documentation archivée et réorganisée - Backend: Ajout tests, migrations, library service, rate limiting - Frontend: Suppression Flutter, focus sur interface web HTML/JS - Tailwind CSS ajouté pour le style - Améliorations UX et corrections bugs Generated with [Claude Code](https://claude.com/claude-code) via [Happy](https://happy.engineering) Co-Authored-By: Claude <noreply@anthropic.com> Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
@@ -1,326 +1,269 @@
|
||||
|
||||
# AudiOhm 🎵
|
||||
# 🎵 AudiOhm
|
||||
|
||||
Alternative à Spotify avec streaming YouTube, interface néon cyberpunk et backend auto-hébergé.
|
||||
**Alternative à Spotify avec streaming YouTube**
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||
Une application web moderne de streaming musical utilisant FastAPI (backend) et HTML/JavaScript (frontend), avec streaming audio depuis YouTube.
|
||||
|
||||
## 🎯 Fonctionnalités
|
||||
---
|
||||
|
||||
### ✅ Implémenté
|
||||
## 🚀 Démarrage Rapide
|
||||
|
||||
**Backend FastAPI :**
|
||||
- ✅ Authentification JWT complète (register, login, refresh, logout)
|
||||
- ✅ Recherche multi-source (database + YouTube via yt-dlp)
|
||||
- ✅ Streaming audio avec support HTTP Range
|
||||
- ✅ CRUD Playlists complet (create, read, update, delete)
|
||||
- ✅ Gestion des tracks dans playlists (add, remove, reorder)
|
||||
- ✅ Recommandations basées sur YouTube related videos
|
||||
### Prérequis
|
||||
|
||||
**Frontend Flutter :**
|
||||
- ✅ Thème néon cyberpunk complet avec effets glow
|
||||
- ✅ Layout adaptatif (Desktop sidebar + Mobile bottom nav)
|
||||
- ✅ Mini player avec contrôles réactifs
|
||||
- ✅ Navigation instantanée (< 100ms)
|
||||
- ✅ Image caching progressif
|
||||
- ✅ State management avec Riverpod
|
||||
- Python 3.13+
|
||||
- PostgreSQL 14+
|
||||
- pip et venv
|
||||
|
||||
**Base de données :**
|
||||
- ✅ 6 modèles SQLAlchemy (User, Artist, Album, Track, Playlist, PlaylistTrack)
|
||||
- ✅ Relations et indexes optimisés
|
||||
- ✅ Support async complet
|
||||
### Installation
|
||||
|
||||
### 🚧 À venir
|
||||
```bash
|
||||
# Cloner le repository
|
||||
git clone https://github.com/votre-username/audiOhm.git
|
||||
cd audiOhm
|
||||
|
||||
- Import de playlists Spotify
|
||||
- Mode offline avec cache local
|
||||
- Recommandations avancées (Last.fm)
|
||||
- Système de likes (bibliothèque)
|
||||
- Mode collaboratif playlists
|
||||
- Historique d'écoute
|
||||
- UI pages (Search, Library, Settings)
|
||||
# Installer les dépendances backend
|
||||
cd backend
|
||||
python -m venv venv
|
||||
source venv/bin/activate # Windows: venv\Scripts\activate
|
||||
pip install -r requirements.txt
|
||||
|
||||
# Configurer la base de données
|
||||
cp .env.example .env
|
||||
# Éditer .env avec vos paramètres de base de données
|
||||
|
||||
# Lancer les migrations
|
||||
alembic upgrade head
|
||||
|
||||
# Créer un utilisateur admin
|
||||
python -c "from app.db import Session; from app.models.user import User; from app.core.security import hash_password; db = Session(); admin = User(email='admin@example.com', username='admin', password_hash=hash_password('admin123')); db.add(admin); db.commit(); print('Admin créé!')"
|
||||
|
||||
# Démarrer le serveur
|
||||
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
|
||||
```
|
||||
|
||||
### Accès
|
||||
|
||||
- **Application**: http://localhost:8000
|
||||
- **Admin par défaut**:
|
||||
- Email: `admin@example.com`
|
||||
- Password: `admin123`
|
||||
|
||||
---
|
||||
|
||||
## 📁 Structure du Projet
|
||||
|
||||
```
|
||||
spotify-le-2/
|
||||
├── backend/ # FastAPI backend
|
||||
audiOhm/
|
||||
├── backend/ # API FastAPI
|
||||
│ ├── app/
|
||||
│ │ ├── api/v1/ # Routes (auth, music, playlists)
|
||||
│ │ ├── core/ # Config, security, database
|
||||
│ │ ├── models/ # SQLAlchemy models
|
||||
│ │ ├── schemas/ # Pydantic schemas
|
||||
│ │ └── services/ # Business logic
|
||||
│ ├── requirements.txt
|
||||
│ └── .env.example
|
||||
│
|
||||
├── frontend/ # Flutter app
|
||||
│ ├── lib/
|
||||
│ │ ├── core/theme/ # Neon cyberpunk theme
|
||||
│ │ ├── domain/ # Entities
|
||||
│ │ ├── infrastructure/ # API client
|
||||
│ │ └── presentation/ # UI, providers
|
||||
│ └── pubspec.yaml
|
||||
│
|
||||
├── docker/
|
||||
│ └── docker-compose.yml # PostgreSQL + Redis
|
||||
│
|
||||
├── docs/
|
||||
│ ├── design-preview.html # Preview du thème
|
||||
│ └── plans/ # Design document
|
||||
│
|
||||
└── README.md
|
||||
│ │ ├── api/ # Routes API
|
||||
│ │ ├── core/ # Configuration, sécurité
|
||||
│ │ ├── models/ # Modèles de base de données
|
||||
│ │ ├── schemas/ # Schémas Pydantic
|
||||
│ │ ├── services/ # Logique métier
|
||||
│ │ └── static/ # Frontend (HTML, CSS, JS)
|
||||
│ ├── alembic/ # Migrations DB
|
||||
│ ├── logs/ # Logs applicatifs
|
||||
│ └── storage/ # Stockage local
|
||||
├── design-system-v2/ # Documentation design system
|
||||
├── docs/ # Documentation technique
|
||||
├── docker/ # Configuration Docker
|
||||
└── builds/ # Builds web
|
||||
```
|
||||
|
||||
## 🚀 Installation
|
||||
|
||||
📖 **Pour un démarrage rapide en mode Web, voir [QUICKSTART_WEB.md](QUICKSTART_WEB.md)**
|
||||
|
||||
### Prérequis
|
||||
|
||||
**Backend :**
|
||||
- Python 3.11+
|
||||
- PostgreSQL 15+
|
||||
- Redis 7+
|
||||
- FFmpeg
|
||||
- yt-dlp
|
||||
|
||||
**Frontend :**
|
||||
- Flutter 3.2+
|
||||
- Dart 3.2+
|
||||
- Android Studio / VS Code
|
||||
|
||||
### 1. Cloner le projet
|
||||
|
||||
```bash
|
||||
git clone <repo-url>
|
||||
cd Spotify_le_2
|
||||
```
|
||||
|
||||
### 2. Lancer l'infrastructure (Docker)
|
||||
|
||||
```bash
|
||||
cd docker
|
||||
docker-compose up -d
|
||||
```
|
||||
|
||||
### 3. Setup Backend
|
||||
|
||||
```bash
|
||||
cd backend
|
||||
|
||||
# Créer venv
|
||||
python -m venv venv
|
||||
venv\Scripts\activate # Windows
|
||||
source venv/bin/activate # Linux/Mac
|
||||
|
||||
# Installer dépendances
|
||||
pip install -r requirements.txt
|
||||
|
||||
# Configurer environnement
|
||||
cp .env.example .env
|
||||
# Éditer .env (changer SECRET_KEY!)
|
||||
|
||||
# Initialiser DB
|
||||
python -c "from app.core.database import init_db; import asyncio; asyncio.run(init_db())"
|
||||
|
||||
# Lancer serveur
|
||||
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000
|
||||
```
|
||||
|
||||
API disponible sur http://localhost:8000
|
||||
|
||||
### 5. Builder l'Application (Android/Windows)
|
||||
|
||||
**IMPORTANT:** Lire le guide de build complet:
|
||||
- 📖 **[BUILD_STATUS.md](BUILD_STATUS.md)** - Status détaillé et solutions aux problèmes
|
||||
- 🚀 **[QUICKSTART_BUILDS.md](QUICKSTART_BUILDS.md)** - Guide de build rapide
|
||||
|
||||
**Résumé rapide:**
|
||||
|
||||
| Plateforme | Status | Instructions |
|
||||
|-----------|--------|--------------|
|
||||
| **Android APK** | ⚠️ Nécessite Android SDK | Voir [BUILD_STATUS.md](BUILD_STATUS.md) |
|
||||
| **Windows EXE** | ⚠️ Requiert Windows host | Builder sur Windows avec `flutter build windows --release` |
|
||||
| **Web** | ⚠️ Problème audio | `flutter run -d chrome` pour dev uniquement |
|
||||
|
||||
Pour tester l'application **sans build**, utiliser:
|
||||
```bash
|
||||
cd frontend
|
||||
flutter run -d chrome
|
||||
```
|
||||
|
||||
### 4. Setup Frontend
|
||||
|
||||
```bash
|
||||
cd frontend
|
||||
|
||||
# Installer dépendances
|
||||
flutter pub get
|
||||
|
||||
# Activer le support Web (recommandé pour le debug)
|
||||
flutter config --enable-web
|
||||
flutter create --platforms=web .
|
||||
|
||||
# Lancer app
|
||||
flutter run -d chrome # Web (recommandé pour debug)
|
||||
flutter run -d windows # Desktop Windows
|
||||
flutter run -d android # Android
|
||||
```
|
||||
|
||||
**🌐 Mode Web (recommandé pour le développement/debug)**
|
||||
|
||||
L'application web s'ouvrira automatiquement à : `http://localhost:8080`
|
||||
|
||||
Avantages du mode Web :
|
||||
- ✅ Pas besoin de Visual Studio
|
||||
- ✅ Débugage dans le navigateur (Chrome DevTools)
|
||||
- ✅ Hot reload instantané
|
||||
- ✅ Fonctionne sur toutes les plateformes
|
||||
|
||||
### 5. Créer un exécutable (.exe)
|
||||
|
||||
**Windows :**
|
||||
```cmd
|
||||
# Double-cliquez sur:
|
||||
BUILD_CLIENT_WINDOWS.bat
|
||||
|
||||
# Ou manuellement:
|
||||
cd frontend
|
||||
flutter build windows --release
|
||||
# Exécutable dans: build\windows\x64\runner\Release\
|
||||
```
|
||||
|
||||
**Linux :**
|
||||
```bash
|
||||
./BUILD_CLIENT_LINUX.sh
|
||||
```
|
||||
|
||||
📖 **Voir `BUILD_CLIENT_README.md` pour les instructions détaillées**
|
||||
|
||||
## 🎨 Design
|
||||
|
||||
Le thème **Néon Cyberpunk** est visible dans `docs/design-preview.html`.
|
||||
|
||||
**Couleurs principales :**
|
||||
- Background: `#0A0E27` (bleu nuit très foncé)
|
||||
- Primary: `#00F0FF` (cyan électrique néon)
|
||||
- Secondary: `#BF00FF` (violet néon)
|
||||
- Accent: `#FF006E` (rose néon)
|
||||
|
||||
## 📡 API Endpoints
|
||||
|
||||
### Authentification
|
||||
|
||||
```
|
||||
POST /api/v1/auth/register - Créer compte
|
||||
POST /api/v1/auth/login - Se connecter
|
||||
POST /api/v1/auth/refresh - Rafraîchir token
|
||||
GET /api/v1/auth/me - Profil utilisateur
|
||||
PUT /api/v1/auth/me - Modifier profil
|
||||
POST /api/v1/auth/logout - Se déconnecter
|
||||
```
|
||||
|
||||
### Musique
|
||||
|
||||
```
|
||||
GET /api/v1/music/search - Rechercher (DB + YouTube)
|
||||
GET /api/v1/music/tracks/{id} - Détails track
|
||||
GET /api/v1/music/tracks/{id}/stream - Stream audio
|
||||
POST /api/v1/music/tracks/from-youtube - Créer track YouTube
|
||||
GET /api/v1/music/tracks/{id}/recommendations - Recommandations
|
||||
GET /api/v1/music/trending - Trending tracks
|
||||
```
|
||||
|
||||
### Playlists
|
||||
|
||||
```
|
||||
GET /api/v1/playlists - Lister playlists
|
||||
POST /api/v1/playlists - Créer playlist
|
||||
GET /api/v1/playlists/{id} - Détails playlist
|
||||
PUT /api/v1/playlists/{id} - Modifier playlist
|
||||
DELETE /api/v1/playlists/{id} - Supprimer playlist
|
||||
POST /api/v1/playlists/{id}/tracks - Ajouter tracks
|
||||
DELETE /api/v1/playlists/{id}/tracks/{track_id} - Retirer track
|
||||
PUT /api/v1/playlists/{id}/tracks/reorder - Réordonner
|
||||
```
|
||||
|
||||
## 🔧 Configuration
|
||||
|
||||
### Backend (.env)
|
||||
|
||||
```env
|
||||
# Application
|
||||
DEBUG=true
|
||||
SECRET_KEY=change-this-to-a-strong-random-key
|
||||
|
||||
# Database
|
||||
POSTGRES_HOST=localhost
|
||||
POSTGRES_PORT=5432
|
||||
POSTGRES_USER=spotify
|
||||
POSTGRES_PASSWORD=your_password
|
||||
POSTGRES_DB=spotify_le_2
|
||||
|
||||
# Redis
|
||||
REDIS_HOST=localhost
|
||||
REDIS_PORT=6379
|
||||
```
|
||||
|
||||
### Frontend
|
||||
|
||||
```dart
|
||||
// lib/core/constants/api_constants.dart
|
||||
const String baseUrl = 'http://localhost:8000/api/v1';
|
||||
```
|
||||
|
||||
## 📊 Stack Technique
|
||||
|
||||
| Composant | Technologie |
|
||||
|-----------|------------|
|
||||
| **Backend** | Python + FastAPI |
|
||||
| **Base de données** | PostgreSQL 15+ |
|
||||
| **Cache** | Redis 7+ |
|
||||
| **Streaming** | yt-dlp + FFmpeg |
|
||||
| **Frontend** | Flutter 3.2+ |
|
||||
| **State Management** | Riverpod |
|
||||
| **Audio** | just_audio |
|
||||
| **ORM** | SQLAlchemy 2.0 (async) |
|
||||
|
||||
## 🛠️ Développement
|
||||
|
||||
### Backend
|
||||
|
||||
```bash
|
||||
# Linter
|
||||
ruff check app/
|
||||
|
||||
# Formatter
|
||||
black app/
|
||||
|
||||
# Tests
|
||||
pytest
|
||||
```
|
||||
|
||||
### Frontend
|
||||
|
||||
```bash
|
||||
# Formatter
|
||||
flutter format .
|
||||
|
||||
# Linter
|
||||
flutter analyze
|
||||
|
||||
# Tests
|
||||
flutter test
|
||||
```
|
||||
|
||||
## 📝 License
|
||||
|
||||
MIT
|
||||
|
||||
---
|
||||
|
||||
**Projet développé avec 💜 pour remplacer Spotify**
|
||||
## ✨ Fonctionnalités
|
||||
|
||||
### 🎧 Player Audio
|
||||
- Lecture, pause, précédent, suivant
|
||||
- Barre de progression cliquable
|
||||
- Contrôle du volume avec mute
|
||||
- Shuffle et repeat
|
||||
- Affichage des métadonnées (titre, artist, pochette)
|
||||
|
||||
### 📚 Bibliothèque
|
||||
- **Playlists**: Création, modification, suppression
|
||||
- **Titres likés**: Gestion des favoris
|
||||
- **Historique**: Tracking des écoutes
|
||||
- **Statistiques**: Compteurs d'écoute
|
||||
|
||||
### 🔍 Recherche
|
||||
- Recherche YouTube intégrée
|
||||
- Lecture instantanée depuis les résultats
|
||||
- Ajout à la file d'attente
|
||||
|
||||
### 📋 Queue de Lecture
|
||||
- File d'attente dynamique
|
||||
- Shuffle
|
||||
- Réorganisation
|
||||
- Persistance locale
|
||||
|
||||
### 👤 Comptes
|
||||
- Authentification JWT
|
||||
- Gestion utilisateur
|
||||
- Données persistantes
|
||||
|
||||
---
|
||||
|
||||
## 🔧 Configuration
|
||||
|
||||
### Variables d'Environnement
|
||||
|
||||
```bash
|
||||
# .env
|
||||
DATABASE_URL=postgresql://user:password@localhost/audiOhm
|
||||
SECRET_KEY=votre_clé_secrète_ici
|
||||
ALGORITHM=HS256
|
||||
ACCESS_TOKEN_EXPIRE_MINUTES=30
|
||||
```
|
||||
|
||||
### Base de Données
|
||||
|
||||
```bash
|
||||
# Lancer les migrations
|
||||
alembic upgrade head
|
||||
|
||||
# Créer une nouvelle migration
|
||||
alembic revision --autogenerate -m "description"
|
||||
|
||||
# Downgrade
|
||||
alembic downgrade -1
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📚 API Endpoints
|
||||
|
||||
### Authentification
|
||||
- `POST /api/v1/auth/register` - Inscription
|
||||
- `POST /api/v1/auth/login` - Connexion
|
||||
- `GET /api/v1/auth/me` - Profil utilisateur
|
||||
|
||||
### Bibliothèque
|
||||
- `GET /api/v1/library/liked-tracks` - Titres likés
|
||||
- `POST /api/v1/library/liked-tracks/{track_id}` - Lik/unlike
|
||||
- `GET /api/v1/library/history` - Historique d'écoute
|
||||
- `POST /api/v1/library/history` - Ajouter à l'historique
|
||||
- `GET /api/v1/library/stats` - Statistiques
|
||||
|
||||
### Playlists
|
||||
- `GET /api/v1/playlists` - Lister les playlists
|
||||
- `POST /api/v1/playlists` - Créer une playlist
|
||||
- `GET /api/v1/playlists/{id}` - Détails playlist
|
||||
- `PUT /api/v1/playlists/{id}` - Modifier playlist
|
||||
- `DELETE /api/v1/playlists/{id}` - Supprimer playlist
|
||||
- `POST /api/v1/playlists/{id}/tracks` - Ajouter des tracks
|
||||
|
||||
### Musique
|
||||
- `GET /api/v1/music/trending` - Titres populaires
|
||||
- `GET /api/v1/music/search` - Rechercher
|
||||
- `GET /api/v1/music/youtube/{id}/stream` - Stream YouTube
|
||||
|
||||
---
|
||||
|
||||
## 🛠️ Développement
|
||||
|
||||
### Lancer en Mode Développement
|
||||
|
||||
```bash
|
||||
# Backend avec rechargement automatique
|
||||
cd backend
|
||||
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload
|
||||
|
||||
# Voir les logs
|
||||
tail -f logs/app.log
|
||||
```
|
||||
|
||||
### Tests
|
||||
|
||||
```bash
|
||||
# Tests unitaires
|
||||
pytest
|
||||
|
||||
# Tests avec couverture
|
||||
pytest --cov=app tests/
|
||||
|
||||
# Tests API
|
||||
pytest tests/api/
|
||||
```
|
||||
|
||||
### Logs
|
||||
|
||||
Les logs sont sauvegardés dans `backend/logs/`:
|
||||
- `app.log` - Logs applicatifs
|
||||
- `error.log` - Erreurs uniquement
|
||||
|
||||
---
|
||||
|
||||
## 🐛 Dépannage
|
||||
|
||||
### Problème: La musique ne joue pas
|
||||
|
||||
**Vérifier:**
|
||||
1. Que le serveur backend tourne
|
||||
2. Que vous avez un token JWT valide (connecté)
|
||||
3. Les logs du navigateur (F12 → Console)
|
||||
4. Les logs backend
|
||||
|
||||
### Problème: Erreur 500 sur l'historique
|
||||
|
||||
**Solution:** Les endpoints de bibliothèque utilisent maintenant une construction manuelle des réponses au lieu de `model_validate()`. Vérifiez que vous utilisez la dernière version du code.
|
||||
|
||||
### Problème: Fonction JavaScript non définie
|
||||
|
||||
**Solution:** Toutes les fonctions appelées depuis le HTML sont maintenant assignées à `window`. Vérifiez que le fichier `app.js` a bien été mis à jour.
|
||||
|
||||
---
|
||||
|
||||
## 📝 Changelog
|
||||
|
||||
### Version 1.0.0 (2026-01-19)
|
||||
- ✅ Application web complète
|
||||
- ✅ Player audio avec contrôles complets
|
||||
- ✅ Bibliothèque (playlists, liked, history)
|
||||
- ✅ Recherche YouTube
|
||||
- ✅ Queue de lecture
|
||||
- ✅ Authentification JWT
|
||||
- ✅ API REST complète
|
||||
|
||||
### Corrections Récentes
|
||||
- Correction des erreurs 500 sur les endpoints de bibliothèque
|
||||
- Correction des fonctions JavaScript non définies
|
||||
- Amélioration de la gestion des erreurs 401
|
||||
|
||||
---
|
||||
|
||||
## 🤝 Contribution
|
||||
|
||||
Les contributions sont les bienvenues!
|
||||
|
||||
1. Fork le projet
|
||||
2. Créer une branche (`git checkout -b feature/AmazingFeature`)
|
||||
3. Commit (`git commit -m 'Add AmazingFeature'`)
|
||||
4. Push (`git push origin feature/AmazingFeature`)
|
||||
5. Ouvrir une Pull Request
|
||||
|
||||
---
|
||||
|
||||
## 📄 Licence
|
||||
|
||||
Ce projet est sous licence MIT. Voir le fichier LICENSE pour plus de détails.
|
||||
|
||||
---
|
||||
|
||||
## 👥 Auteurs
|
||||
|
||||
- **Votre Nom** - *Initial work* - [Votre GitHub]
|
||||
|
||||
---
|
||||
|
||||
## 🙏 Remerciements
|
||||
|
||||
- FastAPI pour le framework backend excellent
|
||||
- YouTube pour l'API de streaming
|
||||
- La communauté open source
|
||||
|
||||
---
|
||||
|
||||
**Note:** Ce projet est une alternative éducative à Spotify. N'utilisez pas pour violer les droits d'auteur.
|
||||
|
||||
Reference in New Issue
Block a user