How romeirofernandes/typiks works
Purpose and entry points
This is a full-stack, real-time multiplayer game application with user profiles, ratings, public/private rooms, presence, geographic data, and a React game UI. The frontend starts at frontend/src/main.jsx and composes routing/application state in frontend/src/App.jsx. The backend HTTP/Worker entry point is backend/src/index.js.
Frontend application shell
The Vite React client provides public landing/auth flows plus authenticated game and social views. Route-level screens include gameplay, matchmaking/room creation, waiting-room, dashboard, leaderboard, profile, friends, bot mode, and globe views:
• frontend/src/pages/Game.jsx
• frontend/src/pages/StartGame.jsx
• frontend/src/pages/WaitingRoom.jsx
Authenticated navigation is gated by frontend/src/components/ProtectedRoute.jsx; Firebase client initialization and auth state are centralized in frontend/src/firebase.js and frontend/src/context/AuthContext.jsx.
Backend API and authentication boundary
The backend exposes user and room-oriented HTTP APIs through:
• backend/src/index.js
• backend/src/routes/users.js
• backend/src/routes/rooms.js
Firebase identity is verified at the server boundary by backend/src/middleware/firebaseAuth.js. This separates client-side Firebase session handling from trusted backend authorization before profile, room, or game-related operations proceed.
Real-time game and presence layer
Cloudflare Durable Objects appear to own mutable, connection-oriented runtime state rather than placing active matches in ordinary request handlers:
• backend/src/durable-objects/GameRoom.js
• backend/src/durable-objects/PrivateRoom.js
• backend/src/durable-objects/PresenceHub.js
Room APIs likely resolve or create the appropriate durable object, while GameRoom manages shared match lifecycle/state, PrivateRoom supports invite/private sessions, and PresenceHub tracks online availability. This is the primary real-time control boundary.
Persistent domain data and progression
Relational persistence is defined in backend/src/db/schema.js and evolved through Drizzle migrations under backend/migrations/, including rating, profile location, presence/invites, and avatar changes. Rating/progression logic is isolated in backend/src/utils/rating.js, allowing game completion state to feed durable-room coordination and then durable profile/ranking storage.
Game content/supporting data includes country geography and generated words:
• backend/src/countries-geo.json
• backend/src/utils/wordGenerator.js
• words.json
Player-facing data visualization and presentation
Dashboard/profile-oriented views expose player history and relationships, with reusable rating/type chart components:
• frontend/src/pages/Dashboard.jsx
• frontend/src/pages/Profile.jsx
• frontend/src/components/charts/RatingGrowthChart.jsx
The gameplay client is distinct from the marketing/auth surface, with landing composition in frontend/src/pages/NewLanding.jsx and game interaction concentrated in frontend/src/pages/Game.jsx.
Runtime and deployment infrastructure
The backend is configured as a Cloudflare Worker/Durable Objects deployment via backend/wrangler.jsonc, with Drizzle configuration in backend/drizzle.config.js. The frontend is a Vite build and has Vercel deployment configuration at frontend/vercel.json. Firebase is an external authentication service; the backend also depends on a database compatible with the Drizzle schema and migration set.
Main entry points: index.js Worker HTTP entry · ProtectedRoute.jsx Protected routes · firebaseAuth.js Server auth verification · rooms.js Room API
Components 20
React Client
- Client entry
frontend/src/main.jsx - App routing shell · Composes public and authenticated views.
frontend/src/App.jsx - Auth session · Centralizes Firebase client auth state.
frontend/src/context/AuthContext.jsx - Firebase client
frontend/src/firebase.js - Protected routes
frontend/src/components/ProtectedRoute.jsx - Gameplay UI
frontend/src/pages/Game.jsx - Matchmaking & lobby · Creates rooms and waits for matches.
frontend/src/pages/StartGame.jsx - Dashboard & profile · Shows player history, relationships, and progression.
frontend/src/pages/Dashboard.jsx
Worker Backend
- Worker HTTP entry
backend/src/index.js - Server auth verification · Verifies Firebase identity before protected operations.
backend/src/middleware/firebaseAuth.js - User API
backend/src/routes/users.js - Room API · Resolves or creates real-time room instances.
backend/src/routes/rooms.js - Worker deployment · Binds the Worker and Durable Objects runtime.
backend/wrangler.jsonc
Real-time Objects
- Game room · Owns shared active-match lifecycle and state.
backend/src/durable-objects/GameRoom.js - Private room · Supports invite-only sessions.
backend/src/durable-objects/PrivateRoom.js - Presence hub · Tracks online player availability.
backend/src/durable-objects/PresenceHub.js
Persistence & Content
- Domain database · Stores profiles, ratings, locations, invites, and history.
backend/src/db/schema.js - Rating progression · Calculates persistent rating changes after matches.
backend/src/utils/rating.js - Game content · Country geography and generated-word support.
backend/src/countries-geo.json
Other components
- Firebase
Connections 23
- Client entry → App routing shell: mounts
- App routing shell → Auth session: uses session
- Auth session → Firebase client: initializes through
- Firebase client → Firebase: authenticates with
- App routing shell → Protected routes: gates
- Protected routes → Gameplay UI: allows
- Protected routes → Matchmaking & lobby: allows
- Protected routes → Dashboard & profile: allows
- Gameplay UI → Worker HTTP entry: game requests
- Matchmaking & lobby → Worker HTTP entry: room requests
- Dashboard & profile → Worker HTTP entry: profile requests
- Worker HTTP entry → Server auth verification: protects requests with
- Server auth verification → Firebase: verifies tokens with
- Server auth verification → User API: authorizes
- Server auth verification → Room API: authorizes
- User API → Domain database: reads and writes
- Room API → Game room: creates or resolves
- Room API → Private room: creates or resolves
- Room API → Presence hub: queries presence
- Game room → Rating progression: on match completion
- Rating progression → Domain database: updates ratings
- Game room → Game content: uses
- Worker deployment → Worker HTTP entry: deploys