cheikhaidev-ui Claude Sonnet 4.6 commited on
Commit
9febf14
·
0 Parent(s):

chore(hf): initial orphan deploy — no image history

Browse files

Orphan branch: zero git history, no PNG blobs in the pack.
images/ excluded (screenshots only, not loaded at Streamlit runtime).
All app files copied from main at 80f3ef4.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

Files changed (10) hide show
  1. .gitignore +29 -0
  2. .streamlit/config.toml +7 -0
  3. Dockerfile +19 -0
  4. README.md +225 -0
  5. app_complete.py +845 -0
  6. init_db.py +244 -0
  7. requirements.txt +5 -0
  8. style.css +135 -0
  9. tidiane_flix.db +0 -0
  10. tidiane_flix.sql +316 -0
.gitignore ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Anciens fichiers backup
2
+ old_backup/
3
+
4
+ # Python
5
+ __pycache__/
6
+ *.pyc
7
+ *.pyo
8
+ *.egg-info/
9
+ .pytest_cache/
10
+
11
+ # Environnements virtuels
12
+ venv/
13
+ env/
14
+ .venv/
15
+
16
+ # IDEs
17
+ .vscode/
18
+ .idea/
19
+ *.swp
20
+ *.swo
21
+
22
+ # OS
23
+ .DS_Store
24
+ Thumbs.db
25
+
26
+ # Streamlit
27
+ .streamlit/secrets.toml
28
+ screenshots/
29
+ *.pdf
.streamlit/config.toml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ [theme]
2
+ base="dark"
3
+ primaryColor="#E50914"
4
+ backgroundColor="#121212"
5
+ secondaryBackgroundColor="#1F1F1F"
6
+ textColor="#FFFFFF"
7
+ font="sans serif"
Dockerfile ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ WORKDIR /app
4
+
5
+ # Copier les fichiers nécessaires
6
+ COPY requirements.txt .
7
+ COPY app_complete.py .
8
+ COPY tidiane_flix.db .
9
+ COPY style.css .
10
+ COPY .streamlit ./.streamlit
11
+
12
+ # Installer les dépendances
13
+ RUN pip install --no-cache-dir -r requirements.txt
14
+
15
+ # Exposer le port
16
+ EXPOSE 8501
17
+
18
+ # Lancer l'application
19
+ CMD ["streamlit", "run", "app_complete.py", "--server.port=8501", "--server.address=0.0.0.0"]
README.md ADDED
@@ -0,0 +1,225 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 🎬 CineFlow
2
+ ### Système Complet de Gestion de Cinéma avec Base de Données Relationnelle
3
+
4
+ [![Python](https://img.shields.io/badge/Python-3.9+-blue.svg)](https://www.python.org/)
5
+ [![SQL](https://img.shields.io/badge/SQL-SQLite-green.svg)](https://www.sqlite.org/)
6
+ [![Streamlit](https://img.shields.io/badge/Streamlit-1.28+-red.svg)](https://streamlit.io/)
7
+ [![License](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
8
+
9
+ ---
10
+
11
+ ## 📋 CONTEXTE & PROBLÉMATIQUE
12
+
13
+ La gestion manuelle des cinémas (réservations papier, suivi Excel, absence de statistiques temps réel) génère inefficacités et perte de revenus. Les petits et moyens cinémas en Afrique manquent de solutions abordables et adaptées à leur contexte.
14
+
15
+ **Objectif du projet :** Développer un système complet de gestion de cinéma avec base de données relationnelle robuste et interface web moderne, permettant la gestion des films, séances, réservations, clients et analyses de performance.
16
+
17
+ ---
18
+
19
+ ## 🎯 SOLUTION DÉVELOPPÉE
20
+
21
+ Application web professionnelle pour la gestion complète d'un cinéma :
22
+
23
+ ### Fonctionnalités Principales
24
+ - **Gestion du catalogue** : 15 films avec métadonnées complètes (genre, durée, réalisateur)
25
+ - **Planification des séances** : 20 projections sur 3 salles (capacité totale 350 places)
26
+ - **Système de réservation** : Interface intuitive pour vente de tickets
27
+ - **Gestion clients** : Base de 20 clients avec historique d'achats
28
+ - **Analytics avancés** : Statistiques de fréquentation, revenus, films populaires
29
+ - **Système d'avis** : Notation et commentaires clients (1-5 étoiles)
30
+
31
+ **Technologies :** SQLite + Python Streamlit + Interface responsive style Netflix
32
+
33
+ ---
34
+
35
+ ## 🗄️ ARCHITECTURE BASE DE DONNÉES
36
+
37
+ ### Modèle Relationnel (6 Tables)
38
+ ```sql
39
+ CLIENT (id_client, nom, prenom, email, telephone)
40
+ ↓
41
+ TICKET (id_ticket, prix, date_achat, id_client, id_projection)
42
+ ↓
43
+ PROJECTION (id_projection, date_projection, heure, id_film, id_salle)
44
+ ↓
45
+ FILM (id_film, titre, genre, date_sortie, duree_minutes, realisateur)
46
+ SALLE (id_salle, nom_salle, capacite)
47
+
48
+ AVIS (id_avis, note, commentaire, date_avis, id_client, id_film)
49
+ ```
50
+
51
+ ### Caractéristiques Techniques
52
+
53
+ ✅ **Normalisation complète** : 3ème forme normale (3FN)
54
+ ✅ **Intégrité référentielle** : Clés étrangères avec contraintes CASCADE
55
+ ✅ **Contraintes métier** : CHECK sur prix > 0, note entre 1-5, capacité > 0
56
+ ✅ **Index optimisés** : Performance garantie sur les jointures
57
+
58
+ ### Données de Production
59
+
60
+ - **20 clients** enregistrés avec coordonnées complètes
61
+ - **15 films** (Inception, Titanic, Avengers, Interstellar, Matrix, etc.)
62
+ - **3 salles** (120, 80, 150 places)
63
+ - **20 projections** planifiées sur 10 jours
64
+ - **30 tickets** vendus (revenus : 103 000 FCFA)
65
+ - **10 avis clients** avec notes et commentaires
66
+
67
+ ---
68
+
69
+ ## 💻 STACK TECHNIQUE
70
+
71
+ **Base de Données**
72
+ - `SQLite` : Base de données relationnelle légère et portable
73
+ - `SQLAlchemy` : ORM Python pour requêtes sécurisées
74
+
75
+ **Backend & Logique**
76
+ - `Python 3.9+` : Logique métier et traitement des données
77
+ - `Pandas` : Manipulation et agrégation de données
78
+
79
+ **Frontend & Visualisation**
80
+ - `Streamlit` : Interface web interactive responsive
81
+ - `Plotly` : Graphiques interactifs (camemberts, barres, courbes)
82
+ - `CSS personnalisé` : Design Netflix-inspired
83
+
84
+ **Déploiement**
85
+ - `Docker` : Conteneurisation pour portabilité
86
+ - Compatible Hugging Face Spaces et autres plateformes
87
+
88
+ ---
89
+
90
+ ## 📊 REQUÊTES SQL COMPLEXES IMPLÉMENTÉES
91
+
92
+ ### Exemples de Requêtes Métier
93
+
94
+ **1. Top 5 des films les plus rentables :**
95
+ ```sql
96
+ SELECT f.titre, COUNT(t.id_ticket) as nb_tickets, SUM(t.prix) as revenus
97
+ FROM film f
98
+ JOIN projection p ON f.id_film = p.id_film
99
+ JOIN ticket t ON p.id_projection = t.id_projection
100
+ GROUP BY f.id_film
101
+ ORDER BY revenus DESC
102
+ LIMIT 5;
103
+ ```
104
+
105
+ **2. Taux de remplissage par salle :**
106
+ ```sql
107
+ SELECT s.nom_salle, s.capacite,
108
+ COUNT(t.id_ticket) as tickets_vendus,
109
+ ROUND(COUNT(t.id_ticket) * 100.0 / s.capacite, 2) as taux_remplissage
110
+ FROM salle s
111
+ JOIN projection p ON s.id_salle = p.id_salle
112
+ LEFT JOIN ticket t ON p.id_projection = t.id_projection
113
+ GROUP BY s.id_salle;
114
+ ```
115
+
116
+ **3. Clients les plus fidèles (avec total dépensé) :**
117
+ ```sql
118
+ SELECT c.nom, c.prenom,
119
+ COUNT(t.id_ticket) as nb_reservations,
120
+ SUM(t.prix) as total_depense
121
+ FROM client c
122
+ JOIN ticket t ON c.id_client = t.id_client
123
+ GROUP BY c.id_client
124
+ ORDER BY total_depense DESC
125
+ LIMIT 10;
126
+ ```
127
+
128
+ ---
129
+
130
+ ## 🚀 INSTALLATION & UTILISATION
131
+
132
+ ### Prérequis
133
+ ```bash
134
+ Python 3.9+
135
+ pip
136
+ ```
137
+
138
+ ### Installation
139
+ ```bash
140
+ # Cloner le repo
141
+ git clone https://github.com/chniang/TIDIANE_FLIX.git
142
+ cd TIDIANE_FLIX
143
+
144
+ # Installer les dépendances
145
+ pip install -r requirements.txt
146
+
147
+ # Lancer l'application
148
+ streamlit run app_complete.py
149
+ ```
150
+
151
+ ### Utilisation
152
+ 1. **Page d'accueil** : Landing page avec statistiques du cinéma
153
+ 2. **Catalogue** : Consulter les films disponibles
154
+ 3. **Réservations** : Acheter des tickets pour les séances
155
+ 4. **Analytics** : Visualiser statistiques de fréquentation et revenus
156
+ 5. **Gestion** : CRUD complet sur clients, films, séances
157
+
158
+ ---
159
+
160
+ ## 📸 APERÇU
161
+
162
+ ### Landing Page
163
+ ![Landing](images/landing.png)
164
+
165
+ ### Tableau de Bord
166
+ ![Dashboard](images/dashbord.png)
167
+
168
+ ### Analytics & Statistiques
169
+ ![Analytics](images/analytics.png)
170
+
171
+ ### Machine Learning Insights
172
+ ![ML](images/machine_learning.png)
173
+
174
+ ---
175
+
176
+ ## 🎯 RÉSULTATS & INSIGHTS MÉTIER
177
+
178
+ ✅ **Architecture scalable** : Peut gérer 1000+ films et 10 000+ clients
179
+ ✅ **Performance optimisée** : Temps de réponse <500ms sur toutes les requêtes
180
+ ✅ **Interface responsive** : Fonctionne sur desktop, tablette et mobile
181
+ ✅ **Modèle réplicable** : Adaptable à d'autres cinémas ou salles de spectacle
182
+
183
+ ### Insights Découverts (Données actuelles)
184
+
185
+ - **Film le plus populaire** : Avengers: Endgame (4 réservations, 14 500 FCFA de revenus)
186
+ - **Jour de pointe** : Vendredi (9 tickets sur 30, soit 30% des ventes)
187
+ - **Prix moyen ticket** : 3 433 FCFA
188
+ - **Taux de remplissage moyen** : 9,2% (optimisable via stratégie marketing)
189
+
190
+ ---
191
+
192
+ ## 🔮 AMÉLIORATIONS FUTURES
193
+
194
+ - [ ] API REST pour intégration mobile (React Native / Flutter)
195
+ - [ ] Système de paiement en ligne (Wave, Orange Money)
196
+ - [ ] Notifications SMS/Email pour rappels de séances
197
+ - [ ] Programme de fidélité avec points cumulables
198
+ - [ ] Recommandations personnalisées par ML (films similaires)
199
+ - [ ] Export automatique des rapports financiers (PDF/Excel)
200
+ - [ ] Multi-cinéma : gestion de plusieurs sites depuis une interface
201
+
202
+ ---
203
+
204
+ ## 👨‍💻 AUTEUR
205
+
206
+ **Cheikh Niang** - Data Scientist Junior
207
+ Spécialisé en bases de données relationnelles et applications web data-driven.
208
+
209
+ 📧 cheikhniang159@gmail.com
210
+ 💼 [LinkedIn](https://www.linkedin.com/in/cheikh-niang-5370091b5/)
211
+ 🌐 [Portfolio](https://portfolio-cheikh-niang.vercel.app/)
212
+
213
+ ---
214
+
215
+ ## 📄 LICENCE
216
+
217
+ Ce projet est sous licence MIT. Voir le fichier `LICENSE` pour plus de détails.
218
+
219
+ ---
220
+
221
+ ## 🙏 REMERCIEMENTS
222
+
223
+ - **GoMyCode Dakar** pour la formation en bases de données SQL
224
+ - Communauté open-source (SQLAlchemy, Streamlit, Plotly)
225
+ - Inspiré par les meilleures pratiques de conception de BD relationnelles
app_complete.py ADDED
@@ -0,0 +1,845 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import pandas as pd
3
+ from sqlalchemy import create_engine, text
4
+ import plotly.express as px
5
+ from pathlib import Path
6
+ from datetime import datetime
7
+ import re
8
+ import sqlite3
9
+
10
+ # -------------------------
11
+ # CONFIGURATION
12
+ # -------------------------
13
+
14
+ st.set_page_config(
15
+ page_title="CineFlow",
16
+ page_icon="🎬",
17
+ layout="wide",
18
+ initial_sidebar_state="collapsed"
19
+ )
20
+
21
+ # -------------------------
22
+ # RESPONSIVE CSS
23
+ # -------------------------
24
+ def load_css():
25
+ """Charge le CSS responsive"""
26
+ try:
27
+ with open('style.css') as f:
28
+ st.markdown(f'<style>{f.read()}</style>', unsafe_allow_html=True)
29
+ except FileNotFoundError:
30
+ pass
31
+
32
+ # Charger CSS
33
+ load_css()
34
+
35
+ # Initialiser le state pour la navigation
36
+ if 'show_landing' not in st.session_state:
37
+ st.session_state.show_landing = True
38
+
39
+ # Utiliser SQLite
40
+ DB_PATH = Path(__file__).parent / "tidiane_flix.db"
41
+ SQLALCHEMY_URL = f"sqlite:///{DB_PATH}"
42
+
43
+ # -------------------------
44
+ # UTILITAIRES DB
45
+ # -------------------------
46
+
47
+ @st.cache_resource
48
+ def get_engine(url=SQLALCHEMY_URL):
49
+ return create_engine(url, pool_pre_ping=True)
50
+
51
+ @st.cache_data(ttl=60)
52
+ def run_query(query, params=None):
53
+ engine = get_engine()
54
+ with engine.connect() as conn:
55
+ df = pd.read_sql(text(query), conn, params=params)
56
+ return df
57
+
58
+ _ALLOWED_TABLES = {"client", "film", "salle", "projection", "ticket", "avis"}
59
+
60
+ @st.cache_data(ttl=60)
61
+ def get_table(table_name, limit=1000):
62
+ if table_name not in _ALLOWED_TABLES:
63
+ raise ValueError(f"Table non autorisée : {table_name!r}")
64
+ q = f"SELECT * FROM {table_name} LIMIT :limit"
65
+ return run_query(q, {'limit': limit})
66
+
67
+ def insert_ticket(prix, date_achat, id_client, id_projection):
68
+ engine = get_engine()
69
+ insert_sql = text("""
70
+ INSERT INTO ticket (prix, date_achat, id_client, id_projection)
71
+ VALUES (:prix, :date_achat, :id_client, :id_projection)
72
+ """)
73
+ with engine.begin() as conn:
74
+ res = conn.execute(insert_sql, {
75
+ 'prix': float(prix),
76
+ 'date_achat': date_achat,
77
+ 'id_client': int(id_client),
78
+ 'id_projection': int(id_projection)
79
+ })
80
+ ticket_id = res.lastrowid if hasattr(res, "lastrowid") else None
81
+ run_query.clear()
82
+ get_table.clear()
83
+ return ticket_id
84
+
85
+ # -------------------------
86
+ # LANDING PAGE
87
+ # -------------------------
88
+
89
+ def show_landing_page():
90
+ st.markdown("""
91
+ <style>
92
+ #MainMenu {visibility: hidden;}
93
+ footer {visibility: hidden;}
94
+ header {visibility: hidden;}
95
+ .stApp {background: linear-gradient(180deg, #141414 0%, #000000 100%);}
96
+
97
+ .hero {
98
+ text-align: center;
99
+ padding: 60px 20px;
100
+ background: linear-gradient(180deg, rgba(229,9,20,0.1) 0%, transparent 100%);
101
+ }
102
+ .hero-title {
103
+ font-size: 72px;
104
+ font-weight: 900;
105
+ color: #E50914;
106
+ text-shadow: 2px 2px 8px rgba(0,0,0,0.8);
107
+ margin-bottom: 20px;
108
+ }
109
+ .hero-subtitle {
110
+ font-size: 28px;
111
+ color: #ffffff;
112
+ margin-bottom: 40px;
113
+ }
114
+ .feature-card {
115
+ background: rgba(255,255,255,0.05);
116
+ border: 1px solid rgba(255,255,255,0.1);
117
+ border-radius: 12px;
118
+ padding: 40px;
119
+ margin: 20px;
120
+ text-align: center;
121
+ transition: all 0.3s;
122
+ }
123
+ .feature-card:hover {
124
+ transform: translateY(-10px);
125
+ background: rgba(255,255,255,0.08);
126
+ border-color: #E50914;
127
+ }
128
+ .custom-footer {
129
+ text-align: center;
130
+ padding: 40px;
131
+ color: #808080;
132
+ border-top: 1px solid rgba(255,255,255,0.1);
133
+ margin-top: 80px;
134
+ }
135
+
136
+ /* Responsive mobile pour la landing page */
137
+ @media screen and (max-width: 768px) {
138
+ .hero-title {
139
+ font-size: 2rem !important;
140
+ line-height: 1.2 !important;
141
+ }
142
+ .hero-subtitle {
143
+ font-size: 1.2rem !important;
144
+ line-height: 1.4 !important;
145
+ }
146
+ .hero-description {
147
+ font-size: 0.9rem !important;
148
+ padding: 0 1rem !important;
149
+ }
150
+ .cta-button {
151
+ font-size: 1rem !important;
152
+ padding: 12px 24px !important;
153
+ }
154
+ }
155
+ </style>
156
+ """, unsafe_allow_html=True)
157
+
158
+ st.markdown("""
159
+ <div class="hero">
160
+ <div class="hero-title">🎬 CINEFLOW</div>
161
+ <div class="hero-subtitle">Votre cinéma premium à Dakar</div>
162
+ <p style="color: #b3b3b3; font-size: 18px; max-width: 600px; margin: 0 auto 40px;">
163
+ Vivez une expérience cinématographique incomparable avec les derniers blockbusters,
164
+ des salles confortables et un système de réservation moderne.
165
+ </p>
166
+ </div>
167
+ """, unsafe_allow_html=True)
168
+
169
+ col1, col2, col3 = st.columns([1, 1, 1])
170
+ with col2:
171
+ if st.button("🎫 ACCÉDER AU SYSTÈME DE GESTION", key="cta", use_container_width=True, type="primary"):
172
+ st.session_state.show_landing = False
173
+ st.rerun()
174
+
175
+ st.markdown("<br><br>", unsafe_allow_html=True)
176
+ col1, col2, col3, col4 = st.columns(4)
177
+
178
+ with col1:
179
+ st.markdown("""
180
+ <div class="feature-card">
181
+ <div style="font-size: 64px;">🎥</div>
182
+ <div style="font-size: 24px; color: white; font-weight: bold; margin: 20px 0 15px;">15 Films</div>
183
+ <div style="color: #b3b3b3;">Les derniers blockbusters</div>
184
+ </div>
185
+ """, unsafe_allow_html=True)
186
+
187
+ with col2:
188
+ st.markdown("""
189
+ <div class="feature-card">
190
+ <div style="font-size: 64px;">🏟️</div>
191
+ <div style="font-size: 24px; color: white; font-weight: bold; margin: 20px 0 15px;">3 Salles</div>
192
+ <div style="color: #b3b3b3;">Équipées Dolby Atmos 4K</div>
193
+ </div>
194
+ """, unsafe_allow_html=True)
195
+
196
+ with col3:
197
+ st.markdown("""
198
+ <div class="feature-card">
199
+ <div style="font-size: 64px;">💺</div>
200
+ <div style="font-size: 24px; color: white; font-weight: bold; margin: 20px 0 15px;">350 Places</div>
201
+ <div style="color: #b3b3b3;">Sièges confortables premium</div>
202
+ </div>
203
+ """, unsafe_allow_html=True)
204
+
205
+ with col4:
206
+ st.markdown("""
207
+ <div class="feature-card">
208
+ <div style="font-size: 64px;">🎟️</div>
209
+ <div style="font-size: 24px; color: white; font-weight: bold; margin: 20px 0 15px;">Réservation</div>
210
+ <div style="color: #b3b3b3;">Billetterie moderne en ligne</div>
211
+ </div>
212
+ """, unsafe_allow_html=True)
213
+
214
+ st.markdown('<br><br><h2 style="color: white; padding-left: 20px;">🍿 Films à l\'affiche</h2>', unsafe_allow_html=True)
215
+
216
+ films = [
217
+ {"titre": "Inception", "genre": "Science-fiction", "emoji": "🌀"},
218
+ {"titre": "Avengers: Endgame", "genre": "Action", "emoji": "⚡"},
219
+ {"titre": "Titanic", "genre": "Drame", "emoji": "🚢"},
220
+ {"titre": "The Matrix", "genre": "Sci-fi", "emoji": "🔴"},
221
+ {"titre": "Joker", "genre": "Drame", "emoji": "🃏"},
222
+ {"titre": "Parasite", "genre": "Thriller", "emoji": "🎭"},
223
+ ]
224
+
225
+ cols = st.columns(3)
226
+ for idx, film in enumerate(films):
227
+ with cols[idx % 3]:
228
+ st.markdown(f"""
229
+ <div style="background: rgba(255,255,255,0.05); border-radius: 8px; padding: 20px;
230
+ margin-bottom: 20px; border: 1px solid rgba(255,255,255,0.1);">
231
+ <div style="font-size: 48px; text-align: center; margin-bottom: 10px;">{film['emoji']}</div>
232
+ <div style="color: white; font-size: 20px; font-weight: bold; text-align: center; margin-bottom: 5px;">
233
+ {film['titre']}
234
+ </div>
235
+ <div style="color: #E50914; text-align: center; font-size: 14px;">
236
+ {film['genre']}
237
+ </div>
238
+ </div>
239
+ """, unsafe_allow_html=True)
240
+
241
+ st.markdown("""
242
+ <div class="custom-footer">
243
+ <p><strong>CineFlow</strong> - Cinéma Premium Dakar</p>
244
+ <p>📍 Dakar, Sénégal | 📞 +221 77 636 27 14 | 📧 cheikhniang159@gmail.com</p>
245
+ <p style="margin-top: 20px; font-size: 14px;">
246
+ © 2025 CineFlow. Tous droits réservés.<br>
247
+ Développé avec ❤️ par Cheikh Niang
248
+ </p>
249
+ </div>
250
+ """, unsafe_allow_html=True)
251
+
252
+ # -------------------------
253
+ # APPLICATION PRINCIPALE
254
+ # -------------------------
255
+
256
+ def sidebar_navigation():
257
+ st.sidebar.title('🎬 CineFlow')
258
+ st.sidebar.markdown("---")
259
+
260
+ if st.sidebar.button("🏠 Retour à l'accueil", use_container_width=True):
261
+ st.session_state.show_landing = True
262
+ st.rerun()
263
+
264
+ st.sidebar.markdown("---")
265
+ page = st.sidebar.radio('Navigation', [
266
+ 'Analytics Avancés', 'Prédictions ML', 'Dashboard',
267
+ 'Films', 'Projections', 'Clients', 'Billets',
268
+ 'Vendre un ticket', 'SQL brut'
269
+ ])
270
+ return page
271
+
272
+ def show_header():
273
+ st.title('🎬 CineFlow — Tableau de bord')
274
+ st.write('Interface complète pour la gestion de billetterie cinéma.')
275
+
276
+ def page_dashboard():
277
+ show_header()
278
+ st.markdown('**Bienvenue** — Utilisez le menu latéral pour naviguer.')
279
+
280
+ col1, col2, col3 = st.columns(3)
281
+
282
+ try:
283
+ total_films = run_query('SELECT COUNT(*) as n FROM film').iloc[0]['n']
284
+ total_clients = run_query('SELECT COUNT(*) as n FROM client').iloc[0]['n']
285
+ total_tickets = run_query('SELECT COUNT(*) as n FROM ticket').iloc[0]['n']
286
+ except Exception as e:
287
+ st.error(f"Erreur de connexion DB: {e}")
288
+ return
289
+
290
+ col1.metric("Films", total_films, "🎥")
291
+ col2.metric("Clients", total_clients, "👥")
292
+ col3.metric("Billets vendus", total_tickets, "🎟️")
293
+
294
+ st.subheader("📅 Dernières projections")
295
+ dfp = run_query("""
296
+ SELECT p.id_projection, p.date_projection, p.heure,
297
+ f.titre, s.nom_salle
298
+ FROM projection p
299
+ JOIN film f ON p.id_film = f.id_film
300
+ JOIN salle s ON p.id_salle = s.id_salle
301
+ ORDER BY p.date_projection DESC LIMIT 10
302
+ """)
303
+ st.dataframe(dfp, use_container_width=True)
304
+
305
+ def page_films():
306
+ st.header("🎥 Films")
307
+ df = get_table("film")
308
+ st.dataframe(df, use_container_width=True)
309
+
310
+ def page_projections():
311
+ st.header("🕐 Projections")
312
+ df = run_query("""
313
+ SELECT p.id_projection, p.date_projection, p.heure,
314
+ f.titre, s.nom_salle
315
+ FROM projection p
316
+ JOIN film f ON p.id_film = f.id_film
317
+ JOIN salle s ON p.id_salle = s.id_salle
318
+ ORDER BY p.date_projection, p.heure
319
+ """)
320
+ st.dataframe(df, use_container_width=True)
321
+
322
+ st.subheader("🔍 Filtrer par film")
323
+ films = run_query("SELECT id_film, titre FROM film")
324
+ options = {row.id_film: row.titre for _, row in films.iterrows()}
325
+
326
+ film_id = st.selectbox("Choisir un film", [None] + list(options.keys()),
327
+ format_func=lambda x: options.get(x, "—") if x else "— Tous les films —")
328
+
329
+ if film_id:
330
+ df2 = run_query("SELECT * FROM projection WHERE id_film = :id", {"id": film_id})
331
+ st.subheader("Résultats filtrés")
332
+ st.dataframe(df2, use_container_width=True)
333
+
334
+ def page_sell_ticket():
335
+ st.header("💳 Vendre un ticket")
336
+
337
+ clients = run_query("SELECT id_client, nom, prenom FROM client")
338
+ clients["label"] = clients["nom"] + " " + clients["prenom"]
339
+
340
+ client_id = st.selectbox(
341
+ "Client",
342
+ [None] + clients.id_client.tolist(),
343
+ format_func=lambda x: clients.loc[clients.id_client == x, "label"].values[0]
344
+ if x else "— Sélectionner un client —"
345
+ )
346
+
347
+ projections = run_query("""
348
+ SELECT p.id_projection, p.date_projection, p.heure, f.titre
349
+ FROM projection p JOIN film f ON p.id_film = f.id_film
350
+ ORDER BY p.date_projection DESC
351
+ """)
352
+ projections["label"] = projections["titre"] + " — " + projections["date_projection"].astype(str)
353
+
354
+ proj_id = st.selectbox(
355
+ "Projection",
356
+ [None] + projections.id_projection.tolist(),
357
+ format_func=lambda x: projections.loc[projections.id_projection == x, "label"].values[0]
358
+ if x else "— Sélectionner une projection —"
359
+ )
360
+
361
+ prix = st.number_input("Prix (FCFA)", 1000.0, 100000.0, 3000.0, 500.0)
362
+ date_achat = st.date_input("Date d'achat", datetime.now().date())
363
+
364
+ if st.button("💰 Enregistrer", type="primary", use_container_width=True):
365
+ if not client_id or not proj_id:
366
+ st.error("⚠️ Veuillez sélectionner un client et une projection.")
367
+ else:
368
+ tid = insert_ticket(prix, date_achat, client_id, proj_id)
369
+ st.success(f"✅ Billet enregistré (ID: {tid})")
370
+ st.balloons()
371
+
372
+ def page_clients():
373
+ st.header("👥 Clients")
374
+ df = get_table("client")
375
+ st.dataframe(df, use_container_width=True)
376
+
377
+ def page_tickets():
378
+ st.header("🎟️ Billets")
379
+ df = run_query("""
380
+ SELECT t.id_ticket, t.prix, t.date_achat,
381
+ c.nom, c.prenom, f.titre
382
+ FROM ticket t
383
+ JOIN client c ON t.id_client = c.id_client
384
+ JOIN projection p ON t.id_projection = p.id_projection
385
+ JOIN film f ON p.id_film = f.id_film
386
+ ORDER BY t.date_achat DESC
387
+ LIMIT 500
388
+ """)
389
+ st.dataframe(df, use_container_width=True)
390
+
391
+ def page_analytics():
392
+ st.header("📊 Analytics Avancés — Insights Business")
393
+
394
+ st.info("💡 Analyse approfondie des performances et KPIs du cinéma")
395
+
396
+ # KPIs Section
397
+ st.subheader("💰 KPIs Financiers")
398
+
399
+ col1, col2, col3, col4 = st.columns(4)
400
+
401
+ revenu_total = run_query("SELECT SUM(prix) as total FROM ticket").iloc[0]['total']
402
+ col1.metric("Revenu Total", f"{revenu_total:,.0f} FCFA", "💵")
403
+
404
+ revenu_moyen = run_query("SELECT AVG(prix) as moyenne FROM ticket").iloc[0]['moyenne']
405
+ col2.metric("Prix Moyen Ticket", f"{revenu_moyen:,.0f} FCFA", "🎫")
406
+
407
+ tickets_par_client = run_query("""
408
+ SELECT COUNT(*) * 1.0 / COUNT(DISTINCT id_client) as moyenne
409
+ FROM ticket
410
+ """).iloc[0]['moyenne']
411
+ col3.metric("Tickets/Client", f"{tickets_par_client:.1f}", "👤")
412
+
413
+ occupation = run_query("""
414
+ SELECT COUNT(t.id_ticket) * 100.0 /
415
+ (COUNT(DISTINCT p.id_projection) *
416
+ (SELECT AVG(capacite) FROM salle)) as taux
417
+ FROM ticket t
418
+ JOIN projection p ON t.id_projection = p.id_projection
419
+ """).iloc[0]['taux']
420
+ col4.metric("Taux Occupation", f"{occupation:.1f}%", "🏟️")
421
+
422
+ st.markdown("---")
423
+
424
+ # Segmentation clients
425
+ st.subheader("👥 Segmentation Clients")
426
+
427
+ df_clients_seg = run_query("""
428
+ SELECT
429
+ c.id_client,
430
+ c.nom || ' ' || c.prenom as client,
431
+ COUNT(t.id_ticket) as nb_tickets,
432
+ SUM(t.prix) as total_depense,
433
+ AVG(t.prix) as prix_moyen
434
+ FROM client c
435
+ LEFT JOIN ticket t ON c.id_client = t.id_client
436
+ GROUP BY c.id_client
437
+ ORDER BY total_depense DESC
438
+ """)
439
+
440
+ def categorize_client(row):
441
+ if row['nb_tickets'] == 0:
442
+ return "Inactif"
443
+ elif row['total_depense'] >= 10000:
444
+ return "VIP 🌟"
445
+ elif row['total_depense'] >= 5000:
446
+ return "Fidèle 💎"
447
+ else:
448
+ return "Occasionnel 🎫"
449
+
450
+ df_clients_seg['Catégorie'] = df_clients_seg.apply(categorize_client, axis=1)
451
+
452
+ col1, col2 = st.columns(2)
453
+
454
+ with col1:
455
+ cat_counts = df_clients_seg['Catégorie'].value_counts()
456
+ fig_cat = px.pie(values=cat_counts.values, names=cat_counts.index,
457
+ title="Distribution des Catégories de Clients")
458
+ st.plotly_chart(fig_cat, use_container_width=True)
459
+
460
+ with col2:
461
+ st.markdown("**🏆 Top 10 Clients**")
462
+ top_clients = df_clients_seg.head(10)[['client', 'nb_tickets', 'total_depense', 'Catégorie']]
463
+ st.dataframe(top_clients, use_container_width=True, hide_index=True)
464
+
465
+ st.markdown("---")
466
+
467
+ # Analyse temporelle
468
+ st.subheader("📈 Tendances Temporelles")
469
+
470
+ df_temporal = run_query("""
471
+ SELECT
472
+ date_achat,
473
+ COUNT(*) as nb_ventes,
474
+ SUM(prix) as revenu_jour
475
+ FROM ticket
476
+ GROUP BY date_achat
477
+ ORDER BY date_achat
478
+ """)
479
+
480
+ col1, col2 = st.columns(2)
481
+
482
+ with col1:
483
+ fig_ventes = px.line(df_temporal, x='date_achat', y='nb_ventes',
484
+ title="Évolution des Ventes (nombre de tickets)",
485
+ markers=True)
486
+ st.plotly_chart(fig_ventes, use_container_width=True)
487
+
488
+ with col2:
489
+ fig_revenu = px.line(df_temporal, x='date_achat', y='revenu_jour',
490
+ title="Évolution du Revenu Journalier",
491
+ markers=True)
492
+ st.plotly_chart(fig_revenu, use_container_width=True)
493
+
494
+ st.markdown("---")
495
+
496
+ # Performance des salles
497
+ st.subheader("🏟️ Performance des Salles")
498
+
499
+ df_salles_perf = run_query("""
500
+ SELECT
501
+ s.nom_salle,
502
+ s.capacite,
503
+ COUNT(DISTINCT p.id_projection) as nb_projections,
504
+ COUNT(t.id_ticket) as tickets_vendus,
505
+ SUM(t.prix) as revenu,
506
+ ROUND(COUNT(t.id_ticket) * 100.0 /
507
+ (s.capacite * COUNT(DISTINCT p.id_projection)), 1) as taux_occupation
508
+ FROM salle s
509
+ LEFT JOIN projection p ON s.id_salle = p.id_salle
510
+ LEFT JOIN ticket t ON p.id_projection = t.id_projection
511
+ GROUP BY s.id_salle
512
+ ORDER BY revenu DESC
513
+ """)
514
+
515
+ col1, col2 = st.columns(2)
516
+
517
+ with col1:
518
+ fig_salle_revenu = px.bar(df_salles_perf, x='nom_salle', y='revenu',
519
+ title="Revenu par Salle",
520
+ text='revenu')
521
+ st.plotly_chart(fig_salle_revenu, use_container_width=True)
522
+
523
+ with col2:
524
+ fig_salle_occupation = px.bar(df_salles_perf, x='nom_salle', y='taux_occupation',
525
+ title="Taux d'Occupation par Salle (%)",
526
+ text='taux_occupation')
527
+ fig_salle_occupation.add_hline(y=70, line_dash="dash", line_color="green",
528
+ annotation_text="Objectif 70%")
529
+ st.plotly_chart(fig_salle_occupation, use_container_width=True)
530
+
531
+ st.markdown("**📋 Détails par Salle**")
532
+ st.dataframe(df_salles_perf, use_container_width=True, hide_index=True)
533
+
534
+ st.markdown("---")
535
+
536
+ # Insights actionnables
537
+ st.subheader("💡 Insights & Recommandations")
538
+
539
+ insights = []
540
+
541
+ best_day = df_temporal.loc[df_temporal['nb_ventes'].idxmax()]
542
+ insights.append(f"📅 **Meilleur jour** : {best_day['date_achat']} avec {int(best_day['nb_ventes'])} tickets vendus")
543
+
544
+ min_occupation = df_salles_perf.loc[df_salles_perf['taux_occupation'].idxmin()]
545
+ if min_occupation['taux_occupation'] < 50:
546
+ insights.append(f"⚠️ **Optimisation** : {min_occupation['nom_salle']} est sous-utilisée ({min_occupation['taux_occupation']:.1f}% occupation)")
547
+
548
+ top_film = run_query("""
549
+ SELECT f.titre, COUNT(t.id_ticket) as tickets
550
+ FROM film f
551
+ JOIN projection p ON f.id_film = p.id_film
552
+ JOIN ticket t ON p.id_projection = t.id_projection
553
+ GROUP BY f.id_film
554
+ ORDER BY tickets DESC
555
+ LIMIT 1
556
+ """)
557
+ if not top_film.empty:
558
+ insights.append(f"🎬 **Film le plus populaire** : {top_film.iloc[0]['titre']} ({int(top_film.iloc[0]['tickets'])} tickets)")
559
+
560
+ nb_vip = len(df_clients_seg[df_clients_seg['Catégorie'] == 'VIP 🌟'])
561
+ if nb_vip > 0:
562
+ insights.append(f"⭐ **Clients VIP** : {nb_vip} clients génèrent les revenus les plus élevés - envisager un programme de fidélité")
563
+
564
+ for insight in insights:
565
+ st.info(insight)
566
+
567
+ def page_predictions():
568
+ st.header("🔮 Prédictions ML — Intelligence Artificielle")
569
+
570
+ st.info("💡 Cette page utilise des modèles de Machine Learning pour prédire les tendances futures")
571
+
572
+ from sklearn.linear_model import LinearRegression
573
+ import numpy as np
574
+
575
+ # Prédiction des ventes futures
576
+ st.subheader("📈 Prédiction des Ventes Futures")
577
+
578
+ df_temporal = run_query("""
579
+ SELECT
580
+ date_achat,
581
+ COUNT(*) as nb_ventes,
582
+ SUM(prix) as revenu_jour
583
+ FROM ticket
584
+ GROUP BY date_achat
585
+ ORDER BY date_achat
586
+ """)
587
+
588
+ if len(df_temporal) >= 5:
589
+ df_temporal['date_num'] = pd.to_datetime(df_temporal['date_achat']).astype(np.int64) // 10**9
590
+
591
+ X = df_temporal[['date_num']].values
592
+ y_ventes = df_temporal['nb_ventes'].values
593
+ y_revenu = df_temporal['revenu_jour'].values
594
+
595
+ model_ventes = LinearRegression()
596
+ model_ventes.fit(X, y_ventes)
597
+
598
+ model_revenu = LinearRegression()
599
+ model_revenu.fit(X, y_revenu)
600
+
601
+ last_date = pd.to_datetime(df_temporal['date_achat'].iloc[-1])
602
+ future_dates = pd.date_range(start=last_date + pd.Timedelta(days=1), periods=7)
603
+ future_dates_num = future_dates.astype(np.int64).values.reshape(-1, 1) // 10**9
604
+
605
+ pred_ventes = model_ventes.predict(future_dates_num)
606
+ pred_revenu = model_revenu.predict(future_dates_num)
607
+
608
+ df_pred = pd.DataFrame({
609
+ 'Date': future_dates,
610
+ 'Ventes Prédites': np.maximum(pred_ventes, 0).round().astype(int),
611
+ 'Revenu Prédit (FCFA)': np.maximum(pred_revenu, 0).round().astype(int)
612
+ })
613
+
614
+ col1, col2 = st.columns(2)
615
+
616
+ with col1:
617
+ st.markdown("**🔮 Prédictions pour les 7 prochains jours**")
618
+ st.dataframe(df_pred, use_container_width=True, hide_index=True)
619
+
620
+ avg_ventes = df_pred['Ventes Prédites'].mean()
621
+ avg_revenu = df_pred['Revenu Prédit (FCFA)'].mean()
622
+ st.metric("Ventes Moy. Prévues", f"{avg_ventes:.1f} tickets/jour")
623
+ st.metric("Revenu Moy. Prévu", f"{avg_revenu:,.0f} FCFA/jour")
624
+
625
+ with col2:
626
+ fig_pred = px.line(df_temporal, x='date_achat', y='nb_ventes',
627
+ title="Ventes Historiques + Prédictions",
628
+ labels={'date_achat': 'Date', 'nb_ventes': 'Nombre de ventes'})
629
+
630
+ fig_pred.add_scatter(x=df_pred['Date'], y=df_pred['Ventes Prédites'],
631
+ mode='lines+markers', name='Prédictions',
632
+ line=dict(color='red', dash='dash'))
633
+
634
+ st.plotly_chart(fig_pred, use_container_width=True)
635
+ else:
636
+ st.warning("⚠️ Pas assez de données historiques pour faire des prédictions fiables (min 5 jours)")
637
+
638
+ st.markdown("---")
639
+
640
+ # Recommandations de films similaires
641
+ st.subheader("🎬 Système de Recommandation de Films")
642
+
643
+ df_films = run_query("SELECT id_film, titre, genre FROM film")
644
+
645
+ selected_film = st.selectbox(
646
+ "Choisir un film",
647
+ df_films['titre'].tolist()
648
+ )
649
+
650
+ if selected_film:
651
+ film_genre = df_films[df_films['titre'] == selected_film]['genre'].iloc[0]
652
+
653
+ recommendations = df_films[
654
+ (df_films['genre'] == film_genre) &
655
+ (df_films['titre'] != selected_film)
656
+ ]
657
+
658
+ if not recommendations.empty:
659
+ st.success(f"✅ Films similaires à **{selected_film}** ({film_genre}) :")
660
+
661
+ cols = st.columns(min(3, len(recommendations)))
662
+ for idx, (_, film) in enumerate(recommendations.head(3).iterrows()):
663
+ with cols[idx]:
664
+ st.markdown(f"""
665
+ <div style="background: rgba(255,255,255,0.05); padding: 20px;
666
+ border-radius: 8px; text-align: center; border: 1px solid rgba(229,9,20,0.3);">
667
+ <div style="font-size: 48px; margin-bottom: 10px;">🎬</div>
668
+ <div style="color: white; font-size: 18px; font-weight: bold;">{film['titre']}</div>
669
+ <div style="color: #E50914; font-size: 14px; margin-top: 5px;">{film['genre']}</div>
670
+ </div>
671
+ """, unsafe_allow_html=True)
672
+ else:
673
+ st.info("ℹ️ Aucun film similaire trouvé dans la base")
674
+
675
+ st.markdown("---")
676
+
677
+ # Scoring clients
678
+ st.subheader("💡 Scoring Clients — Probabilité de Réachat")
679
+
680
+ df_clients_scoring = run_query("""
681
+ SELECT
682
+ c.id_client,
683
+ c.nom || ' ' || c.prenom as client,
684
+ COUNT(t.id_ticket) as nb_tickets,
685
+ SUM(t.prix) as total_depense,
686
+ MAX(t.date_achat) as derniere_visite,
687
+ julianday('now') - julianday(MAX(t.date_achat)) as jours_depuis_derniere_visite
688
+ FROM client c
689
+ LEFT JOIN ticket t ON c.id_client = t.id_client
690
+ GROUP BY c.id_client
691
+ HAVING nb_tickets > 0
692
+ ORDER BY jours_depuis_derniere_visite
693
+ """)
694
+
695
+ if not df_clients_scoring.empty:
696
+ df_clients_scoring['score_fidelite'] = (
697
+ (df_clients_scoring['nb_tickets'] * 20) +
698
+ (100 / (df_clients_scoring['jours_depuis_derniere_visite'] + 1))
699
+ ).round(1)
700
+
701
+ max_score = df_clients_scoring['score_fidelite'].max()
702
+ df_clients_scoring['proba_reachat'] = (
703
+ (df_clients_scoring['score_fidelite'] / max_score) * 100
704
+ ).round(1)
705
+
706
+ def categorize_proba(proba):
707
+ if proba >= 70:
708
+ return "🟢 Élevée"
709
+ elif proba >= 40:
710
+ return "🟡 Moyenne"
711
+ else:
712
+ return "🔴 Faible"
713
+
714
+ df_clients_scoring['Risque'] = df_clients_scoring['proba_reachat'].apply(categorize_proba)
715
+
716
+ at_risk = df_clients_scoring[df_clients_scoring['proba_reachat'] < 40].head(5)
717
+ high_value = df_clients_scoring[df_clients_scoring['proba_reachat'] >= 70].head(5)
718
+
719
+ col1, col2 = st.columns(2)
720
+
721
+ with col1:
722
+ st.markdown("**⚠️ Clients à Risque (à réactiver)**")
723
+ if not at_risk.empty:
724
+ st.dataframe(
725
+ at_risk[['client', 'nb_tickets', 'jours_depuis_derniere_visite', 'proba_reachat']],
726
+ use_container_width=True,
727
+ hide_index=True
728
+ )
729
+ st.info("💡 Action : Envoyer une offre promotionnelle pour réengager ces clients")
730
+ else:
731
+ st.success("✅ Aucun client à risque détecté")
732
+
733
+ with col2:
734
+ st.markdown("**⭐ Clients Fidèles (forte probabilité de réachat)**")
735
+ if not high_value.empty:
736
+ st.dataframe(
737
+ high_value[['client', 'nb_tickets', 'jours_depuis_derniere_visite', 'proba_reachat']],
738
+ use_container_width=True,
739
+ hide_index=True
740
+ )
741
+ st.success("💡 Action : Programme VIP ou réductions exclusives")
742
+ else:
743
+ st.warning("Aucun client avec probabilité élevée")
744
+
745
+ st.markdown("**📊 Distribution des Probabilités de Réachat**")
746
+ fig_proba = px.histogram(df_clients_scoring, x='proba_reachat', nbins=20,
747
+ title="Répartition des scores de fidélité clients",
748
+ labels={'proba_reachat': 'Probabilité de réachat (%)'})
749
+ st.plotly_chart(fig_proba, use_container_width=True)
750
+ else:
751
+ st.warning("⚠️ Aucune donnée de tickets disponible pour le scoring")
752
+
753
+ st.markdown("---")
754
+
755
+ # Optimisation occupation
756
+ st.subheader("🏟️ Optimisation de l'Occupation des Salles")
757
+
758
+ df_occupation = run_query("""
759
+ SELECT
760
+ s.nom_salle,
761
+ s.capacite,
762
+ COUNT(DISTINCT p.id_projection) as nb_projections,
763
+ COUNT(t.id_ticket) as tickets_vendus,
764
+ ROUND(COUNT(t.id_ticket) * 100.0 /
765
+ (s.capacite * COUNT(DISTINCT p.id_projection)), 1) as taux_occupation,
766
+ ROUND(s.capacite * 0.7, 0) as objectif_70
767
+ FROM salle s
768
+ LEFT JOIN projection p ON s.id_salle = p.id_salle
769
+ LEFT JOIN ticket t ON p.id_projection = t.id_projection
770
+ GROUP BY s.id_salle
771
+ """)
772
+
773
+ if not df_occupation.empty:
774
+ col1, col2 = st.columns([2, 1])
775
+
776
+ with col1:
777
+ fig_opt = px.bar(df_occupation, x='nom_salle',
778
+ y=['taux_occupation'],
779
+ title="Taux d'Occupation Actuel vs Objectif (70%)",
780
+ labels={'value': 'Taux (%)', 'nom_salle': 'Salle'})
781
+ fig_opt.add_hline(y=70, line_dash="dash", line_color="green",
782
+ annotation_text="Objectif 70%")
783
+ st.plotly_chart(fig_opt, use_container_width=True)
784
+
785
+ with col2:
786
+ st.markdown("**💡 Recommandations**")
787
+ for _, salle in df_occupation.iterrows():
788
+ if salle['taux_occupation'] < 50:
789
+ st.warning(f"**{salle['nom_salle']}** : {salle['taux_occupation']}% - Sous-utilisée")
790
+ elif salle['taux_occupation'] >= 70:
791
+ st.success(f"**{salle['nom_salle']}** : {salle['taux_occupation']}% - Objectif atteint ! 🎉")
792
+ else:
793
+ st.info(f"**{salle['nom_salle']}** : {salle['taux_occupation']}% - Proche de l'objectif")
794
+
795
+ def page_sql_raw():
796
+ st.header("🛠️ SQL brut")
797
+ sql = st.text_area("Requête SELECT", height=150)
798
+ if st.button("▶️ Exécuter", type="primary"):
799
+ s = sql.strip()
800
+ if not s.lower().startswith("select"):
801
+ st.error("⚠️ Uniquement les requêtes SELECT sont autorisées.")
802
+ elif re.search(r';\s*\S', s):
803
+ st.error("⚠️ Requêtes empilées interdites (';' détecté).")
804
+ else:
805
+ try:
806
+ con = sqlite3.connect(f"file:{DB_PATH}?mode=ro", uri=True)
807
+ df = pd.read_sql_query(s, con)
808
+ con.close()
809
+ st.dataframe(df, use_container_width=True)
810
+ except Exception as e:
811
+ st.error(f"❌ Erreur: {e}")
812
+
813
+ # -------------------------
814
+ # MAIN
815
+ # -------------------------
816
+
817
+ def main():
818
+ if st.session_state.show_landing:
819
+ show_landing_page()
820
+ else:
821
+ page = sidebar_navigation()
822
+
823
+ if page == "Dashboard":
824
+ page_dashboard()
825
+ elif page == "Films":
826
+ page_films()
827
+ elif page == "Projections":
828
+ page_projections()
829
+ elif page == "Vendre un ticket":
830
+ page_sell_ticket()
831
+ elif page == "Clients":
832
+ page_clients()
833
+ elif page == "Billets":
834
+ page_tickets()
835
+ elif page == "Analytics Avancés":
836
+ page_analytics()
837
+ elif page == "Prédictions ML":
838
+ page_predictions()
839
+ elif page == "SQL brut":
840
+ page_sql_raw()
841
+
842
+ if __name__ == "__main__":
843
+ main()
844
+
845
+
init_db.py ADDED
@@ -0,0 +1,244 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ init_db.py — Recrée tidiane_flix.db en SQLite natif.
3
+ Remplace le dump phpMyAdmin/MariaDB (ENGINE=InnoDB, backticks, ALTER TABLE ADD CONSTRAINT)
4
+ par un schéma 100 % compatible SQLite.
5
+
6
+ Corrections appliquées :
7
+ - "telehone" → "telephone"
8
+ - Contraintes CHECK natives SQLite (prix > 0, note BETWEEN 1 AND 5, capacite > 0)
9
+ - Clés étrangères déclarées dans CREATE TABLE (pas en ALTER TABLE séparé)
10
+ - Table avis peuplée (était vide dans le .db malgré le SQL source)
11
+ """
12
+
13
+ import sqlite3
14
+ import os
15
+
16
+ DB_PATH = os.path.join(os.path.dirname(__file__), "tidiane_flix.db")
17
+
18
+
19
+ # ── Schéma SQLite natif ────────────────────────────────────────────────────────
20
+
21
+ SCHEMA = """
22
+ PRAGMA foreign_keys = ON;
23
+
24
+ CREATE TABLE IF NOT EXISTS client (
25
+ id_client INTEGER PRIMARY KEY AUTOINCREMENT,
26
+ nom TEXT NOT NULL,
27
+ prenom TEXT NOT NULL,
28
+ email TEXT,
29
+ telephone TEXT
30
+ );
31
+
32
+ CREATE TABLE IF NOT EXISTS film (
33
+ id_film INTEGER PRIMARY KEY AUTOINCREMENT,
34
+ titre TEXT NOT NULL,
35
+ genre TEXT,
36
+ date_sortie TEXT,
37
+ duree_minutes INTEGER CHECK (duree_minutes > 0),
38
+ realisateur TEXT
39
+ );
40
+
41
+ CREATE TABLE IF NOT EXISTS salle (
42
+ id_salle INTEGER PRIMARY KEY AUTOINCREMENT,
43
+ nom_salle TEXT NOT NULL,
44
+ capacite INTEGER CHECK (capacite > 0)
45
+ );
46
+
47
+ CREATE TABLE IF NOT EXISTS projection (
48
+ id_projection INTEGER PRIMARY KEY AUTOINCREMENT,
49
+ date_projection TEXT NOT NULL,
50
+ heure TEXT NOT NULL,
51
+ id_film INTEGER NOT NULL REFERENCES film(id_film),
52
+ id_salle INTEGER NOT NULL REFERENCES salle(id_salle)
53
+ );
54
+
55
+ CREATE TABLE IF NOT EXISTS ticket (
56
+ id_ticket INTEGER PRIMARY KEY AUTOINCREMENT,
57
+ prix REAL CHECK (prix > 0),
58
+ date_achat TEXT NOT NULL,
59
+ id_client INTEGER NOT NULL REFERENCES client(id_client),
60
+ id_projection INTEGER NOT NULL REFERENCES projection(id_projection)
61
+ );
62
+
63
+ CREATE TABLE IF NOT EXISTS avis (
64
+ id_avis INTEGER PRIMARY KEY AUTOINCREMENT,
65
+ note INTEGER CHECK (note >= 1 AND note <= 5),
66
+ commentaire TEXT,
67
+ date_avis TEXT NOT NULL,
68
+ id_client INTEGER NOT NULL REFERENCES client(id_client),
69
+ id_film INTEGER NOT NULL REFERENCES film(id_film)
70
+ );
71
+ """
72
+
73
+ # ── Données ────────────────────────────────────────────────────────────────────
74
+
75
+ CLIENTS = [
76
+ (1, 'Niang', 'Cheikh', 'cheikh1@mail.com', '771234567'),
77
+ (2, 'Fall', 'Tidiane', 'tidiane2@mail.com', '778765432'),
78
+ (3, 'Sow', 'Aminata', 'aminata3@mail.com', '770111222'),
79
+ (4, 'Ba', 'Mamadou', 'mamadou4@mail.com', '770222333'),
80
+ (5, 'Diop', 'Fatou', 'fatou5@mail.com', '770333444'),
81
+ (6, 'Gueye', 'Ousmane', 'ousmane6@mail.com', '770444555'),
82
+ (7, 'Ndiaye', 'Seynabou', 'seynabou7@mail.com', '770555666'),
83
+ (8, 'Sy', 'Ibrahima', 'ibrahima8@mail.com', '770666777'),
84
+ (9, 'Kane', 'Mame', 'mame9@mail.com', '770777888'),
85
+ (10, 'Faye', 'Lamine', 'lamine10@mail.com', '770888999'),
86
+ (11, 'Sarr', 'Ndèye', 'ndeye11@mail.com', '770999000'),
87
+ (12, 'Camara', 'Aliou', 'aliou12@mail.com', '771000111'),
88
+ (13, 'Barry', 'Mariama', 'mariama13@mail.com', '771111222'),
89
+ (14, 'Mbaye', 'Khady', 'khady14@mail.com', '771222333'),
90
+ (15, 'Diagne', 'Serigne', 'serigne15@mail.com', '771333444'),
91
+ (16, 'Thiam', 'Pape', 'pape16@mail.com', '771444555'),
92
+ (17, 'Fall', 'Coumba', 'coumba17@mail.com', '771555666'),
93
+ (18, 'Seck', 'Abdou', 'abdou18@mail.com', '771666777'),
94
+ (19, 'Niane', 'Aissatou', 'aissatou19@mail.com', '771777888'),
95
+ (20, 'Diallo', 'Boubacar', 'boubacar20@mail.com', '771888999'),
96
+ ]
97
+
98
+ FILMS = [
99
+ (1, 'Inception', 'Science-fiction', '2010-07-16', 148, 'Christopher Nolan'),
100
+ (2, 'Titanic', 'Drame', '1997-12-19', 195, 'James Cameron'),
101
+ (3, 'Avengers: Endgame', 'Action', '2019-04-26', 181, 'Anthony Russo'),
102
+ (4, 'Interstellar', 'Science-fiction', '2014-11-07', 169, 'Christopher Nolan'),
103
+ (5, 'The Matrix', 'Action', '1999-03-31', 136, 'Lana Wachowski'),
104
+ (6, 'Joker', 'Drame', '2019-10-04', 122, 'Todd Phillips'),
105
+ (7, 'Parasite', 'Thriller', '2019-05-30', 132, 'Bong Joon-ho'),
106
+ (8, 'The Godfather', 'Crime', '1972-03-24', 175, 'Francis Ford Coppola'),
107
+ (9, 'Pulp Fiction', 'Crime', '1994-10-14', 154, 'Quentin Tarantino'),
108
+ (10, 'Fight Club', 'Drame', '1999-10-15', 139, 'David Fincher'),
109
+ (11, 'Forrest Gump', 'Drame', '1994-07-06', 142, 'Robert Zemeckis'),
110
+ (12, 'The Dark Knight', 'Action', '2008-07-18', 152, 'Christopher Nolan'),
111
+ (13, 'Gladiator', 'Action', '2000-05-05', 155, 'Ridley Scott'),
112
+ (14, 'Black Panther', 'Action', '2018-02-16', 134, 'Ryan Coogler'),
113
+ (15, 'La La Land', 'Musical', '2016-12-09', 128, 'Damien Chazelle'),
114
+ ]
115
+
116
+ SALLES = [
117
+ (1, 'Salle 1', 120),
118
+ (2, 'Salle 2', 80),
119
+ (3, 'Salle 3', 150),
120
+ ]
121
+
122
+ PROJECTIONS = [
123
+ (1, '2025-05-01', '18:00:00', 1, 1),
124
+ (2, '2025-05-01', '21:00:00', 2, 2),
125
+ (3, '2025-05-02', '16:00:00', 3, 3),
126
+ (4, '2025-05-02', '19:30:00', 4, 1),
127
+ (5, '2025-05-03', '17:00:00', 5, 2),
128
+ (6, '2025-05-03', '20:00:00', 6, 3),
129
+ (7, '2025-05-04', '15:00:00', 7, 1),
130
+ (8, '2025-05-04', '18:30:00', 8, 2),
131
+ (9, '2025-05-05', '20:00:00', 9, 3),
132
+ (10, '2025-05-05', '14:00:00', 10, 1),
133
+ (11, '2025-05-06', '16:30:00', 11, 2),
134
+ (12, '2025-05-06', '19:00:00', 12, 3),
135
+ (13, '2025-05-07', '21:00:00', 13, 1),
136
+ (14, '2025-05-07', '17:30:00', 14, 2),
137
+ (15, '2025-05-08', '20:00:00', 15, 3),
138
+ (16, '2025-05-08', '18:00:00', 1, 1),
139
+ (17, '2025-05-09', '19:00:00', 2, 2),
140
+ (18, '2025-05-09', '15:00:00', 3, 3),
141
+ (19, '2025-05-10', '17:00:00', 4, 1),
142
+ (20, '2025-05-10', '20:00:00', 5, 2),
143
+ ]
144
+
145
+ TICKETS = [
146
+ (1, 3000.00, '2025-04-28', 1, 1),
147
+ (2, 3000.00, '2025-04-28', 1, 2),
148
+ (3, 3500.00, '2025-04-29', 2, 3),
149
+ (4, 3500.00, '2025-04-29', 3, 4),
150
+ (5, 3000.00, '2025-04-30', 4, 5),
151
+ (6, 4000.00, '2025-04-30', 5, 6),
152
+ (7, 4000.00, '2025-05-01', 6, 7),
153
+ (8, 3000.00, '2025-05-01', 7, 8),
154
+ (9, 3500.00, '2025-05-02', 8, 9),
155
+ (10, 3500.00, '2025-05-02', 9, 10),
156
+ (11, 3000.00, '2025-05-03', 10, 11),
157
+ (12, 3000.00, '2025-05-03', 11, 12),
158
+ (13, 4000.00, '2025-05-04', 12, 13),
159
+ (14, 3000.00, '2025-05-04', 13, 14),
160
+ (15, 3500.00, '2025-05-05', 14, 15),
161
+ (16, 3500.00, '2025-05-05', 15, 16),
162
+ (17, 3000.00, '2025-05-06', 16, 17),
163
+ (18, 4000.00, '2025-05-06', 17, 18),
164
+ (19, 3000.00, '2025-05-07', 18, 19),
165
+ (20, 4000.00, '2025-05-07', 19, 20),
166
+ (21, 3000.00, '2025-05-08', 20, 1),
167
+ (22, 3500.00, '2025-05-08', 1, 3),
168
+ (23, 3500.00, '2025-05-08', 2, 3),
169
+ (24, 4000.00, '2025-05-09', 3, 5),
170
+ (25, 4000.00, '2025-05-09', 4, 7),
171
+ (26, 4000.00, '2025-05-09', 5, 9),
172
+ (27, 3500.00, '2025-05-09', 6, 11),
173
+ (28, 3500.00, '2025-05-09', 7, 13),
174
+ (29, 3000.00, '2025-05-09', 8, 15),
175
+ (30, 3000.00, '2025-05-09', 9, 17),
176
+ ]
177
+
178
+ AVIS = [
179
+ (1, 5, 'Excellent film !', '2025-04-28', 1, 1),
180
+ (2, 4, 'Très bon mais un peu long.','2025-04-28', 2, 2),
181
+ (3, 5, "Chef-d'oeuvre !", '2025-04-29', 3, 3),
182
+ (4, 3, 'Pas à mon goût.', '2025-04-30', 4, 4),
183
+ (5, 5, 'Très émouvant.', '2025-04-30', 5, 5),
184
+ (6, 4, 'Bonne histoire.', '2025-05-01', 6, 6),
185
+ (7, 2, 'Bof, scénario confus.', '2025-05-02', 7, 7),
186
+ (8, 4, 'Sympa pour un dimanche.', '2025-05-02', 8, 8),
187
+ (9, 5, 'Mon film préféré !', '2025-05-03', 9, 9),
188
+ (10, 3, 'Pas mal.', '2025-05-04', 10, 10),
189
+ ]
190
+
191
+ # ── Construction ───────────────────────────────────────────────────────────────
192
+
193
+ def build():
194
+ if os.path.exists(DB_PATH):
195
+ os.remove(DB_PATH)
196
+ print(f"[OK] Ancienne base supprimee : {DB_PATH}")
197
+
198
+ con = sqlite3.connect(DB_PATH)
199
+ cur = con.cursor()
200
+ cur.executescript(SCHEMA)
201
+
202
+ cur.executemany(
203
+ "INSERT INTO client VALUES (?,?,?,?,?)", CLIENTS)
204
+ cur.executemany(
205
+ "INSERT INTO film VALUES (?,?,?,?,?,?)", FILMS)
206
+ cur.executemany(
207
+ "INSERT INTO salle VALUES (?,?,?)", SALLES)
208
+ cur.executemany(
209
+ "INSERT INTO projection VALUES (?,?,?,?,?)", PROJECTIONS)
210
+ cur.executemany(
211
+ "INSERT INTO ticket VALUES (?,?,?,?,?)", TICKETS)
212
+ cur.executemany(
213
+ "INSERT INTO avis VALUES (?,?,?,?,?,?)", AVIS)
214
+
215
+ con.commit()
216
+
217
+ # ── Vérification des comptes ──────────────────────────────────────────────
218
+ counts = {}
219
+ for table in ("client", "film", "salle", "projection", "ticket", "avis"):
220
+ counts[table] = cur.execute(f"SELECT COUNT(*) FROM {table}").fetchone()[0]
221
+
222
+ # ── Statistiques financières ──────────────────────────────────────────────
223
+ total_revenus = cur.execute("SELECT SUM(prix) FROM ticket").fetchone()[0]
224
+ prix_moyen = cur.execute("SELECT AVG(prix) FROM ticket").fetchone()[0]
225
+
226
+ con.close()
227
+
228
+ print("\n=== BASE RECREE — CINEFLOW ===")
229
+ print(f" Chemin : {DB_PATH}")
230
+ print()
231
+ print(" Enregistrements insérés :")
232
+ for table, n in counts.items():
233
+ print(f" {table:<12} {n:>3} lignes")
234
+ print()
235
+ print(" Statistiques financières (vérité pour le README) :")
236
+ print(f" Revenus totaux : {total_revenus:,.0f} FCFA")
237
+ print(f" Prix moyen : {prix_moyen:,.2f} FCFA")
238
+ print()
239
+ print(" Colonnes corrigees : 'telehone' -> 'telephone'")
240
+ print(" Table avis : peuplee (10 avis, etait vide dans l'ancien .db)")
241
+
242
+
243
+ if __name__ == "__main__":
244
+ build()
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ streamlit==1.40.1
2
+ pandas==2.1.0
3
+ sqlalchemy==2.0.23
4
+ plotly==5.18.0
5
+ scikit-learn==1.3.2
style.css ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* ========================================
2
+ CINEFLOW - RESPONSIVE CSS
3
+ ======================================== */
4
+
5
+ /* Fix page d'accueil mobile */
6
+ @media screen and (max-width: 768px) {
7
+ /* Reset zoom et viewport */
8
+ html {
9
+ -webkit-text-size-adjust: 100%;
10
+ -ms-text-size-adjust: 100%;
11
+ text-size-adjust: 100%;
12
+ }
13
+
14
+ /* Conteneur principal */
15
+ .main .block-container {
16
+ padding: 1rem 0.5rem !important;
17
+ max-width: 100% !important;
18
+ overflow-x: hidden !important;
19
+ }
20
+
21
+ /* Fix titre page d'accueil CINEFLOW */
22
+ h1[style*="color: #E50914"],
23
+ h1[style*="text-align: center"] {
24
+ font-size: 2rem !important;
25
+ line-height: 1.2 !important;
26
+ word-break: break-word !important;
27
+ overflow-wrap: break-word !important;
28
+ }
29
+
30
+ /* Tous les h1 sur mobile */
31
+ h1 {
32
+ font-size: 1.5rem !important;
33
+ line-height: 1.3 !important;
34
+ }
35
+
36
+ h2 {
37
+ font-size: 1.2rem !important;
38
+ }
39
+
40
+ h3 {
41
+ font-size: 1rem !important;
42
+ }
43
+
44
+ /* Paragraphes */
45
+ p {
46
+ font-size: 0.9rem !important;
47
+ line-height: 1.5 !important;
48
+ }
49
+
50
+ /* Empêcher le dépassement horizontal */
51
+ * {
52
+ max-width: 100%;
53
+ overflow-x: hidden;
54
+ }
55
+
56
+ /* Colonnes Streamlit */
57
+ [data-testid="column"] {
58
+ width: 100% !important;
59
+ flex: 1 1 100% !important;
60
+ min-width: 100% !important;
61
+ }
62
+
63
+ /* Métriques */
64
+ [data-testid="stMetricValue"] {
65
+ font-size: 1.3rem !important;
66
+ }
67
+
68
+ [data-testid="stMetricLabel"] {
69
+ font-size: 0.75rem !important;
70
+ }
71
+
72
+ /* Graphiques Plotly */
73
+ .js-plotly-plot {
74
+ width: 100% !important;
75
+ height: auto !important;
76
+ min-height: 250px !important;
77
+ }
78
+
79
+ /* Tables */
80
+ .dataframe {
81
+ font-size: 0.7rem !important;
82
+ overflow-x: auto !important;
83
+ }
84
+
85
+ /* Boutons */
86
+ .stButton > button {
87
+ width: 100% !important;
88
+ font-size: 0.85rem !important;
89
+ padding: 0.4rem !important;
90
+ }
91
+
92
+ /* Sidebar mobile */
93
+ [data-testid="stSidebar"] {
94
+ width: 100% !important;
95
+ }
96
+
97
+ /* Selectbox et inputs */
98
+ .stSelectbox, .stDateInput, .stNumberInput {
99
+ font-size: 0.85rem !important;
100
+ }
101
+
102
+ /* Espacement */
103
+ .element-container {
104
+ margin-bottom: 0.5rem !important;
105
+ }
106
+
107
+ /* Images */
108
+ img {
109
+ max-width: 100% !important;
110
+ height: auto !important;
111
+ }
112
+ }
113
+
114
+ /* Tablet (768px - 1024px) */
115
+ @media screen and (min-width: 768px) and (max-width: 1024px) {
116
+ .main .block-container {
117
+ padding: 2rem 1rem !important;
118
+ }
119
+
120
+ [data-testid="column"] {
121
+ min-width: 45% !important;
122
+ }
123
+
124
+ h1 {
125
+ font-size: 2rem !important;
126
+ }
127
+ }
128
+
129
+ /* Desktop amélioré */
130
+ @media screen and (min-width: 1024px) {
131
+ .main .block-container {
132
+ max-width: 1400px !important;
133
+ padding: 2rem 3rem !important;
134
+ }
135
+ }
tidiane_flix.db ADDED
Binary file (32.8 kB). View file
 
tidiane_flix.sql ADDED
@@ -0,0 +1,316 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -- phpMyAdmin SQL Dump
2
+ -- version 5.2.1
3
+ -- https://www.phpmyadmin.net/
4
+ --
5
+ -- Hôte : 127.0.0.1
6
+ -- Généré le : lun. 05 mai 2025 à 16:02
7
+ -- Version du serveur : 10.4.32-MariaDB
8
+ -- Version de PHP : 8.2.12
9
+
10
+ SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
11
+ START TRANSACTION;
12
+ SET time_zone = "+00:00";
13
+
14
+
15
+ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
16
+ /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
17
+ /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
18
+ /*!40101 SET NAMES utf8mb4 */;
19
+
20
+ --
21
+ -- Base de données : `tidiane_flix`
22
+ --
23
+
24
+ -- --------------------------------------------------------
25
+
26
+ --
27
+ -- Structure de la table `avis`
28
+ --
29
+
30
+ CREATE TABLE `avis` (
31
+ `id_avis` int(11) NOT NULL,
32
+ `note` int(11) DEFAULT NULL CHECK (`note` >= 1 and `note` <= 5),
33
+ `commentaire` text DEFAULT NULL,
34
+ `date_avis` date NOT NULL,
35
+ `id_client` int(11) NOT NULL,
36
+ `id_film` int(11) NOT NULL
37
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
38
+
39
+ --
40
+ -- Déchargement des données de la table `avis`
41
+ --
42
+
43
+ INSERT INTO `avis` (`id_avis`, `note`, `commentaire`, `date_avis`, `id_client`, `id_film`) VALUES
44
+ (1, 5, 'Excellent film !', '2025-04-28', 1, 1),
45
+ (2, 4, 'Très bon mais un peu long.', '2025-04-28', 2, 2),
46
+ (3, 5, 'Chef-d’œuvre !', '2025-04-29', 3, 3),
47
+ (4, 3, 'Pas à mon goût.', '2025-04-30', 4, 4),
48
+ (5, 5, 'Très émouvant.', '2025-04-30', 5, 5),
49
+ (6, 4, 'Bonne histoire.', '2025-05-01', 6, 6),
50
+ (7, 2, 'Bof, scénario confus.', '2025-05-02', 7, 7),
51
+ (8, 4, 'Sympa pour un dimanche.', '2025-05-02', 8, 8),
52
+ (9, 5, 'Mon film préféré !', '2025-05-03', 9, 9),
53
+ (10, 3, 'Pas mal.', '2025-05-04', 10, 10);
54
+
55
+ -- --------------------------------------------------------
56
+
57
+ --
58
+ -- Structure de la table `client`
59
+ --
60
+
61
+ CREATE TABLE `client` (
62
+ `id_client` int(11) NOT NULL,
63
+ `nom` varchar(50) NOT NULL,
64
+ `prenom` varchar(50) NOT NULL,
65
+ `email` varchar(100) DEFAULT NULL,
66
+ `telehone` varchar(15) DEFAULT NULL
67
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
68
+
69
+ --
70
+ -- Déchargement des données de la table `client`
71
+ --
72
+
73
+ INSERT INTO `client` (`id_client`, `nom`, `prenom`, `email`, `telehone`) VALUES
74
+ (1, 'Niang', 'Cheikh', 'cheikh1@mail.com', '771234567'),
75
+ (2, 'Fall', 'Tidiane', 'tidiane2@mail.com', '778765432'),
76
+ (3, 'Sow', 'Aminata', 'aminata3@mail.com', '770111222'),
77
+ (4, 'Ba', 'Mamadou', 'mamadou4@mail.com', '770222333'),
78
+ (5, 'Diop', 'Fatou', 'fatou5@mail.com', '770333444'),
79
+ (6, 'Gueye', 'Ousmane', 'ousmane6@mail.com', '770444555'),
80
+ (7, 'Ndiaye', 'Seynabou', 'seynabou7@mail.com', '770555666'),
81
+ (8, 'Sy', 'Ibrahima', 'ibrahima8@mail.com', '770666777'),
82
+ (9, 'Kane', 'Mame', 'mame9@mail.com', '770777888'),
83
+ (10, 'Faye', 'Lamine', 'lamine10@mail.com', '770888999'),
84
+ (11, 'Sarr', 'Ndèye', 'ndeye11@mail.com', '770999000'),
85
+ (12, 'Camara', 'Aliou', 'aliou12@mail.com', '771000111'),
86
+ (13, 'Barry', 'Mariama', 'mariama13@mail.com', '771111222'),
87
+ (14, 'Mbaye', 'Khady', 'khady14@mail.com', '771222333'),
88
+ (15, 'Diagne', 'Serigne', 'serigne15@mail.com', '771333444'),
89
+ (16, 'Thiam', 'Pape', 'pape16@mail.com', '771444555'),
90
+ (17, 'Fall', 'Coumba', 'coumba17@mail.com', '771555666'),
91
+ (18, 'Seck', 'Abdou', 'abdou18@mail.com', '771666777'),
92
+ (19, 'Niane', 'Aissatou', 'aissatou19@mail.com', '771777888'),
93
+ (20, 'Diallo', 'Boubacar', 'boubacar20@mail.com', '771888999');
94
+
95
+ -- --------------------------------------------------------
96
+
97
+ --
98
+ -- Structure de la table `film`
99
+ --
100
+
101
+ CREATE TABLE `film` (
102
+ `id_film` int(11) NOT NULL,
103
+ `titre` varchar(100) NOT NULL,
104
+ `genre` varchar(50) DEFAULT NULL,
105
+ `date_sortie` date DEFAULT NULL,
106
+ `duree_minutes` int(11) DEFAULT NULL CHECK (`duree_minutes` > 0),
107
+ `realisateur` varchar(100) DEFAULT NULL
108
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
109
+
110
+ --
111
+ -- Déchargement des données de la table `film`
112
+ --
113
+
114
+ INSERT INTO `film` (`id_film`, `titre`, `genre`, `date_sortie`, `duree_minutes`, `realisateur`) VALUES
115
+ (1, 'Inception', 'Science-fiction', '2010-07-16', 148, 'Christopher Nolan'),
116
+ (2, 'Titanic', 'Drame', '1997-12-19', 195, 'James Cameron'),
117
+ (3, 'Avengers: Endgame', 'Action', '2019-04-26', 181, 'Anthony Russo'),
118
+ (4, 'Interstellar', 'Science-fiction', '2014-11-07', 169, 'Christopher Nolan'),
119
+ (5, 'The Matrix', 'Action', '1999-03-31', 136, 'Lana Wachowski'),
120
+ (6, 'Joker', 'Drame', '2019-10-04', 122, 'Todd Phillips'),
121
+ (7, 'Parasite', 'Thriller', '2019-05-30', 132, 'Bong Joon-ho'),
122
+ (8, 'The Godfather', 'Crime', '1972-03-24', 175, 'Francis Ford Coppola'),
123
+ (9, 'Pulp Fiction', 'Crime', '1994-10-14', 154, 'Quentin Tarantino'),
124
+ (10, 'Fight Club', 'Drame', '1999-10-15', 139, 'David Fincher'),
125
+ (11, 'Forrest Gump', 'Drame', '1994-07-06', 142, 'Robert Zemeckis'),
126
+ (12, 'The Dark Knight', 'Action', '2008-07-18', 152, 'Christopher Nolan'),
127
+ (13, 'Gladiator', 'Action', '2000-05-05', 155, 'Ridley Scott'),
128
+ (14, 'Black Panther', 'Action', '2018-02-16', 134, 'Ryan Coogler'),
129
+ (15, 'La La Land', 'Musical', '2016-12-09', 128, 'Damien Chazelle');
130
+
131
+ -- --------------------------------------------------------
132
+
133
+ --
134
+ -- Structure de la table `projection`
135
+ --
136
+
137
+ CREATE TABLE `projection` (
138
+ `id_projection` int(11) NOT NULL,
139
+ `date_projection` date NOT NULL,
140
+ `heure` time NOT NULL,
141
+ `id_film` int(11) NOT NULL,
142
+ `id_salle` int(11) NOT NULL
143
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
144
+
145
+ --
146
+ -- Déchargement des données de la table `projection`
147
+ --
148
+
149
+ INSERT INTO `projection` (`id_projection`, `date_projection`, `heure`, `id_film`, `id_salle`) VALUES
150
+ (1, '2025-05-01', '18:00:00', 1, 1),
151
+ (2, '2025-05-01', '21:00:00', 2, 2),
152
+ (3, '2025-05-02', '16:00:00', 3, 3),
153
+ (4, '2025-05-02', '19:30:00', 4, 1),
154
+ (5, '2025-05-03', '17:00:00', 5, 2),
155
+ (6, '2025-05-03', '20:00:00', 6, 3),
156
+ (7, '2025-05-04', '15:00:00', 7, 1),
157
+ (8, '2025-05-04', '18:30:00', 8, 2),
158
+ (9, '2025-05-05', '20:00:00', 9, 3),
159
+ (10, '2025-05-05', '14:00:00', 10, 1),
160
+ (11, '2025-05-06', '16:30:00', 11, 2),
161
+ (12, '2025-05-06', '19:00:00', 12, 3),
162
+ (13, '2025-05-07', '21:00:00', 13, 1),
163
+ (14, '2025-05-07', '17:30:00', 14, 2),
164
+ (15, '2025-05-08', '20:00:00', 15, 3),
165
+ (16, '2025-05-08', '18:00:00', 1, 1),
166
+ (17, '2025-05-09', '19:00:00', 2, 2),
167
+ (18, '2025-05-09', '15:00:00', 3, 3),
168
+ (19, '2025-05-10', '17:00:00', 4, 1),
169
+ (20, '2025-05-10', '20:00:00', 5, 2);
170
+
171
+ -- --------------------------------------------------------
172
+
173
+ --
174
+ -- Structure de la table `salle`
175
+ --
176
+
177
+ CREATE TABLE `salle` (
178
+ `id_salle` int(11) NOT NULL,
179
+ `nom_salle` varchar(50) NOT NULL,
180
+ `capacite` int(11) DEFAULT NULL CHECK (`capacite` > 0)
181
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
182
+
183
+ --
184
+ -- Déchargement des données de la table `salle`
185
+ --
186
+
187
+ INSERT INTO `salle` (`id_salle`, `nom_salle`, `capacite`) VALUES
188
+ (1, 'Salle 1', 120),
189
+ (2, 'Salle 2', 80),
190
+ (3, 'Salle 3', 150);
191
+
192
+ -- --------------------------------------------------------
193
+
194
+ --
195
+ -- Structure de la table `ticket`
196
+ --
197
+
198
+ CREATE TABLE `ticket` (
199
+ `id_ticket` int(11) NOT NULL,
200
+ `prix` decimal(6,2) DEFAULT NULL CHECK (`prix` > 0),
201
+ `date_achat` date NOT NULL,
202
+ `id_client` int(11) NOT NULL,
203
+ `id_projection` int(11) NOT NULL
204
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
205
+
206
+ --
207
+ -- Déchargement des données de la table `ticket`
208
+ --
209
+
210
+ INSERT INTO `ticket` (`id_ticket`, `prix`, `date_achat`, `id_client`, `id_projection`) VALUES
211
+ (1, 3000.00, '2025-04-28', 1, 1),
212
+ (2, 3000.00, '2025-04-28', 1, 2),
213
+ (3, 3500.00, '2025-04-29', 2, 3),
214
+ (4, 3500.00, '2025-04-29', 3, 4),
215
+ (5, 3000.00, '2025-04-30', 4, 5),
216
+ (6, 4000.00, '2025-04-30', 5, 6),
217
+ (7, 4000.00, '2025-05-01', 6, 7),
218
+ (8, 3000.00, '2025-05-01', 7, 8),
219
+ (9, 3500.00, '2025-05-02', 8, 9),
220
+ (10, 3500.00, '2025-05-02', 9, 10),
221
+ (11, 3000.00, '2025-05-03', 10, 11),
222
+ (12, 3000.00, '2025-05-03', 11, 12),
223
+ (13, 4000.00, '2025-05-04', 12, 13),
224
+ (14, 3000.00, '2025-05-04', 13, 14),
225
+ (15, 3500.00, '2025-05-05', 14, 15),
226
+ (16, 3500.00, '2025-05-05', 15, 16),
227
+ (17, 3000.00, '2025-05-06', 16, 17),
228
+ (18, 4000.00, '2025-05-06', 17, 18),
229
+ (19, 3000.00, '2025-05-07', 18, 19),
230
+ (20, 4000.00, '2025-05-07', 19, 20),
231
+ (21, 3000.00, '2025-05-08', 20, 1),
232
+ (22, 3500.00, '2025-05-08', 1, 3),
233
+ (23, 3500.00, '2025-05-08', 2, 3),
234
+ (24, 4000.00, '2025-05-09', 3, 5),
235
+ (25, 4000.00, '2025-05-09', 4, 7),
236
+ (26, 4000.00, '2025-05-09', 5, 9),
237
+ (27, 3500.00, '2025-05-09', 6, 11),
238
+ (28, 3500.00, '2025-05-09', 7, 13),
239
+ (29, 3000.00, '2025-05-09', 8, 15),
240
+ (30, 3000.00, '2025-05-09', 9, 17);
241
+
242
+ --
243
+ -- Index pour les tables déchargées
244
+ --
245
+
246
+ --
247
+ -- Index pour la table `avis`
248
+ --
249
+ ALTER TABLE `avis`
250
+ ADD PRIMARY KEY (`id_avis`),
251
+ ADD KEY `id_client` (`id_client`),
252
+ ADD KEY `id_film` (`id_film`);
253
+
254
+ --
255
+ -- Index pour la table `client`
256
+ --
257
+ ALTER TABLE `client`
258
+ ADD PRIMARY KEY (`id_client`);
259
+
260
+ --
261
+ -- Index pour la table `film`
262
+ --
263
+ ALTER TABLE `film`
264
+ ADD PRIMARY KEY (`id_film`);
265
+
266
+ --
267
+ -- Index pour la table `projection`
268
+ --
269
+ ALTER TABLE `projection`
270
+ ADD PRIMARY KEY (`id_projection`),
271
+ ADD KEY `id_film` (`id_film`),
272
+ ADD KEY `id_salle` (`id_salle`);
273
+
274
+ --
275
+ -- Index pour la table `salle`
276
+ --
277
+ ALTER TABLE `salle`
278
+ ADD PRIMARY KEY (`id_salle`);
279
+
280
+ --
281
+ -- Index pour la table `ticket`
282
+ --
283
+ ALTER TABLE `ticket`
284
+ ADD PRIMARY KEY (`id_ticket`),
285
+ ADD KEY `id_client` (`id_client`),
286
+ ADD KEY `id_projection` (`id_projection`);
287
+
288
+ --
289
+ -- Contraintes pour les tables déchargées
290
+ --
291
+
292
+ --
293
+ -- Contraintes pour la table `avis`
294
+ --
295
+ ALTER TABLE `avis`
296
+ ADD CONSTRAINT `avis_ibfk_1` FOREIGN KEY (`id_client`) REFERENCES `client` (`id_client`),
297
+ ADD CONSTRAINT `avis_ibfk_2` FOREIGN KEY (`id_film`) REFERENCES `film` (`id_film`);
298
+
299
+ --
300
+ -- Contraintes pour la table `projection`
301
+ --
302
+ ALTER TABLE `projection`
303
+ ADD CONSTRAINT `projection_ibfk_1` FOREIGN KEY (`id_film`) REFERENCES `film` (`id_film`),
304
+ ADD CONSTRAINT `projection_ibfk_2` FOREIGN KEY (`id_salle`) REFERENCES `salle` (`id_salle`);
305
+
306
+ --
307
+ -- Contraintes pour la table `ticket`
308
+ --
309
+ ALTER TABLE `ticket`
310
+ ADD CONSTRAINT `ticket_ibfk_1` FOREIGN KEY (`id_client`) REFERENCES `client` (`id_client`),
311
+ ADD CONSTRAINT `ticket_ibfk_2` FOREIGN KEY (`id_projection`) REFERENCES `projection` (`id_projection`);
312
+ COMMIT;
313
+
314
+ /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
315
+ /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
316
+ /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;