Hkoradiya123 commited on
Commit
3ba45b3
·
1 Parent(s): c0c08d7

feat: Update README with Docker setup and deployment options

Browse files

chore: Remove outdated SETUP_COMPLETE.md file

chore: Add .dockerignore for backend to exclude unnecessary files

fix: Update backend .env.example for production readiness

build: Create production Dockerfile for backend with Gunicorn

fix: Modify backend config for CORS origins and debug settings

fix: Update main.py to use dynamic CORS origins

chore: Add Gunicorn to backend requirements

build: Create docker-compose.prod.yml for production deployment

build: Add entrypoint script for backend with Nginx

chore: Add .dockerignore for frontend to exclude unnecessary files

fix: Update frontend .env.example for local development

feat: Add frontend production environment variables example

build: Create production Dockerfile for frontend with Nginx

feat: Add Nginx configuration for frontend deployment

style: Enhance navbar styles for better UI

feat: Improve Matches page with match status and scoreboard updates

style: Update matches.module.css for better layout and design

fix: Update Vite config to allow access from all hosts

feat: Add Nginx configuration for Hugging Face deployment

Dockerfile.huggingface ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM node:18-alpine AS frontend-builder
2
+
3
+ WORKDIR /app/frontend
4
+
5
+ COPY frontend/package*.json ./
6
+ RUN npm ci
7
+
8
+ COPY frontend/ .
9
+
10
+ ARG VITE_API_URL=/api
11
+ ENV VITE_API_URL=${VITE_API_URL}
12
+ RUN npm run build
13
+
14
+ # ============================================
15
+
16
+ FROM python:3.11-slim
17
+
18
+ ENV PYTHONDONTWRITEBYTECODE=1
19
+ ENV PYTHONUNBUFFERED=1
20
+
21
+ WORKDIR /app
22
+
23
+ # Install Nginx
24
+ RUN apt-get update && apt-get install -y --no-install-recommends \
25
+ nginx \
26
+ && rm -rf /var/lib/apt/lists/*
27
+
28
+ # Copy and install Python dependencies
29
+ COPY backend/requirements.txt ./
30
+ RUN pip install --no-cache-dir --upgrade pip && \
31
+ pip install --no-cache-dir -r requirements.txt
32
+
33
+ # Copy backend code
34
+ COPY backend/ ./backend/
35
+
36
+ # Copy frontend built files from builder stage
37
+ COPY --from=frontend-builder /app/frontend/dist ./frontend/dist
38
+
39
+ # Copy Nginx config for Hugging Face
40
+ COPY nginx-huggingface.conf /etc/nginx/conf.d/default.conf
41
+
42
+ # Copy startup script
43
+ COPY docker-entrypoint.sh /app/
44
+ RUN chmod +x /app/docker-entrypoint.sh
45
+
46
+ # Create data directory for SQLite
47
+ RUN mkdir -p /app/data
48
+
49
+ EXPOSE 7860
50
+
51
+ # Start both backend and frontend
52
+ ENTRYPOINT ["/app/docker-entrypoint.sh"]
FEATURES_CHECKLIST.md DELETED
@@ -1,283 +0,0 @@
1
- # 🏏 SSC - Complete Project Features & Implementation
2
-
3
- ## ✅ Core Features Implemented
4
-
5
- ### Authentication & Authorization
6
- - ✅ User registration with email validation
7
- - ✅ Secure JWT-based authentication
8
- - ✅ Password hashing with bcrypt
9
- - ✅ Admin role verification
10
- - ✅ Protected endpoints with token validation
11
- - ✅ Rate limiting on auth endpoints (5-10 req/min)
12
-
13
- ### Player Management
14
- - ✅ User profiles with bio and jersey number
15
- - ✅ View all active players
16
- - ✅ Individual player profiles with detailed stats
17
- - ✅ Update own profile information
18
- - ✅ Last login tracking
19
-
20
- ### Performance Tracking
21
- - ✅ Log match performances (runs, wickets)
22
- - ✅ Track match types (friendly, league, tournament)
23
- - ✅ Performance rating system (0-10 scale)
24
- - ✅ Match notes and opponent tracking
25
- - ✅ Automatic stats calculation:
26
- - Centuries and half-centuries tracking
27
- - Batting average calculation
28
- - Highest score tracking
29
- - Total matches played
30
- - ✅ Match history with date filtering
31
-
32
- ### Premium Subscription System
33
- - ✅ Premium membership upgrade (₹1000/month)
34
- - ✅ Auto-downgrade after 30 days expiry
35
- - ✅ Premium status checking
36
- - ✅ Membership cancellation
37
- - ✅ Payment history tracking
38
- - ✅ Premium member highlighting on dashboard
39
- - ✅ Premium expiry notifications
40
-
41
- ### Dashboard & Analytics
42
- - ✅ System overview (total players, premium members, matches, runs)
43
- - ✅ Featured premium players section
44
- - ✅ Top scorers leaderboard
45
- - ✅ Top wicket-takers leaderboard
46
- - ✅ Recently joined players
47
- - ✅ Top statistics display
48
-
49
- ### Admin Panel
50
- - ✅ View all registered users
51
- - ✅ Manually toggle user premium status
52
- - ✅ Deactivate user accounts
53
- - ✅ System statistics dashboard
54
- - ✅ Admin role protection on endpoints
55
-
56
- ### Frontend UI/UX
57
- - ✅ Responsive design for all screen sizes
58
- - ✅ Modern gradient-based styling
59
- - ✅ Navigation bar with authentication status
60
- - ✅ Home page with features and pricing
61
- - ✅ Login/Register pages with form validation
62
- - ✅ Dashboard with key metrics
63
- - ✅ Players list with filtering
64
- - ✅ Profile pages with detailed stats
65
- - ✅ Premium upgrade buttons
66
- - ✅ Loading states and error handling
67
-
68
- ## 🎁 Additional Features Implemented
69
-
70
- ### 1. **Notification System**
71
- - ✅ Premium expiry notifications
72
- - ✅ Achievement notifications (centuries, half-centuries)
73
- - ✅ Database-backed notification storage
74
- - ✅ Mark notifications as read
75
-
76
- ### 2. **Activity Logging**
77
- - ✅ Comprehensive API request logging
78
- - ✅ User action tracking
79
- - ✅ Request duration logging
80
- - ✅ Error tracking and reporting
81
- - ✅ Rotating log files (10 backups)
82
- - ✅ Activity logs stored in `logs/ssc.log`
83
-
84
- ### 3. **Rate Limiting**
85
- - ✅ Per-endpoint rate limiting with SlowAPI
86
- - ✅ Register: 5 requests/minute
87
- - ✅ Login: 10 requests/minute
88
- - ✅ Default: 30 requests/minute
89
- - ✅ Graceful error responses (429 status)
90
-
91
- ### 4. **Data Validation**
92
- - ✅ Email validation
93
- - ✅ Password strength requirements
94
- - ✅ Pydantic schema validation
95
- - ✅ Type checking on all inputs
96
- - ✅ Required field validation
97
-
98
- ### 5. **CORS Support**
99
- - ✅ Cross-origin requests enabled
100
- - ✅ All HTTP methods supported
101
- - ✅ Custom headers allowed
102
- - ✅ Credentials handling
103
-
104
- ### 6. **API Documentation**
105
- - ✅ Auto-generated Swagger/OpenAPI docs
106
- - ✅ Interactive API testing interface
107
- - ✅ Endpoint descriptions and examples
108
- - ✅ Request/response schemas
109
- - ✅ Authentication guidance
110
-
111
- ### 7. **Error Handling**
112
- - ✅ HTTP status codes (400, 401, 403, 404, 429, 500)
113
- - ✅ Meaningful error messages
114
- - ✅ Validation error details
115
- - ✅ Missing resource handlers
116
- - ✅ Authentication error responses
117
-
118
- ### 8. **Database Features**
119
- - ✅ Automatic schema creation
120
- - ✅ Foreign key relationships
121
- - ✅ Timestamps on all records
122
- - ✅ Unique constraints (email)
123
- - ✅ Indexed columns for performance
124
- - ✅ Atomic transactions
125
-
126
- ### 9. **Performance Optimizations**
127
- - ✅ Database query optimization
128
- - ✅ Proper field indexing
129
- - ✅ Connection pooling
130
- - ✅ Lazy loading relationships
131
- - ✅ Pagination support
132
-
133
- ### 10. **Security Features**
134
- - ✅ JWT token-based auth
135
- - ✅ Password hashing and salt
136
- - ✅ Admin role verification
137
- - ✅ Rate limiting
138
- - ✅ CORS protection
139
- - ✅ SQL injection prevention (ORM)
140
- - ✅ Secure headers
141
-
142
- ### 11. **Testing & Documentation**
143
- - ✅ Sample test data loader
144
- - ✅ Test accounts with different roles
145
- - ✅ API documentation with curl examples
146
- - ✅ Quick start guide
147
- - ✅ Project structure documentation
148
- - ✅ Database schema docs
149
-
150
- ### 12. **Deployment Ready**
151
- - ✅ Docker support (backend + frontend)
152
- - ✅ Docker Compose setup
153
- - ✅ Environment variable configuration
154
- - ✅ Production-ready settings
155
- - ✅ Multi-container orchestration
156
-
157
- ## 📊 Statistics Module
158
- - ✅ Career runs total
159
- - ✅ Matches played
160
- - ✅ Wickets taken
161
- - ✅ Centuries scored
162
- - ✅ Half-centuries scored
163
- - ✅ Strike rate / Batting average
164
- - ✅ Highest score
165
- - ✅ Performance rating
166
-
167
- ## 🎯 Ranking & Leaderboards
168
- - ✅ Top 10 scorers by runs
169
- - ✅ Top wicket-takers
170
- - ✅ Premium player filtering
171
- - ✅ Active player filtering
172
- - ✅ Sortable by multiple criteria
173
-
174
- ## 👥 User Roles
175
- - ✅ Player (default)
176
- - ✅ Premium Player
177
- - ✅ Admin
178
-
179
- ## 🔔 Notification Types
180
- - ✅ Premium expiry alerts
181
- - ✅ Achievement unlocked
182
- - ✅ New feature announcements
183
- - ✅ Custom notification system
184
-
185
- ## 📱 Responsive Components
186
- - ✅ Mobile-first design
187
- - ✅ Grid-based layouts
188
- - ✅ Touch-friendly buttons
189
- - ✅ Readable text sizes
190
- - ✅ Proper spacing
191
-
192
- ## 🎨 Frontend Features
193
- - ✅ Dark/light color scheme ready
194
- - ✅ CSS modules (scoped styling)
195
- - ✅ Gradient backgrounds
196
- - ✅ Hover effects
197
- - ✅ Transitions and animations
198
- - ✅ Form validation
199
- - ✅ Loading indicators
200
- - ✅ Error messages
201
-
202
- ## 📁 Project Files
203
-
204
- ### Backend
205
- - 30+ Python files
206
- - Complete API with 20+ endpoints
207
- - SQLAlchemy models
208
- - Pydantic schemas
209
- - Utility functions
210
- - Middleware layer
211
-
212
- ### Frontend
213
- - 7+ React components
214
- - 5+ pages
215
- - API service layer
216
- - CSS modules
217
- - Responsive design
218
- - Client-side routing
219
-
220
- ### Documentation
221
- - Comprehensive README (3000+ words)
222
- - API Documentation (2500+ words)
223
- - Quick Start Guide (1500+ words)
224
- - Project Structure docs
225
- - Complete Feature List
226
-
227
- ## 🚀 Ready for Production
228
-
229
- - ✅ Error handling
230
- - ✅ Logging system
231
- - ✅ Security measures
232
- - ✅ Rate limiting
233
- - ✅ Database transactions
234
- - ✅ Input validation
235
- - ✅ Authentication/Authorization
236
- - ✅ API documentation
237
- - ✅ Docker support
238
- - ✅ Environment configuration
239
-
240
- ## 🧪 Test Accounts Created
241
-
242
- ```
243
- Player 1: virat@ssc.com / password123
244
- Player 2: bumrah@ssc.com / password123
245
- Premium: rohit@ssc.com / password123
246
- Admin: admin@ssc.com / admin123
247
- ```
248
-
249
- ## 📋 Database Tables
250
- 1. Users (with 18+ fields)
251
- 2. Payments
252
- 3. Performance Logs
253
- 4. Notifications
254
-
255
- ## 🎓 Learning Resources Included
256
-
257
- - Complete code examples
258
- - API usage patterns
259
- - Database design
260
- - Authentication flow
261
- - Frontend architecture
262
- - Component structure
263
- - State management patterns
264
- - Error handling
265
- - Form validation
266
-
267
- ---
268
-
269
- ## Summary
270
-
271
- This is a **production-ready SaaS application** with:
272
- - ✨ 50+ implemented features
273
- - 📚 Comprehensive documentation
274
- - 🔒 Enterprise-grade security
275
- - 📱 Responsive UI
276
- - 🚀 Docker deployment ready
277
- - 📊 Analytics and reporting
278
- - 👥 User management
279
- - 💳 Subscription system
280
- - 🏆 Competitive features (leaderboards)
281
- - 🎯 Performance tracking
282
-
283
- Total code: **5000+ lines** across backend and frontend!
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
PROJECT_STRUCTURE.md DELETED
@@ -1,213 +0,0 @@
1
- # Project Structure
2
-
3
- ```
4
- SSC/
5
- ├── backend/ # FastAPI Backend
6
- │ ├── app/
7
- │ │ ├── __init__.py
8
- │ │ ├── config.py # Configuration settings
9
- │ │ ├── database.py # Database setup
10
- │ │ ├── models/ # SQLAlchemy models
11
- │ │ │ ├── user.py
12
- │ │ │ ├── payment.py
13
- │ │ │ ├── performance_log.py
14
- │ │ │ └── notification.py
15
- │ │ ├── routes/ # API endpoints
16
- │ │ │ ├── auth.py # Authentication
17
- │ │ │ ├── players.py # Player management
18
- │ │ │ ├── premium.py # Premium subscriptions
19
- │ │ │ ├── performance.py # Performance tracking
20
- │ │ │ ├── dashboard.py # Dashboard
21
- │ │ │ └── admin.py # Admin functions
22
- │ │ ├── schemas/ # Pydantic schemas
23
- │ │ │ ├── user.py
24
- │ │ │ ├── payment.py
25
- │ │ │ ├── performance.py
26
- │ │ │ └── notification.py
27
- │ │ ├── utils/ # Utility functions
28
- │ │ │ ├── auth.py # Auth helpers
29
- │ │ │ ├── premium.py # Premium logic
30
- │ │ │ └── logger.py # Logging
31
- │ │ └── middleware/ # Middleware
32
- │ │ ├── __init__.py # Rate limiting, logging
33
- │ │ └── auth.py # Authentication middleware
34
- │ ├── main.py # FastAPI app entry
35
- │ ├── requirements.txt # Python dependencies
36
- │ ├── .env # Environment variables
37
- │ ├── .env.example # Example env file
38
- │ ├── Dockerfile # Docker configuration
39
- │ ├── load_test_data.py # Test data loader
40
- │ └── logs/ # Log files (created at runtime)
41
- │
42
- ├── frontend/ # React Frontend
43
- │ ├── src/
44
- │ │ ├── components/ # React components
45
- │ │ │ ├── Navbar.jsx
46
- │ │ │ └── navbar.module.css
47
- │ │ ├── pages/ # Page components
48
- │ │ │ ├── Home.jsx
49
- │ │ │ ├── Auth.jsx
50
- │ │ │ ├── Dashboard.jsx
51
- │ │ │ ├── Players.jsx
52
- │ │ │ ├── Profile.jsx
53
- │ │ │ ├── home.module.css
54
- │ │ │ ├── auth.module.css
55
- │ │ │ ├── dashboard.module.css
56
- │ │ │ ├── players.module.css
57
- │ │ │ └── profile.module.css
58
- │ │ ├── utils/ # Utility functions
59
- │ │ │ └── api.js # API service
60
- │ │ ├── styles/ # Global styles
61
- │ │ │ ├── global.css
62
- │ │ │ └── theme.js
63
- │ │ ├── App.jsx # Main app component
64
- │ │ └── main.jsx # React entry point
65
- │ ├── index.html # HTML template
66
- │ ├── vite.config.js # Vite configuration
67
- │ ├── package.json # Node dependencies
68
- │ ├── .env # Environment variables
69
- │ ├── .env.example # Example env file
70
- │ ├── .eslintrc.json # ESLint config
71
- │ ├── Dockerfile # Docker configuration
72
- │ └── node_modules/ # Dependencies (created after npm install)
73
- │
74
- ├── docker-compose.yml # Docker compose setup
75
- ├── .gitignore # Git ignore patterns
76
- ├── README.md # Project documentation
77
- ├── QUICK_START.md # Quick start guide
78
- ├── API_DOCUMENTATION.md # API documentation
79
- └── PROJECT_STRUCTURE.md # This file
80
-
81
- ```
82
-
83
- ## Key Directories
84
-
85
- ### Backend (`backend/`)
86
- - **app/models**: SQLAlchemy ORM models for database tables
87
- - **app/routes**: FastAPI route handlers for all endpoints
88
- - **app/schemas**: Pydantic models for request/response validation
89
- - **app/utils**: Helper functions for auth, premium logic, logging
90
- - **app/middleware**: Custom middleware for auth, rate limiting, logging
91
- - **main.py**: FastAPI application entrypoint
92
-
93
- ### Frontend (`frontend/`)
94
- - **src/components**: Reusable React components
95
- - **src/pages**: Full-page components (Home, Dashboard, etc.)
96
- - **src/utils/api.js**: Axios-based API client
97
- - **src/styles**: CSS modules and theme configuration
98
-
99
- ## Database Schema
100
-
101
- ### Users Table
102
- ```
103
- id (PK)
104
- name, email, password
105
- jersey_number, role (player/admin), bio
106
- runs, matches, wickets, centuries, half_centuries
107
- average_runs, highest_score
108
- is_premium, premium_expiry, premium_start_date
109
- is_active
110
- created_at, updated_at, last_login
111
- ```
112
-
113
- ### Payments Table
114
- ```
115
- id (PK)
116
- user_id (FK)
117
- amount, payment_method, transaction_id
118
- status, plan_duration_days
119
- created_at, updated_at
120
- ```
121
-
122
- ### Performance Logs Table
123
- ```
124
- id (PK)
125
- user_id (FK)
126
- match_date
127
- runs_scored, wickets_taken
128
- match_type, opponent
129
- performance_rating, notes
130
- created_at
131
- ```
132
-
133
- ### Notifications Table
134
- ```
135
- id (PK)
136
- user_id (FK)
137
- title, message
138
- notification_type, is_read
139
- created_at
140
- ```
141
-
142
- ## API Route Structure
143
-
144
- ```
145
- Authentication
146
- ├── POST /auth/register
147
- └── POST /auth/login
148
-
149
- Players
150
- ├── GET /players/me
151
- ├── PUT /players/me
152
- ├── GET /players/{id}
153
- ├── GET /players
154
- ├── GET /players/leaderboard/top-performers
155
- └── GET /players/leaderboard/by-wickets
156
-
157
- Premium
158
- ├── POST /premium/upgrade
159
- ├── GET /premium/status
160
- ├── POST /premium/cancel
161
- └── GET /premium/payments
162
-
163
- Performance
164
- ├── POST /performance
165
- ├── GET /performance/my-logs
166
- ├── GET /performance/player/{id}
167
- └── GET /performance/stats/{id}
168
-
169
- Dashboard
170
- ├── GET /dashboard/overview
171
- ├── GET /dashboard/featured-players
172
- ├── GET /dashboard/recent-players
173
- └── GET /dashboard/top-stats
174
-
175
- Admin
176
- ├── GET /admin/users
177
- ├── PUT /admin/users/{id}/premium
178
- ├── DELETE /admin/users/{id}
179
- └── GET /admin/stats
180
- ```
181
-
182
- ## Technology Stack
183
-
184
- **Backend:**
185
- - FastAPI 0.104.1
186
- - SQLAlchemy 2.0.23
187
- - Pydantic 2.5.0
188
- - PassLib + bcrypt (authentication)
189
- - JWT (token management)
190
- - SlowAPI (rate limiting)
191
- - SQLite
192
-
193
- **Frontend:**
194
- - React 18.2.0
195
- - React Router 6.20.0
196
- - Axios 1.6.0
197
- - Chart.js (data visualization)
198
- - Vite (build tool)
199
- - CSS Modules (styling)
200
-
201
- ## Configuration Files
202
-
203
- - `.env`: Runtime environment variables
204
- - `vite.config.js`: Frontend build configuration
205
- - `package.json`: Node dependencies and scripts
206
- - `requirements.txt`: Python dependencies
207
- - `docker-compose.yml`: Multi-container setup
208
-
209
- ## Getting Started
210
-
211
- 1. See [QUICK_START.md](./QUICK_START.md) for immediate setup
212
- 2. See [README.md](./README.md) for full documentation
213
- 3. See [API_DOCUMENTATION.md](./API_DOCUMENTATION.md) for API details
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
QUICK_START.md DELETED
@@ -1,265 +0,0 @@
1
- # SSC Quick Start Guide
2
-
3
- ## 🚀 Getting Started (5 Minutes)
4
-
5
- ### 1. Backend Setup
6
-
7
- ```bash
8
- # Navigate to backend
9
- cd backend
10
-
11
- # Create virtual environment
12
- python -m venv venv
13
-
14
- # Activate virtual environment
15
- # On Windows:
16
- venv\Scripts\activate
17
- # On Mac/Linux:
18
- source venv/bin/activate
19
-
20
- # Install dependencies
21
- pip install -r requirements.txt
22
-
23
- # Load test data (optional)
24
- python load_test_data.py
25
-
26
- # Start server
27
- python -m uvicorn main:app --reload
28
- ```
29
-
30
- ✅ Backend running at: http://localhost:8000
31
- 📚 API Docs: http://localhost:8000/docs
32
-
33
- ### 2. Frontend Setup
34
-
35
- In a new terminal:
36
-
37
- ```bash
38
- # Navigate to frontend
39
- cd frontend
40
-
41
- # Install dependencies
42
- npm install
43
-
44
- # Start development server
45
- npm run dev
46
- ```
47
-
48
- ✅ Frontend running at: http://localhost:3000
49
-
50
- ---
51
-
52
- ## 📝 Test Accounts
53
-
54
- Use these credentials to test the application:
55
-
56
- ### Regular Player
57
- - **Email**: virat@ssc.com
58
- - **Password**: password123
59
-
60
- ### Premium Player
61
- - **Email**: rohit@ssc.com
62
- - **Password**: password123
63
-
64
- ### Admin User
65
- - **Email**: admin@ssc.com
66
- - **Password**: admin123
67
-
68
- ---
69
-
70
- ## 🧪 Testing the API
71
-
72
- ### 1. Register a New Player
73
-
74
- ```bash
75
- curl -X POST "http://localhost:8000/auth/register" \
76
- -H "Content-Type: application/json" \
77
- -d '{
78
- "name": "Test Player",
79
- "email": "test@ssc.com",
80
- "password": "testpass123"
81
- }'
82
- ```
83
-
84
- ### 2. Login
85
-
86
- ```bash
87
- curl -X POST "http://localhost:8000/auth/login" \
88
- -H "Content-Type: application/json" \
89
- -d '{
90
- "email": "test@ssc.com",
91
- "password": "testpass123"
92
- }'
93
- ```
94
-
95
- Copy the `access_token` from the response.
96
-
97
- ### 3. Get Player Profile
98
-
99
- ```bash
100
- curl -X GET "http://localhost:8000/players/me" \
101
- -H "Authorization: Bearer YOUR_TOKEN_HERE"
102
- ```
103
-
104
- ### 4. Log Performance
105
-
106
- ```bash
107
- curl -X POST "http://localhost:8000/performance" \
108
- -H "Authorization: Bearer YOUR_TOKEN_HERE" \
109
- -H "Content-Type: application/json" \
110
- -d '{
111
- "match_date": "2024-01-15T14:00:00",
112
- "runs_scored": 50,
113
- "wickets_taken": 0,
114
- "match_type": "league",
115
- "opponent": "Team A",
116
- "performance_rating": 8.0,
117
- "notes": "Great batting"
118
- }'
119
- ```
120
-
121
- ### 5. Upgrade to Premium
122
-
123
- ```bash
124
- curl -X POST "http://localhost:8000/premium/upgrade" \
125
- -H "Authorization: Bearer YOUR_TOKEN_HERE" \
126
- -H "Content-Type: application/json" \
127
- -d '{
128
- "plan_days": 30
129
- }'
130
- ```
131
-
132
- ---
133
-
134
- ## 🎯 Key Features to Try
135
-
136
- ### On Dashboard
137
- 1. View all players
138
- 2. Check featured premium players
139
- 3. See top scorers and wicket-takers
140
- 4. View system statistics
141
-
142
- ### In Player Profile
143
- 1. View personal statistics
144
- 2. See performance history
145
- 3. Upgrade to premium membership
146
- 4. Track achievements
147
-
148
- ### In Admin Panel
149
- 1. View all registered users
150
- 2. Toggle user premium status
151
- 3. Deactivate users
152
- 4. Check system statistics
153
-
154
- ---
155
-
156
- ## 🔧 Troubleshooting
157
-
158
- ### Backend won't start
159
- ```bash
160
- # Clear any cached Python files
161
- find . -type d -name __pycache__ -exec rm -r {} +
162
-
163
- # Ensure all dependencies are installed
164
- pip install -r requirements.txt
165
-
166
- # Check if port 8000 is already in use
167
- # Change port: uvicorn main:app --reload --port 8001
168
- ```
169
-
170
- ### Frontend won't start
171
- ```bash
172
- # Clear node_modules and reinstall
173
- rm -rf node_modules package-lock.json
174
- npm install
175
-
176
- # Try different port
177
- npm run dev -- --port 3001
178
- ```
179
-
180
- ### Database errors
181
- ```bash
182
- # Reinitialize database
183
- rm ssc.db
184
- python load_test_data.py
185
- ```
186
-
187
- ### Token issues
188
- - Ensure token is copied correctly (no extra spaces)
189
- - Token expires after 30 minutes
190
- - Re-login to get a new token
191
-
192
- ---
193
-
194
- ## 📚 API Usage Examples
195
-
196
- ### JavaScript/React Example
197
-
198
- ```javascript
199
- // Login
200
- const response = await fetch('http://localhost:8000/auth/login', {
201
- method: 'POST',
202
- headers: { 'Content-Type': 'application/json' },
203
- body: JSON.stringify({
204
- email: 'virat@ssc.com',
205
- password: 'password123'
206
- })
207
- });
208
-
209
- const data = await response.json();
210
- localStorage.setItem('token', data.access_token);
211
-
212
- // Get profile
213
- const profileRes = await fetch('http://localhost:8000/players/me', {
214
- headers: {
215
- 'Authorization': `Bearer ${localStorage.getItem('token')}`
216
- }
217
- });
218
-
219
- const profile = await profileRes.json();
220
- console.log(profile);
221
- ```
222
-
223
- ---
224
-
225
- ## 🚀 Next Steps
226
-
227
- 1. **Explore API Documentation**: Visit http://localhost:8000/docs
228
- 2. **Test all endpoints**: Use the Swagger UI
229
- 3. **Build custom features**: Extend the frontend
230
- 4. **Integrate payments**: Add Razorpay integration
231
- 5. **Deploy**: Use Docker or cloud services
232
-
233
- ---
234
-
235
- ## 📖 Documentation
236
-
237
- - [Full README](./README.md)
238
- - [API Documentation](./API_DOCUMENTATION.md)
239
- - [Backend Code](./backend/)
240
- - [Frontend Code](./frontend/)
241
-
242
- ---
243
-
244
- ## ❓ Need Help?
245
-
246
- Check the logs:
247
-
248
- ```bash
249
- # Backend logs
250
- tail -f logs/ssc.log
251
-
252
- # Frontend console errors
253
- # Open browser DevTools (F12)
254
- ```
255
-
256
- For errors, check:
257
- 1. Correct .env variables
258
- 2. Database initialization
259
- 3. Port availability
260
- 4. CORS configuration
261
- 5. Token validity
262
-
263
- ---
264
-
265
- Happy Testing! 🏏⭐
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
README.md CHANGED
@@ -1,3 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
1
  # SSC - Sculpt Soft Cricketers
2
 
3
  A complete web-based player management and performance tracking system for cricket players. Built with FastAPI backend and React frontend, featuring a freemium subscription model.
@@ -215,26 +226,64 @@ Premium membership auto-downgrades after 30 days.
215
  - Deactivate users
216
  - View system statistics
217
 
218
- ## 🐳 Docker Setup (Optional)
 
 
219
 
220
  ```bash
221
- docker-compose up -d
222
  ```
223
 
224
- This will start both backend and frontend containers.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
225
 
226
  ## 📖 Environment Variables
227
 
228
  ### Backend (.env)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
229
  ```
230
- DATABASE_URL=sqlite:///./ssc.db
231
- SECRET_KEY=your-secret-key
232
- ALGORITHM=HS256
233
- ACCESS_TOKEN_EXPIRE_MINUTES=30
234
- PREMIUM_COST=1000
235
- PREMIUM_DURATION_DAYS=30
236
  ```
237
 
 
 
238
  ## 🧪 Testing
239
 
240
  ### Test Authentication
@@ -252,18 +301,62 @@ curl -X GET "http://localhost:8000/players/me" \
252
 
253
  ## 🚀 Deployment
254
 
255
- ### Backend
256
- The backend can be deployed on:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
257
  - Heroku
258
  - AWS EC2
259
  - Google Cloud Run
260
  - DigitalOcean
 
261
 
262
- ### Frontend
263
- The frontend can be deployed on:
264
- - Vercel
265
  - Netlify
266
- - AWS S3
267
  - GitHub Pages
268
 
269
  ## 🔒 Security Features
 
1
+ ---
2
+ title: SSC
3
+ emoji: 📉
4
+ colorFrom: purple
5
+ colorTo: yellow
6
+ sdk: docker
7
+ pinned: false
8
+ license: mit
9
+ short_description: SculptSoft Cricketers
10
+ ---
11
+
12
  # SSC - Sculpt Soft Cricketers
13
 
14
  A complete web-based player management and performance tracking system for cricket players. Built with FastAPI backend and React frontend, featuring a freemium subscription model.
 
226
  - Deactivate users
227
  - View system statistics
228
 
229
+ ## 🐳 Docker Setup
230
+
231
+ ### Development (hot reload)
232
 
233
  ```bash
234
+ docker-compose up -d --build
235
  ```
236
 
237
+ This starts backend on `http://localhost:8000` and frontend on `http://localhost:3000`.
238
+
239
+ ### Production-ready (Nginx + Gunicorn)
240
+
241
+ 1. Copy backend env template:
242
+ ```bash
243
+ cp backend/.env.example backend/.env
244
+ ```
245
+
246
+ 2. Update secrets in `backend/.env`:
247
+ - `SECRET_KEY`
248
+ - `ADMIN_PASSWORD`
249
+ - `CORS_ORIGINS` (set your real frontend domain)
250
+
251
+ 3. Build and run production stack:
252
+ ```bash
253
+ docker compose -f docker-compose.prod.yml up -d --build
254
+ ```
255
+
256
+ 4. Open app at `http://localhost`.
257
+
258
+ Production stack includes:
259
+ - Frontend served by Nginx on port 80
260
+ - Reverse proxy `/api` -> backend service
261
+ - Backend served by Gunicorn + Uvicorn workers
262
+ - Persistent SQLite volume `ssc-db-data`
263
 
264
  ## 📖 Environment Variables
265
 
266
  ### Backend (.env)
267
+
268
+ Use `backend/.env.example` as base.
269
+
270
+ Important variables:
271
+ ```
272
+ DATABASE_URL=sqlite:////app/data/ssc.db
273
+ SECRET_KEY=CHANGE_THIS
274
+ DEBUG=False
275
+ CORS_ORIGINS=https://your-frontend-domain.com
276
+ ```
277
+
278
+ ### Frontend (.env)
279
+
280
+ For development:
281
  ```
282
+ VITE_API_URL=http://localhost:8000
 
 
 
 
 
283
  ```
284
 
285
+ For production Docker build, frontend uses `/api` via Nginx proxy.
286
+
287
  ## 🧪 Testing
288
 
289
  ### Test Authentication
 
301
 
302
  ## 🚀 Deployment
303
 
304
+ ### Option 1: Hugging Face Spaces (Easiest - Both Backend + Frontend)
305
+
306
+ 1. **Create Hugging Face account** and new Space (Docker)
307
+
308
+ 2. **Copy/create required files in Space repo:**
309
+ ```bash
310
+ Dockerfile.huggingface
311
+ docker-entrypoint.sh
312
+ nginx-huggingface.conf
313
+ backend/
314
+ frontend/
315
+ ```
316
+
317
+ 3. **Rename or use Dockerfile as:**
318
+ ```bash
319
+ cp Dockerfile.huggingface Dockerfile
320
+ chmod +x docker-entrypoint.sh
321
+ ```
322
+
323
+ 4. **Set secrets in Space settings:**
324
+ - `SECRET_KEY`: Generate strong random string
325
+ - `ADMIN_PASSWORD`: Your secure admin password
326
+
327
+ 5. **Push to Hugging Face repo** - Space auto-builds and deploys
328
+
329
+ 6. **Access your app:**
330
+ ```
331
+ https://huggingface.co/spaces/{your-username}/{your-space-name}
332
+ ```
333
+
334
+ Your app runs on port 7860 with:
335
+ - Frontend: Served by Nginx
336
+ - Backend: Internal port 8000
337
+ - API proxy: `/api` → backend
338
+ - Docs still available at `/docs`
339
+
340
+ ### Option 2: Docker Compose (Local or VPS)
341
+
342
+ ```bash
343
+ docker compose -f docker-compose.prod.yml up -d --build
344
+ ```
345
+ Access at `http://localhost`
346
+
347
+ ### Option 3: Separate Deployment
348
+
349
+ **Backend:**
350
  - Heroku
351
  - AWS EC2
352
  - Google Cloud Run
353
  - DigitalOcean
354
+ - Railway.app
355
 
356
+ **Frontend:**
357
+ - Vercel (recommended)
 
358
  - Netlify
359
+ - AWS S3 + CloudFront
360
  - GitHub Pages
361
 
362
  ## 🔒 Security Features
SETUP_COMPLETE.md DELETED
@@ -1,389 +0,0 @@
1
- # 🏏 SSC - Complete Application Setup
2
-
3
- ## ✅ Setup Complete!
4
-
5
- Your **SSC (Sculpt Soft Cricketers)** application has been fully created with:
6
-
7
- ### 📦 What's Included
8
-
9
- #### Backend (FastAPI)
10
- - **30+ Python files** with complete API implementation
11
- - **6 API modules**: Auth, Players, Premium, Performance, Dashboard, Admin
12
- - **4 Database models**: User, Payment, PerformanceLog, Notification
13
- - **SQLite database** with automatic initialization
14
- - **JWT authentication** with role-based access
15
- - **Rate limiting** on all endpoints
16
- - **Comprehensive logging** system
17
- - **Test data loader** with sample users
18
-
19
- #### Frontend (React)
20
- - **5 complete pages**: Home, Auth, Dashboard, Players, Profile
21
- - **Responsive design** with CSS modules
22
- - **Axios API client** with token management
23
- - **React Router v6** navigation
24
- - **Modern UI/UX** with gradient styling
25
- - **Form validation** and error handling
26
-
27
- #### Documentation
28
- - 📖 **README.md** - Complete project guide
29
- - 📖 **QUICK_START.md** - 5-minute setup
30
- - 📖 **API_DOCUMENTATION.md** - All endpoints documented
31
- - 📖 **PROJECT_STRUCTURE.md** - Architecture details
32
- - 📖 **FEATURES_CHECKLIST.md** - 50+ implemented features
33
-
34
- ---
35
-
36
- ## 🚀 Quick Start (5 Minutes)
37
-
38
- ### 1. Start Backend
39
-
40
- ```bash
41
- cd backend
42
-
43
- # Windows
44
- python -m venv venv
45
- venv\Scripts\activate
46
-
47
- # Mac/Linux
48
- python -m venv venv
49
- source venv/bin/activate
50
-
51
- # Install dependencies
52
- pip install -r requirements.txt
53
-
54
- # Load test data (optional)
55
- python load_test_data.py
56
-
57
- # Start server
58
- python -m uvicorn main:app --reload
59
- ```
60
-
61
- ✅ Backend running at: `http://localhost:8000`
62
- 📚 API Docs: `http://localhost:8000/docs`
63
-
64
- ### 2. Start Frontend (in new terminal)
65
-
66
- ```bash
67
- cd frontend
68
- npm install
69
- npm run dev
70
- ```
71
-
72
- ✅ Frontend running at: `http://localhost:3000`
73
-
74
- ---
75
-
76
- ## 🔑 Test Accounts
77
-
78
- Login with these credentials:
79
-
80
- | Role | Email | Password |
81
- |------|-------|----------|
82
- | Player | virat@ssc.com | password123 |
83
- | Premium | rohit@ssc.com | password123 |
84
- | Admin | admin@ssc.com | admin123 |
85
-
86
- ---
87
-
88
- ## 🎯 Features Implemented
89
-
90
- ### Core Features
91
- - ✅ User registration & authentication
92
- - ✅ Player profiles with statistics
93
- - ✅ Performance tracking (runs, wickets)
94
- - ✅ Premium membership (₹1000/month)
95
- - ✅ Leaderboards & rankings
96
- - ✅ Dashboard with analytics
97
- - ✅ Admin panel
98
- - ✅ Notification system
99
-
100
- ### Additional Features
101
- - ✅ Activity logging
102
- - ✅ Rate limiting
103
- - ✅ Error handling
104
- - ✅ Data validation
105
- - ✅ CORS support
106
- - ✅ API documentation
107
- - ✅ Docker support
108
- - ✅ Environment configuration
109
-
110
- ---
111
-
112
- ## 📊 Database
113
-
114
- The application uses **SQLite** with these tables:
115
-
116
- 1. **Users** - Player profiles and stats
117
- 2. **Payments** - Subscription payments
118
- 3. **PerformanceLogs** - Match records
119
- 4. **Notifications** - User notifications
120
-
121
- Database file: `backend/ssc.db` (created automatically)
122
-
123
- ---
124
-
125
- ## 🔌 API Endpoints
126
-
127
- ### Authentication
128
- - `POST /auth/register` - Register
129
- - `POST /auth/login` - Login
130
-
131
- ### Players
132
- - `GET /players/me` - Current player
133
- - `PUT /players/me` - Update profile
134
- - `GET /players` - All players
135
- - `GET /players/leaderboard/top-performers` - Top scorers
136
- - `GET /players/leaderboard/by-wickets` - Top bowlers
137
-
138
- ### Premium
139
- - `POST /premium/upgrade` - Upgrade membership
140
- - `GET /premium/status` - Check status
141
- - `POST /premium/cancel` - Cancel
142
-
143
- ### Performance
144
- - `POST /performance` - Log match
145
- - `GET /performance/my-logs` - Own logs
146
- - `GET /performance/stats/{id}` - Player stats
147
-
148
- ### Dashboard
149
- - `GET /dashboard/overview` - System stats
150
- - `GET /dashboard/featured-players` - Premium players
151
- - `GET /dashboard/top-stats` - Top performers
152
-
153
- ### Admin
154
- - `GET /admin/users` - All users
155
- - `PUT /admin/users/{id}/premium` - Toggle premium
156
- - `DELETE /admin/users/{id}` - Deactivate
157
- - `GET /admin/stats` - System stats
158
-
159
- ---
160
-
161
- ## 📁 Project Structure
162
-
163
- ```
164
- SSC/
165
- ├── backend/ # FastAPI backend
166
- │ ├── app/
167
- │ │ ├── models/ # Database models
168
- │ │ ├── routes/ # API endpoints
169
- │ │ ├── schemas/ # Request/response schemas
170
- │ │ ├── utils/ # Helper functions
171
- │ │ ├── middleware/ # Auth & logging
172
- │ │ ├── config.py # Configuration
173
- │ │ └── database.py # Database setup
174
- │ ├── main.py # FastAPI app
175
- │ ├── requirements.txt # Dependencies
176
- │ └── load_test_data.py # Test data loader
177
- ├── frontend/ # React frontend
178
- │ ├── src/
179
- │ │ ├── components/ # React components
180
- │ │ ├── pages/ # Full pages
181
- │ │ ├── utils/ # API client
182
- │ │ ├── styles/ # CSS & theme
183
- │ │ ├── App.jsx # Main app
184
- │ │ └── main.jsx # Entry point
185
- │ ├── package.json # Dependencies
186
- │ └── vite.config.js # Build config
187
- ├── README.md # Full documentation
188
- ├── QUICK_START.md # Setup guide
189
- ├── API_DOCUMENTATION.md # API docs
190
- └── docker-compose.yml # Docker setup
191
- ```
192
-
193
- ---
194
-
195
- ## 🔧 Configuration
196
-
197
- ### Backend (.env)
198
- ```
199
- DATABASE_URL=sqlite:///./ssc.db
200
- SECRET_KEY=ssc-dev-secret-key
201
- ALGORITHM=HS256
202
- ACCESS_TOKEN_EXPIRE_MINUTES=30
203
- PREMIUM_COST=1000
204
- PREMIUM_DURATION_DAYS=30
205
- ```
206
-
207
- ### Frontend (.env)
208
- ```
209
- VITE_API_URL=http://localhost:8000
210
- VITE_APP_TITLE=SSC - Sculpt Soft Cricketers
211
- ```
212
-
213
- ---
214
-
215
- ## 🧪 Testing
216
-
217
- ### Test the API with curl:
218
-
219
- ```bash
220
- # Register
221
- curl -X POST "http://localhost:8000/auth/register" \
222
- -H "Content-Type: application/json" \
223
- -d '{"name":"Test","email":"test@example.com","password":"pass123"}'
224
-
225
- # Login
226
- curl -X POST "http://localhost:8000/auth/login" \
227
- -H "Content-Type: application/json" \
228
- -d '{"email":"test@example.com","password":"pass123"}'
229
-
230
- # Get profile (use token from login)
231
- curl -X GET "http://localhost:8000/players/me" \
232
- -H "Authorization: Bearer TOKEN_HERE"
233
- ```
234
-
235
- ---
236
-
237
- ## 🐳 Docker Setup
238
-
239
- ```bash
240
- # Start both backend and frontend
241
- docker-compose up -d
242
-
243
- # Stop containers
244
- docker-compose down
245
-
246
- # View logs
247
- docker-compose logs -f
248
- ```
249
-
250
- ---
251
-
252
- ## 🚀 Production Deployment
253
-
254
- The application is ready for deployment on:
255
- - Heroku
256
- - AWS
257
- - DigitalOcean
258
- - Google Cloud
259
- - Azure
260
-
261
- See `README.md` for deployment instructions.
262
-
263
- ---
264
-
265
- ## 📚 Documentation Files
266
-
267
- Read these in order:
268
-
269
- 1. 📖 **QUICK_START.md** - Get running in 5 minutes
270
- 2. 📖 **README.md** - Complete documentation
271
- 3. 📖 **API_DOCUMENTATION.md** - All API endpoints
272
- 4. 📖 **PROJECT_STRUCTURE.md** - Architecture
273
- 5. 📖 **FEATURES_CHECKLIST.md** - All features
274
-
275
- ---
276
-
277
- ## 🎓 Learning Outcomes
278
-
279
- This project teaches:
280
- - FastAPI REST API development
281
- - SQLAlchemy ORM usage
282
- - JWT authentication
283
- - React component architecture
284
- - API integration from frontend
285
- - Database design
286
- - Security best practices
287
- - Error handling
288
- - Logging systems
289
- - Docker containerization
290
-
291
- ---
292
-
293
- ## ⚡ Performance Features
294
-
295
- - ✅ Database query optimization
296
- - ✅ Connection pooling
297
- - ✅ Pagination support
298
- - ✅ Rate limiting
299
- - ✅ Efficient data serialization
300
- - ✅ Async-ready architecture
301
-
302
- ---
303
-
304
- ## 🔒 Security Features
305
-
306
- - ✅ Password hashing (bcrypt)
307
- - ✅ JWT token authentication
308
- - ✅ CORS protection
309
- - ✅ Rate limiting
310
- - ✅ SQL injection prevention
311
- - ✅ Admin role verification
312
- - ✅ Secure headers
313
-
314
- ---
315
-
316
- ## 💡 Customization
317
-
318
- ### Add New Features:
319
-
320
- **Add a new API endpoint:**
321
- 1. Create model in `backend/app/models/`
322
- 2. Create schema in `backend/app/schemas/`
323
- 3. Create routes in `backend/app/routes/`
324
- 4. Import in `backend/main.py`
325
-
326
- **Add a new React page:**
327
- 1. Create component in `frontend/src/pages/`
328
- 2. Create CSS module
329
- 3. Import in `frontend/src/App.jsx`
330
- 4. Add routing
331
-
332
- ---
333
-
334
- ## 🐛 Troubleshooting
335
-
336
- ### Backend won't start?
337
- ```bash
338
- # Clear cache
339
- find . -type d -name __pycache__ -exec rm -r {} +
340
-
341
- # Reinstall dependencies
342
- pip install --force-reinstall -r requirements.txt
343
- ```
344
-
345
- ### Frontend won't start?
346
- ```bash
347
- # Clear node_modules
348
- rm -rf node_modules package-lock.json
349
- npm install
350
- ```
351
-
352
- ### Database errors?
353
- ```bash
354
- # Reset database
355
- rm backend/ssc.db
356
- python backend/load_test_data.py
357
- ```
358
-
359
- ---
360
-
361
- ## 📞 Support
362
-
363
- - Check **README.md** for detailed docs
364
- - Check **API_DOCUMENTATION.md** for endpoint details
365
- - Check **QUICK_START.md** for common issues
366
- - Run `python verify_setup.py` to check files
367
-
368
- ---
369
-
370
- ## 🎉 You're All Set!
371
-
372
- Everything is ready to run. Start both servers and begin building!
373
-
374
- ```bash
375
- # Terminal 1: Backend
376
- cd backend && python -m uvicorn main:app --reload
377
-
378
- # Terminal 2: Frontend
379
- cd frontend && npm run dev
380
- ```
381
-
382
- Visit **http://localhost:3000** to see your app! 🚀
383
-
384
- ---
385
-
386
- **Created**: March 2024
387
- **Framework**: FastAPI + React
388
- **Database**: SQLite
389
- **Status**: ✅ Production Ready
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
backend/.dockerignore ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ __pycache__/
2
+ *.pyc
3
+ *.pyo
4
+ *.pyd
5
+ *.db
6
+ *.sqlite3
7
+ venv/
8
+ .env
9
+ .git
10
+ .gitignore
11
+ .vscode/
12
+ pytest_cache/
backend/.env.example CHANGED
@@ -1,12 +1,16 @@
1
- DATABASE_URL=sqlite:///./ssc.db
2
- SECRET_KEY=your-secret-key-change-in-production
3
  ALGORITHM=HS256
4
  ACCESS_TOKEN_EXPIRE_MINUTES=30
5
  PREMIUM_COST=1000
6
  PREMIUM_DURATION_DAYS=30
7
  SMTP_SERVER=smtp.gmail.com
8
  SMTP_PORT=587
9
- SMTP_USER=your-email@gmail.com
10
- SMTP_PASSWORD=your-app-password
11
  ADMIN_EMAIL=admin@ssc.com
12
- ADMIN_PASSWORD=admin123
 
 
 
 
 
1
+ DATABASE_URL=sqlite:////app/data/ssc.db
2
+ SECRET_KEY=CHANGE_THIS_TO_A_LONG_RANDOM_SECRET
3
  ALGORITHM=HS256
4
  ACCESS_TOKEN_EXPIRE_MINUTES=30
5
  PREMIUM_COST=1000
6
  PREMIUM_DURATION_DAYS=30
7
  SMTP_SERVER=smtp.gmail.com
8
  SMTP_PORT=587
9
+ SMTP_USER=
10
+ SMTP_PASSWORD=
11
  ADMIN_EMAIL=admin@ssc.com
12
+ ADMIN_PASSWORD=CHANGE_ME
13
+ API_TITLE=SSC API
14
+ API_VERSION=1.0.0
15
+ DEBUG=False
16
+ CORS_ORIGINS=http://localhost:3000,http://127.0.0.1:3000
backend/Dockerfile.prod ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.11-slim
2
+
3
+ ENV PYTHONDONTWRITEBYTECODE=1
4
+ ENV PYTHONUNBUFFERED=1
5
+
6
+ WORKDIR /app
7
+
8
+ COPY requirements.txt .
9
+ RUN pip install --no-cache-dir --upgrade pip && pip install --no-cache-dir -r requirements.txt
10
+
11
+ COPY . .
12
+
13
+ RUN mkdir -p /app/data
14
+
15
+ EXPOSE 8000
16
+
17
+ CMD ["gunicorn", "main:app", "-k", "uvicorn.workers.UvicornWorker", "--bind", "0.0.0.0:8000", "--workers", "2", "--timeout", "120"]
backend/app/config.py CHANGED
@@ -28,7 +28,14 @@ class Settings(BaseSettings):
28
  # API
29
  API_TITLE: str = "SSC API"
30
  API_VERSION: str = "1.0.0"
31
- DEBUG: bool = True
 
 
 
 
 
 
 
32
 
33
  class Config:
34
  env_file = ".env"
 
28
  # API
29
  API_TITLE: str = "SSC API"
30
  API_VERSION: str = "1.0.0"
31
+ DEBUG: bool = False
32
+
33
+ # Deployment / CORS
34
+ CORS_ORIGINS: str = "http://localhost:3000,http://127.0.0.1:3000"
35
+
36
+ @property
37
+ def cors_origins_list(self) -> list[str]:
38
+ return [origin.strip() for origin in self.CORS_ORIGINS.split(",") if origin.strip()]
39
 
40
  class Config:
41
  env_file = ".env"
backend/main.py CHANGED
@@ -28,10 +28,12 @@ app = FastAPI(
28
  )
29
 
30
  # Add CORS middleware
 
 
31
  app.add_middleware(
32
  CORSMiddleware,
33
- allow_origins=["*"],
34
- allow_credentials=True,
35
  allow_methods=["*"],
36
  allow_headers=["*"],
37
  )
 
28
  )
29
 
30
  # Add CORS middleware
31
+ allowed_origins = settings.cors_origins_list or ["*"]
32
+
33
  app.add_middleware(
34
  CORSMiddleware,
35
+ allow_origins=allowed_origins,
36
+ allow_credentials="*" not in allowed_origins,
37
  allow_methods=["*"],
38
  allow_headers=["*"],
39
  )
backend/requirements.txt CHANGED
@@ -1,5 +1,6 @@
1
  fastapi==0.104.1
2
  uvicorn==0.24.0
 
3
  sqlalchemy==2.0.23
4
  pydantic==2.5.0
5
  pydantic-settings==2.1.0
 
1
  fastapi==0.104.1
2
  uvicorn==0.24.0
3
+ gunicorn==21.2.0
4
  sqlalchemy==2.0.23
5
  pydantic==2.5.0
6
  pydantic-settings==2.1.0
docker-compose.prod.yml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ version: '3.8'
2
+
3
+ services:
4
+ backend:
5
+ build:
6
+ context: ./backend
7
+ dockerfile: Dockerfile.prod
8
+ env_file:
9
+ - ./backend/.env
10
+ volumes:
11
+ - ssc-db-data:/app/data
12
+ restart: unless-stopped
13
+ networks:
14
+ - ssc-network
15
+
16
+ frontend:
17
+ build:
18
+ context: ./frontend
19
+ dockerfile: Dockerfile.prod
20
+ args:
21
+ VITE_API_URL: /api
22
+ ports:
23
+ - "80:80"
24
+ depends_on:
25
+ - backend
26
+ restart: unless-stopped
27
+ networks:
28
+ - ssc-network
29
+
30
+ volumes:
31
+ ssc-db-data:
32
+
33
+ networks:
34
+ ssc-network:
35
+ driver: bridge
docker-entrypoint.sh ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ set -e
3
+
4
+ # Start backend in background
5
+ echo "Starting backend..."
6
+ cd /app/backend
7
+ gunicorn main:app -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:8000 --workers 1 --timeout 120 &
8
+ BACKEND_PID=$!
9
+
10
+ # Give backend time to start
11
+ sleep 2
12
+
13
+ # Start Nginx in foreground
14
+ echo "Starting Nginx..."
15
+ cd /app
16
+ nginx -g "daemon off;"
17
+
18
+ # Cleanup on exit
19
+ trap "kill $BACKEND_PID" EXIT
frontend/.dockerignore ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ node_modules/
2
+ dist/
3
+ .env
4
+ .git
5
+ .gitignore
6
+ .vscode/
7
+ npm-debug.log*
frontend/.env.example CHANGED
@@ -1,4 +1,5 @@
1
  # Frontend Environment Configuration
2
 
3
- VITE_API_URL=http://localhost:8001
 
4
  VITE_APP_TITLE=SSC - Sculpt Soft Cricketers
 
1
  # Frontend Environment Configuration
2
 
3
+ # Local development backend
4
+ VITE_API_URL=http://localhost:8000
5
  VITE_APP_TITLE=SSC - Sculpt Soft Cricketers
frontend/.env.production.example ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ # Frontend production build variables
2
+ # For docker+nginx deployment keep this as /api
3
+ VITE_API_URL=/api
4
+ VITE_APP_TITLE=SSC - Sculpt Soft Cricketers
frontend/Dockerfile.prod ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM node:18-alpine AS builder
2
+
3
+ WORKDIR /app
4
+
5
+ COPY package*.json ./
6
+ RUN npm ci
7
+
8
+ COPY . .
9
+
10
+ ARG VITE_API_URL=/api
11
+ ENV VITE_API_URL=${VITE_API_URL}
12
+ RUN npm run build
13
+
14
+ FROM nginx:1.27-alpine
15
+
16
+ COPY nginx.conf /etc/nginx/conf.d/default.conf
17
+ COPY --from=builder /app/dist /usr/share/nginx/html
18
+
19
+ EXPOSE 80
20
+
21
+ CMD ["nginx", "-g", "daemon off;"]
frontend/nginx.conf ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ server {
2
+ listen 80;
3
+ server_name _;
4
+
5
+ root /usr/share/nginx/html;
6
+ index index.html;
7
+
8
+ location /api/ {
9
+ proxy_pass http://backend:8000/;
10
+ proxy_http_version 1.1;
11
+ proxy_set_header Host $host;
12
+ proxy_set_header X-Real-IP $remote_addr;
13
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
14
+ proxy_set_header X-Forwarded-Proto $scheme;
15
+ }
16
+
17
+ location / {
18
+ try_files $uri /index.html;
19
+ }
20
+ }
frontend/src/components/navbar.module.css CHANGED
@@ -1,10 +1,12 @@
1
  .navbar {
2
- background: linear-gradient(110deg, #123a35, #164942);
3
  color: white;
4
  padding: 13px 0;
5
  position: sticky;
6
  top: 0;
7
  z-index: 100;
 
 
8
  box-shadow: 0 6px 16px rgba(10, 44, 39, 0.25);
9
  }
10
 
 
1
  .navbar {
2
+ background: linear-gradient(110deg, rgba(18, 58, 53, 0.8 ), rgba(22, 73, 66, 0.8));
3
  color: white;
4
  padding: 13px 0;
5
  position: sticky;
6
  top: 0;
7
  z-index: 100;
8
+ -webkit-backdrop-filter: blur(10px);
9
+ backdrop-filter: blur(10px);
10
  box-shadow: 0 6px 16px rgba(10, 44, 39, 0.25);
11
  }
12
 
frontend/src/pages/Matches.jsx CHANGED
@@ -275,6 +275,23 @@ export function MatchesPage() {
275
  const selectedTeamAPlayers = players.filter((p) => teamAIds.includes(String(p.id)));
276
  const selectedTeamBPlayers = players.filter((p) => teamBIds.includes(String(p.id)));
277
  const reusableMatches = matches.filter((m) => m.id !== selectedMatchId);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
278
 
279
  return (
280
  <div className={styles.page}>
@@ -357,7 +374,20 @@ export function MatchesPage() {
357
  className={`${styles.matchItem} ${selectedMatchId === match.id ? styles.active : ''}`}
358
  onClick={() => handleSelectMatch(match)}
359
  >
360
- <strong>{match.title}</strong>
 
 
 
 
 
 
 
 
 
 
 
 
 
361
  <span>{match.team_a_name} vs {match.team_b_name}</span>
362
  <small>{match.status}</small>
363
  </button>
@@ -666,56 +696,116 @@ export function MatchesPage() {
666
 
667
  <div className={styles.rowButtons}>
668
  <button type="button" onClick={() => setCurrentStep(2)}>Back</button>
669
- <button type="submit">Record Ball</button>
670
  </div>
671
  </form>
672
 
 
 
 
 
 
 
673
  <h3 className={styles.sectionTitle}>Live Scoreboard</h3>
674
  {!scoreboard && <p>Select a match to view live score.</p>}
675
  {scoreboard && (
676
- <div className={styles.scoreboard}>
677
- <h3>{selectedMatch?.match?.title}</h3>
678
- <p>Innings: {scoreboard.current_innings}</p>
679
- <p className={styles.bigScore}>
680
- {scoreboard.total_runs}/{scoreboard.wickets}
681
- </p>
682
- <p>Overs: {scoreboard.overs_display}</p>
683
- <p>
684
- Batting Team: {scoreboard.batting_team === 'A' ? selectedMatch?.match?.team_a_name : selectedMatch?.match?.team_b_name}
685
- </p>
686
- <p>
687
- {selectedMatch?.match?.team_a_name}: {scoreboard.team_a_runs} | {selectedMatch?.match?.team_b_name}: {scoreboard.team_b_runs}
688
- </p>
689
-
690
- {scoreboard.result_text && (
691
- <p className={styles.resultBadge}>{scoreboard.result_text}</p>
692
- )}
693
-
694
- <h4>Current Over ({scoreboard.current_over_number})</h4>
695
- <div className={styles.ballStrip}>
696
- {scoreboard.current_over_balls.map((ball, idx) => (
697
- <span key={`current-${ball}-${idx}`}>{ball}</span>
698
- ))}
699
- {scoreboard.current_over_balls.length === 0 && <span>No balls in current over yet</span>}
700
  </div>
701
 
702
- <div className={styles.overToggleRow}>
703
- <button
704
- type="button"
705
- className={styles.toggleBtn}
706
- onClick={() => setShowPastOvers((prev) => !prev)}
707
- disabled={scoreboard.past_overs.length === 0}
708
- >
709
- {showPastOvers ? 'Hide Past Overs' : 'Show Past Overs'}
710
- </button>
 
 
 
 
 
 
711
  </div>
712
 
713
- {showPastOvers && scoreboard.past_overs.length > 0 && (
714
- <div className={styles.pastOversWrap}>
715
- {scoreboard.past_overs.map((overText, idx) => (
716
- <p key={`past-${idx}`} className={styles.overLine}>{overText}</p>
717
- ))}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
718
  </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
719
  )}
720
  </div>
721
  )}
 
275
  const selectedTeamAPlayers = players.filter((p) => teamAIds.includes(String(p.id)));
276
  const selectedTeamBPlayers = players.filter((p) => teamBIds.includes(String(p.id)));
277
  const reusableMatches = matches.filter((m) => m.id !== selectedMatchId);
278
+ const selectedMatchStatus = scoreboard?.match_status || selectedMatch?.match?.status || 'setup';
279
+ const isLiveMatch = selectedMatchStatus === 'live';
280
+ const isCompletedMatch = selectedMatchStatus === 'completed';
281
+ const teamAName = selectedMatch?.match?.team_a_name;
282
+ const teamBName = selectedMatch?.match?.team_b_name;
283
+ const isTeamAWinner = Boolean(scoreboard?.winner_team) && scoreboard.winner_team === teamAName;
284
+ const isTeamBWinner = Boolean(scoreboard?.winner_team) && scoreboard.winner_team === teamBName;
285
+
286
+ const getMatchStatusLabel = (status) => {
287
+ if (status === 'live') {
288
+ return 'LIVE';
289
+ }
290
+ if (status === 'completed') {
291
+ return 'COMPLETED';
292
+ }
293
+ return 'SETUP';
294
+ };
295
 
296
  return (
297
  <div className={styles.page}>
 
374
  className={`${styles.matchItem} ${selectedMatchId === match.id ? styles.active : ''}`}
375
  onClick={() => handleSelectMatch(match)}
376
  >
377
+ <div className={styles.matchHeadRow}>
378
+ <strong>{match.title}</strong>
379
+ <span
380
+ className={`${styles.statusPill} ${
381
+ match.status === 'live'
382
+ ? styles.statusLive
383
+ : match.status === 'completed'
384
+ ? styles.statusCompleted
385
+ : styles.statusSetup
386
+ }`}
387
+ >
388
+ {getMatchStatusLabel(match.status)}
389
+ </span>
390
+ </div>
391
  <span>{match.team_a_name} vs {match.team_b_name}</span>
392
  <small>{match.status}</small>
393
  </button>
 
696
 
697
  <div className={styles.rowButtons}>
698
  <button type="button" onClick={() => setCurrentStep(2)}>Back</button>
699
+ <button type="submit" disabled={isCompletedMatch}>Record Ball</button>
700
  </div>
701
  </form>
702
 
703
+ {isCompletedMatch && (
704
+ <p className={styles.completedHint}>
705
+ This match is completed. Live scoring inputs are now read-only.
706
+ </p>
707
+ )}
708
+
709
  <h3 className={styles.sectionTitle}>Live Scoreboard</h3>
710
  {!scoreboard && <p>Select a match to view live score.</p>}
711
  {scoreboard && (
712
+ <div
713
+ className={`${styles.scoreboard} ${
714
+ isCompletedMatch
715
+ ? styles.scoreboardCompleted
716
+ : isLiveMatch
717
+ ? styles.scoreboardLive
718
+ : styles.scoreboardSetup
719
+ }`}
720
+ >
721
+ <div className={styles.scoreboardTop}>
722
+ <h3>{selectedMatch?.match?.title}</h3>
723
+ <span
724
+ className={`${styles.scoreboardStatus} ${
725
+ isCompletedMatch
726
+ ? styles.scoreboardStatusCompleted
727
+ : isLiveMatch
728
+ ? styles.scoreboardStatusLive
729
+ : styles.scoreboardStatusSetup
730
+ }`}
731
+ >
732
+ {getMatchStatusLabel(selectedMatchStatus)}
733
+ </span>
 
 
734
  </div>
735
 
736
+ <div className={styles.teamTotalsRow}>
737
+ <div className={`${styles.teamTotalItem} ${isTeamAWinner ? styles.teamTotalWinner : ''}`}>
738
+ <span>
739
+ {teamAName}
740
+ {isTeamAWinner && <em className={styles.winnerTag}>Winner</em>}
741
+ </span>
742
+ <strong>{scoreboard.team_a_runs}</strong>
743
+ </div>
744
+ <div className={`${styles.teamTotalItem} ${isTeamBWinner ? styles.teamTotalWinner : ''}`}>
745
+ <span>
746
+ {teamBName}
747
+ {isTeamBWinner && <em className={styles.winnerTag}>Winner</em>}
748
+ </span>
749
+ <strong>{scoreboard.team_b_runs}</strong>
750
+ </div>
751
  </div>
752
 
753
+ <div className={styles.scoreMainRow}>
754
+ <div className={styles.scoreMetaItem}>
755
+ <span className={styles.scoreMetaLabel}>Innings</span>
756
+ <strong className={styles.scoreMetaValue}>{scoreboard.current_innings}</strong>
757
+ </div>
758
+ <div className={styles.scoreMetaItem}>
759
+ <span className={styles.scoreMetaLabel}>Overs</span>
760
+ <strong className={styles.scoreMetaValue}>{scoreboard.overs_display}</strong>
761
+ </div>
762
+ <div className={styles.scoreMetaItemWide}>
763
+ <span className={styles.scoreMetaLabel}>Batting Team</span>
764
+ <strong className={styles.scoreMetaValue}>
765
+ {scoreboard.batting_team === 'A' ? selectedMatch?.match?.team_a_name : selectedMatch?.match?.team_b_name}
766
+ </strong>
767
+ </div>
768
+ <div className={styles.scoreNowCard}>
769
+ <span className={styles.scoreMetaLabel}>Current Score</span>
770
+ <p className={styles.bigScore}>
771
+ {scoreboard.total_runs}/{scoreboard.wickets}
772
+ </p>
773
  </div>
774
+ </div>
775
+
776
+ {scoreboard.result_text && (
777
+ <p className={styles.resultBadge}>{scoreboard.result_text}</p>
778
+ )}
779
+
780
+ {!isCompletedMatch && (
781
+ <>
782
+ <h4>Current Over ({scoreboard.current_over_number})</h4>
783
+ <div className={styles.ballStrip}>
784
+ {scoreboard.current_over_balls.map((ball, idx) => (
785
+ <span key={`current-${ball}-${idx}`}>{ball}</span>
786
+ ))}
787
+ {scoreboard.current_over_balls.length === 0 && <span>No balls in current over yet</span>}
788
+ </div>
789
+
790
+ <div className={styles.overToggleRow}>
791
+ <button
792
+ type="button"
793
+ className={styles.toggleBtn}
794
+ onClick={() => setShowPastOvers((prev) => !prev)}
795
+ disabled={scoreboard.past_overs.length === 0}
796
+ >
797
+ {showPastOvers ? 'Hide Past Overs' : 'Show Past Overs'}
798
+ </button>
799
+ </div>
800
+
801
+ {showPastOvers && scoreboard.past_overs.length > 0 && (
802
+ <div className={styles.pastOversWrap}>
803
+ {scoreboard.past_overs.map((overText, idx) => (
804
+ <p key={`past-${idx}`} className={styles.overLine}>{overText}</p>
805
+ ))}
806
+ </div>
807
+ )}
808
+ </>
809
  )}
810
  </div>
811
  )}
frontend/src/pages/matches.module.css CHANGED
@@ -104,15 +104,72 @@
104
  .matchItem {
105
  background: #f4f9f8;
106
  border: 1px solid #cfe2de;
 
107
  text-align: left;
108
  display: flex;
109
  flex-direction: column;
110
  gap: 3px;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
  }
112
 
113
  .matchItem.active {
114
- border-color: #0f6f62;
115
- background: #e4f4f1;
 
 
 
 
 
 
 
116
  }
117
 
118
  .sectionTitle {
@@ -262,28 +319,165 @@
262
  }
263
 
264
  .scoreboard {
265
- background: #0f332f;
266
  color: #e7fffb;
267
  border-radius: 14px;
268
  padding: 14px;
269
  }
270
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
271
  .bigScore {
272
- font-size: 36px;
273
- margin: 4px 0;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
274
  font-weight: 800;
 
 
 
 
 
 
 
 
 
 
275
  }
276
 
277
  .resultBadge {
278
- margin-top: 8px;
279
- display: inline-block;
280
- background: #1d655d;
281
- border: 1px solid #49a293;
 
282
  border-radius: 999px;
283
- padding: 6px 10px;
284
- font-size: 13px;
285
- font-weight: 700;
286
- color: #e9fffb;
 
 
287
  }
288
 
289
  .ballStrip {
@@ -320,6 +514,14 @@
320
  color: #cfeae6;
321
  }
322
 
 
 
 
 
 
 
 
 
323
  .error {
324
  margin: 10px 0;
325
  background: #fde7ea;
@@ -358,4 +560,12 @@
358
  .previousBox select {
359
  min-width: 0;
360
  }
 
 
 
 
 
 
 
 
361
  }
 
104
  .matchItem {
105
  background: #f4f9f8;
106
  border: 1px solid #cfe2de;
107
+ color: ffffff;
108
  text-align: left;
109
  display: flex;
110
  flex-direction: column;
111
  gap: 3px;
112
+ padding: 10px 12px;
113
+ transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
114
+ }
115
+
116
+ .matchItem > span,
117
+ .matchItem > small,
118
+ .matchHeadRow strong {
119
+ color: #1d4b45;
120
+ }
121
+
122
+ .matchItem:hover {
123
+ background: #e8f5f2;
124
+ border-color: #9ecfc4;
125
+ }
126
+
127
+ .matchHeadRow {
128
+ display: flex;
129
+ align-items: center;
130
+ justify-content: space-between;
131
+ gap: 10px;
132
+ }
133
+
134
+ .statusPill {
135
+ display: inline-flex;
136
+ align-items: center;
137
+ justify-content: center;
138
+ border-radius: 999px;
139
+ padding: 4px 9px;
140
+ font-size: 11px;
141
+ font-weight: 800;
142
+ letter-spacing: 0.04em;
143
+ }
144
+
145
+ .statusLive {
146
+ color: #0f5a4f;
147
+ background: #dbf7ef;
148
+ border: 1px solid #9fe6d3;
149
+ }
150
+
151
+ .statusCompleted {
152
+ color: #255d8f;
153
+ background: #e2eefb;
154
+ border: 1px solid #bcd8f4;
155
+ }
156
+
157
+ .statusSetup {
158
+ color: #6c4b00;
159
+ background: #fff3d6;
160
+ border: 1px solid #f3d79a;
161
  }
162
 
163
  .matchItem.active {
164
+ border-color: #5fe0c4;
165
+ background: linear-gradient(120deg, #0f6f62, #12927f);
166
+ box-shadow: 0 8px 16px rgba(9, 53, 47, 0.28);
167
+ }
168
+
169
+ .matchItem.active > span,
170
+ .matchItem.active > small,
171
+ .matchItem.active .matchHeadRow strong {
172
+ color: #f2fffc;
173
  }
174
 
175
  .sectionTitle {
 
319
  }
320
 
321
  .scoreboard {
 
322
  color: #e7fffb;
323
  border-radius: 14px;
324
  padding: 14px;
325
  }
326
 
327
+ .scoreboardLive {
328
+ background: linear-gradient(145deg, #0f332f 0%, #145049 100%);
329
+ }
330
+
331
+ .scoreboardCompleted {
332
+ background: linear-gradient(145deg, #173654 0%, #2b547e 100%);
333
+ }
334
+
335
+ .scoreboardSetup {
336
+ background: linear-gradient(145deg, #473d19 0%, #665420 100%);
337
+ }
338
+
339
+ .scoreboardTop {
340
+ display: flex;
341
+ align-items: flex-start;
342
+ justify-content: space-between;
343
+ gap: 10px;
344
+ }
345
+
346
+ .scoreMainRow {
347
+ margin-top: 10px;
348
+ width: 100%;
349
+ display: grid;
350
+ grid-template-columns: 1fr 1fr 1.4fr 1.2fr;
351
+ gap: 10px;
352
+ align-items: stretch;
353
+ }
354
+
355
+ .scoreMetaItem,
356
+ .scoreMetaItemWide,
357
+ .scoreNowCard {
358
+ background: rgba(7, 36, 33, 0.28);
359
+ border: 1px solid rgba(159, 236, 214, 0.22);
360
+ border-radius: 12px;
361
+ padding: 10px;
362
+ display: flex;
363
+ flex-direction: column;
364
+ gap: 4px;
365
+ }
366
+
367
+ .scoreMetaItemWide {
368
+ min-width: 0;
369
+ }
370
+
371
+ .scoreMetaLabel {
372
+ font-size: 12px;
373
+ color: #bde8de;
374
+ letter-spacing: 0.02em;
375
+ }
376
+
377
+ .scoreMetaValue {
378
+ font-size: 17px;
379
+ color: #effffb;
380
+ line-height: 1.2;
381
+ }
382
+
383
+ .scoreNowCard {
384
+ justify-content: center;
385
+ align-items: flex-start;
386
+ }
387
+
388
+ .scoreboardStatus {
389
+ display: inline-flex;
390
+ align-items: center;
391
+ border-radius: 999px;
392
+ padding: 5px 10px;
393
+ font-size: 12px;
394
+ font-weight: 800;
395
+ border: 1px solid transparent;
396
+ }
397
+
398
+ .scoreboardStatusLive {
399
+ color: #d0ffe7;
400
+ background: rgba(10, 93, 75, 0.45);
401
+ border-color: rgba(152, 255, 215, 0.45);
402
+ }
403
+
404
+ .scoreboardStatusCompleted {
405
+ color: #e5f1ff;
406
+ background: rgba(31, 91, 149, 0.45);
407
+ border-color: rgba(176, 215, 255, 0.45);
408
+ }
409
+
410
+ .scoreboardStatusSetup {
411
+ color: #fff2d3;
412
+ background: rgba(125, 94, 14, 0.45);
413
+ border-color: rgba(255, 215, 123, 0.45);
414
+ }
415
+
416
  .bigScore {
417
+ font-size: 34px;
418
+ margin: 2px 0;
419
+ font-weight: 800;
420
+ }
421
+
422
+ .teamTotalsRow {
423
+ margin-top: 10px;
424
+ display: grid;
425
+ grid-template-columns: 1fr 1fr;
426
+ gap: 10px;
427
+ }
428
+
429
+ .teamTotalItem {
430
+ background: rgba(7, 36, 33, 0.28);
431
+ border: 1px solid rgba(159, 236, 214, 0.22);
432
+ border-radius: 10px;
433
+ padding: 8px 10px;
434
+ display: flex;
435
+ justify-content: space-between;
436
+ align-items: center;
437
+ color: #dcfff7;
438
+ }
439
+
440
+ .teamTotalItem span {
441
+ display: inline-flex;
442
+ align-items: center;
443
+ gap: 8px;
444
+ }
445
+
446
+ .teamTotalWinner {
447
+ background: linear-gradient(145deg, rgba(33, 113, 90, 0.55), rgba(22, 80, 67, 0.65));
448
+ border-color: rgba(124, 255, 207, 0.75);
449
+ box-shadow: 0 0 0 1px rgba(124, 255, 207, 0.32), 0 8px 16px rgba(7, 41, 33, 0.32);
450
+ }
451
+
452
+ .winnerTag {
453
+ font-style: normal;
454
+ font-size: 11px;
455
  font-weight: 800;
456
+ letter-spacing: 0.04em;
457
+ text-transform: uppercase;
458
+ color: #07261f;
459
+ background: #8fffd2;
460
+ border-radius: 999px;
461
+ padding: 2px 7px;
462
+ }
463
+
464
+ .teamTotalItem strong {
465
+ font-size: 20px;
466
  }
467
 
468
  .resultBadge {
469
+ margin: 12px auto 2px;
470
+ display: table;
471
+ text-align: center;
472
+ background: linear-gradient(120deg, #1f7a68, #2cae93);
473
+ border: 1px solid rgba(168, 255, 231, 0.7);
474
  border-radius: 999px;
475
+ padding: 8px 16px;
476
+ font-size: 14px;
477
+ font-weight: 800;
478
+ letter-spacing: 0.02em;
479
+ color: #f3fffc;
480
+ box-shadow: 0 6px 16px rgba(11, 44, 38, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.2);
481
  }
482
 
483
  .ballStrip {
 
514
  color: #cfeae6;
515
  }
516
 
517
+ .completedHint {
518
+ margin-top: 8px;
519
+ margin-bottom: 2px;
520
+ font-size: 13px;
521
+ color: #355f8a;
522
+ font-weight: 700;
523
+ }
524
+
525
  .error {
526
  margin: 10px 0;
527
  background: #fde7ea;
 
560
  .previousBox select {
561
  min-width: 0;
562
  }
563
+
564
+ .scoreMainRow {
565
+ grid-template-columns: 1fr 1fr;
566
+ }
567
+
568
+ .teamTotalsRow {
569
+ grid-template-columns: 1fr;
570
+ }
571
  }
frontend/vite.config.js CHANGED
@@ -4,6 +4,7 @@ import react from '@vitejs/plugin-react'
4
  export default defineConfig({
5
  plugins: [react()],
6
  server: {
 
7
  port: 3000,
8
  proxy: {
9
  '/api': {
 
4
  export default defineConfig({
5
  plugins: [react()],
6
  server: {
7
+ host: '0.0.0.0',
8
  port: 3000,
9
  proxy: {
10
  '/api': {
nginx-huggingface.conf ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ server {
2
+ listen 7860;
3
+ server_name _;
4
+
5
+ # Serve frontend static files
6
+ root /app/frontend/dist;
7
+ index index.html;
8
+
9
+ # API proxy to backend
10
+ location /api/ {
11
+ proxy_pass http://localhost:8000/;
12
+ proxy_http_version 1.1;
13
+ proxy_set_header Host $host;
14
+ proxy_set_header X-Real-IP $remote_addr;
15
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
16
+ proxy_set_header X-Forwarded-Proto $scheme;
17
+ proxy_redirect off;
18
+ }
19
+
20
+ # Swagger/OpenAPI docs
21
+ location /docs {
22
+ proxy_pass http://localhost:8000/docs;
23
+ proxy_http_version 1.1;
24
+ proxy_set_header Host $host;
25
+ }
26
+
27
+ location /openapi.json {
28
+ proxy_pass http://localhost:8000/openapi.json;
29
+ proxy_http_version 1.1;
30
+ proxy_set_header Host $host;
31
+ }
32
+
33
+ # SPA fallback - any non-file request goes to index.html
34
+ location / {
35
+ try_files $uri /index.html;
36
+ }
37
+ }