How pupupu999/calculater works
Project type and purpose
• Type: Full-stack web application (SPA front-end + RESTful back-end)
• Purpose: “Chipin” is a real-time poker‐score tracking app without real money, allowing friends to create/join rooms, input chip counts at game end, and see live updates of individual and aggregate standings (charts, tables, rankings).
File structure
Top level:
– client/poker-app: React app (CRA + craco, Next config present but used primarily as SPA)
– server: Node.js/Express API with firebase-admin
– scripts: Data‐migration & reset utilities
client/poker-app highlights:
– public/: static assets & index.html
– src/
• pages/: React pages (CreateRoom, JoinRoom, Ranking, RoomPage, etc.)
• components/: UI widgets (BattleRecord, LineChart, RankingTable, Spinner…)
• contexts/AuthContext.js: user authentication state
• hooks/: custom data‐fetch hooks (useUser, useUsersWithTotalChip)
• utils/api.js, syncUser.js: wrapper around REST calls & user syncing
• firebase.js: Firebase SDK init
server highlights:
– server.js: Express app bootstrap on port 3001
– middleware/authMiddleware.js: verifies Firebase JWT
– routes/auth.js: sign-up/login endpoints
– routes/secure.js: protected game/room management endpoints
– firebase-admin.js: admin SDK init
config & infra files:
– client/.env.development, firebase.json, .firebaserc: Firebase hosting & environment
– CORS note in README for production
Extract insights from README
– Features: real-time chip updates, line-chart of score history, sortable history table, global ranking
– Dev setup: npm run start-all launches front (3000) + back (3001), mobile access via LAN IP
– Deployment: front on Firebase Hosting, back on Render (adjust CORS)
a. Main components
1. Client Browser (React SPA)
2. Firebase Hosting (serves SPA)
3. Node.js/Express API Server (Render or local)
4. Firebase Services:
– Authentication (email/password)
– Firestore or Realtime Database (rooms, user stats, game records)
5. Utility scripts (offline tasks)
b. Relationships & data flow
• Browser → Firebase Hosting → serves static JS/CSS
• Browser → Firebase Auth SDK → sign-up/sign-in (email/password)
• Browser → Firestore SDK → read/write public game data (rooms, real-time updates)
• Browser → Express API → protected operations (create room, submit chip count)
• Express API → firebase-admin → verify JWT & read/write Firestore
• scripts → firebase-admin → batch operations on Firestore
c. Architectural patterns & design principles
– Client: SPA, Context API for auth, custom hooks for data fetching
– API: RESTful endpoints, middleware for auth, MVC-light (routes + handlers)
– Security: token-based auth with Firebase JWT
– Separation of concerns: UI vs. business logic vs. persistence
d. Key technologies/frameworks
– React, Create React App (craco), Context & Hooks
– Firebase SDK (Auth & Firestore)
– Node.js, Express, firebase-admin
– Charting library for LineChart component
– Hosting: Firebase Hosting (front), Render.com (back)