agh123 commited on
Commit
9543568
Β·
1 Parent(s): 981d083

update readme

Browse files
Files changed (1) hide show
  1. README.md +128 -34
README.md CHANGED
@@ -13,42 +13,76 @@ short_description: AI Phone Leaderboard
13
 
14
  # AI Phone Benchmark Leaderboard
15
 
16
- Streamlit frontend for displaying AI model performance benchmarks across different mobile devices.
17
 
18
- ## Features
19
 
20
- - Interactive data filtering
21
- - Performance comparison charts
22
- - Detailed benchmark leaderboard
23
- - Real-time data updates
24
- - Responsive design
25
 
26
- ## Local Development
27
 
28
- 1. Create a virtual environment:
29
  ```bash
30
- make venv
 
31
  ```
32
 
33
- 2. Install dependencies:
34
  ```bash
 
35
  make setup-dev
36
  ```
37
 
38
- 3. Set up environment variables:
39
- Create a `.env` file:
40
- ```env
41
- HF_TOKEN=your_hugging_face_token_here # Required for accessing the API
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  ```
43
 
44
- 4. Run the application:
45
  ```bash
46
  make run
47
  ```
48
 
49
- ## Deployment
50
-
51
- This application is configured for deployment on Hugging Face Spaces:
52
 
53
  1. Create a new Space:
54
  - Go to huggingface.co/spaces
@@ -56,25 +90,54 @@ This application is configured for deployment on Hugging Face Spaces:
56
  - Select "Streamlit" as the SDK
57
  - Choose a name for your space
58
 
59
- 2. Add required secret:
60
- - Go to Space Settings
61
- - Under "Repository Secrets"
62
- - Add `HF_TOKEN` with your Hugging Face token
 
63
 
64
- 3. The application will automatically deploy when you push to the repository.
 
 
 
65
 
66
- ## Configuration
67
 
68
- The application can be configured through environment variables:
69
- - `HF_TOKEN`: Hugging Face access token (required)
70
- - `API_URL`: Backend API URL (defaults to production)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
 
72
- ## API Integration
73
 
74
- The application integrates with the AI Phone Benchmark API for data retrieval:
75
- - Leaderboard data
76
- - Performance metrics
77
- - Device information
 
 
 
 
 
 
78
 
79
  ## Development
80
 
@@ -88,4 +151,35 @@ make lint # Run code linter
88
  make format # Format code using black
89
  make test # Run tests
90
  make clean # Clean cache files
91
- ```
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
  # AI Phone Benchmark Leaderboard
15
 
16
+ 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.
17
 
18
+ ## Setup
19
 
20
+ ### Prerequisites
21
+ - Python 3.10+
22
+ - Firebase project with Firestore database
23
+ - Hugging Face account (for deployment)
 
24
 
25
+ ### Local Development
26
 
27
+ 1. Clone the repository:
28
  ```bash
29
+ git clone https://github.com/yourusername/ai-phone-leaderboard.git
30
+ cd ai-phone-leaderboard
31
  ```
32
 
33
+ 2. Create a virtual environment and install dependencies:
34
  ```bash
35
+ make venv
36
  make setup-dev
37
  ```
38
 
39
+ ### Firebase Configuration
40
+
41
+ 1. Create a Firebase Service Account:
42
+ - Go to Firebase Console β†’ Project Settings β†’ Service Accounts
43
+ - Create a new service account for the dashboard:
44
+ ```bash
45
+ # Create service account
46
+ gcloud iam service-accounts create dashboard-firestore-reader \
47
+ --description="Service account for reading Firestore data in the dashboard" \
48
+ --display-name="Dashboard Firestore Reader"
49
+ ```
50
+ - Grant minimal required permissions:
51
+ ```bash
52
+ # Grant Firestore read-only access
53
+ gcloud projects add-iam-policy-binding YOUR_PROJECT_ID \
54
+ --member="serviceAccount:dashboard-firestore-reader@YOUR_PROJECT_ID.iam.gserviceaccount.com" \
55
+ --role="roles/datastore.viewer"
56
+ ```
57
+ - Generate and download the service account key:
58
+ - Click "Generate New Private Key"
59
+ - Save the JSON file (don't commit this to git)
60
+
61
+ 2. For local development, create `.streamlit/secrets.toml`:
62
+ ```toml
63
+ FIREBASE_CREDENTIALS = '''
64
+ {
65
+ "type": "service_account",
66
+ "project_id": "your-project-id",
67
+ "private_key_id": "your-private-key-id",
68
+ "private_key": "your-private-key",
69
+ "client_email": "your-client-email",
70
+ "client_id": "your-client-id",
71
+ "auth_uri": "https://accounts.google.com/o/oauth2/auth",
72
+ "token_uri": "https://oauth2.googleapis.com/token",
73
+ "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
74
+ "client_x509_cert_url": "your-client-cert-url",
75
+ "universe_domain": "googleapis.com"
76
+ }
77
+ '''
78
  ```
79
 
80
+ 3. Run the application:
81
  ```bash
82
  make run
83
  ```
84
 
85
+ ## Deployment to Hugging Face Spaces
 
 
86
 
87
  1. Create a new Space:
88
  - Go to huggingface.co/spaces
 
90
  - Select "Streamlit" as the SDK
91
  - Choose a name for your space
92
 
93
+ 2. Add Firebase credentials to Spaces:
94
+ - Go to Space Settings β†’ Repository Secrets
95
+ - Add a new secret named `FIREBASE_CREDENTIALS`
96
+ - Value should be your Firebase credentials as a minified JSON string (single line)
97
+ - Note: Convert the private key's newlines to `\n` in the JSON
98
 
99
+ Example of minified credentials for HF Spaces:
100
+ ```json
101
+ {"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"}
102
+ ```
103
 
104
+ 3. The application will automatically deploy when you push to the repository.
105
 
106
+ ## Project Structure
107
+ ```
108
+ .
109
+ β”œβ”€β”€ .gitignore
110
+ β”œβ”€β”€ .streamlit/
111
+ β”‚ └── secrets.toml
112
+ β”œβ”€β”€ requirements/
113
+ β”‚ β”œβ”€β”€ base.txt
114
+ β”‚ β”œβ”€β”€ dev.txt
115
+ β”‚ └── prod.txt
116
+ β”œβ”€β”€ src/
117
+ β”‚ β”œβ”€β”€ components/
118
+ β”‚ β”‚ β”œβ”€β”€ filters.py
119
+ β”‚ β”‚ β”œβ”€β”€ header.py
120
+ β”‚ β”‚ └── visualizations.py
121
+ β”‚ β”œβ”€β”€ core/
122
+ β”‚ β”‚ └── config.py
123
+ β”‚ └── services/
124
+ β”‚ └── firebase.py
125
+ β”œβ”€β”€ main.py
126
+ └── requirements.txt
127
+ ```
128
 
129
+ ## Firebase Data Structure
130
 
131
+ The application expects the following Firestore collection structure:
132
+ ```
133
+ benchmarks/
134
+ └── v1/
135
+ └── submissions/
136
+ └── [benchmark_uuid]/
137
+ β”œβ”€β”€ benchmarkResult: {...}
138
+ β”œβ”€β”€ deviceInfo: {...}
139
+ └── metadata: {...}
140
+ ```
141
 
142
  ## Development
143
 
 
151
  make format # Format code using black
152
  make test # Run tests
153
  make clean # Clean cache files
154
+ ```
155
+
156
+ ## Security Considerations
157
+
158
+ 1. Never commit sensitive credentials to git:
159
+ ```gitignore
160
+ # Add to .gitignore
161
+ .streamlit/secrets.toml
162
+ *firebase*.json
163
+ ```
164
+
165
+ 2. Use environment-specific secrets:
166
+ - Local: Use `.streamlit/secrets.toml`
167
+ - Production: Use HF Spaces secrets
168
+
169
+ 3. Firebase Security:
170
+ - Create a dedicated service account with minimal permissions
171
+ - Only grant read access to the required Firestore collections
172
+
173
+ ## Dependencies
174
+
175
+ Key dependencies are pinned to specific versions to ensure stability:
176
+ ```
177
+ firebase-admin==6.6.0
178
+ streamlit>=1.28.0
179
+ pandas>=2.1.3
180
+ plotly>=5.18.0
181
+ ```
182
+
183
+ ## License
184
+
185
+ [MIT License](LICENSE)