Spaces:
Running
Running
A newer version of the Streamlit SDK is available:
1.41.1
metadata
title: AI Phone Leaderboard
emoji: π±
colorFrom: blue
colorTo: purple
sdk: streamlit
sdk_version: 1.41.0
app_file: main.py
pinned: false
license: mit
short_description: AI Phone Leaderboard
AI Phone Benchmark Leaderboard
A Streamlit dashboard for displaying and analyzing mobile device AI benchmark results. The dashboard fetches data from Firebase Firestore and provides interactive visualizations and filtering capabilities.
Setup
Prerequisites
- Python 3.10+
- Firebase project with Firestore database
- Hugging Face account (for deployment)
Local Development
- Clone the repository:
git clone https://github.com/yourusername/ai-phone-leaderboard.git
cd ai-phone-leaderboard
- Create a virtual environment and install dependencies:
make venv
make setup-dev
Firebase Configuration
Create a Firebase Service Account:
- Go to Firebase Console β Project Settings β Service Accounts
- Create a new service account for the dashboard:
# Create service account gcloud iam service-accounts create dashboard-firestore-reader \ --description="Service account for reading Firestore data in the dashboard" \ --display-name="Dashboard Firestore Reader"
- Grant minimal required permissions:
# Grant Firestore read-only access gcloud projects add-iam-policy-binding YOUR_PROJECT_ID \ --member="serviceAccount:dashboard-firestore-reader@YOUR_PROJECT_ID.iam.gserviceaccount.com" \ --role="roles/datastore.viewer"
- Generate and download the service account key:
- Click "Generate New Private Key"
- Save the JSON file (don't commit this to git)
For local development, create
.streamlit/secrets.toml
:
FIREBASE_CREDENTIALS = '''
{
"type": "service_account",
"project_id": "your-project-id",
"private_key_id": "your-private-key-id",
"private_key": "your-private-key",
"client_email": "your-client-email",
"client_id": "your-client-id",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://oauth2.googleapis.com/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "your-client-cert-url",
"universe_domain": "googleapis.com"
}
'''
- Run the application:
make run
Deployment to Hugging Face Spaces
Create a new Space:
- Go to huggingface.co/spaces
- Click "Create new Space"
- Select "Streamlit" as the SDK
- Choose a name for your space
Add Firebase credentials to Spaces:
- Go to Space Settings β Repository Secrets
- Add a new secret named
FIREBASE_CREDENTIALS
- Value should be your Firebase credentials as a minified JSON string (single line)
- Note: Convert the private key's newlines to
\n
in the JSON
Example of minified credentials for HF Spaces:
{"type":"service_account","project_id":"your-project-id","private_key_id":"your-key-id","private_key":"-----BEGIN PRIVATE KEY-----\\nYour\\nPrivate\\nKey\\nHere\\n-----END PRIVATE KEY-----\\n","client_email":"your-email","client_id":"your-client-id","auth_uri":"https://accounts.google.com/o/oauth2/auth","token_uri":"https://oauth2.googleapis.com/token","auth_provider_x509_cert_url":"https://www.googleapis.com/oauth2/v1/certs","client_x509_cert_url":"your-cert-url","universe_domain":"googleapis.com"}
- The application will automatically deploy when you push to the repository.
Project Structure
.
βββ .gitignore
βββ .streamlit/
β βββ secrets.toml
βββ requirements/
β βββ base.txt
β βββ dev.txt
β βββ prod.txt
βββ src/
β βββ components/
β β βββ filters.py
β β βββ header.py
β β βββ visualizations.py
β βββ core/
β β βββ config.py
β βββ services/
β βββ firebase.py
βββ main.py
βββ requirements.txt
Firebase Data Structure
The application expects the following Firestore collection structure:
benchmarks/
βββ v1/
βββ submissions/
βββ [benchmark_uuid]/
βββ benchmarkResult: {...}
βββ deviceInfo: {...}
βββ metadata: {...}
Development
Available make commands:
make help # Show available commands
make setup-dev # Setup development environment
make setup-prod # Setup production environment
make run # Run Streamlit application
make lint # Run code linter
make format # Format code using black
make test # Run tests
make clean # Clean cache files
Security Considerations
- Never commit sensitive credentials to git:
# Add to .gitignore
.streamlit/secrets.toml
*firebase*.json
Use environment-specific secrets:
- Local: Use
.streamlit/secrets.toml
- Production: Use HF Spaces secrets
- Local: Use
Firebase Security:
- Create a dedicated service account with minimal permissions
- Only grant read access to the required Firestore collections
Dependencies
Key dependencies are pinned to specific versions to ensure stability:
firebase-admin==6.6.0
streamlit>=1.28.0
pandas>=2.1.3
plotly>=5.18.0