# arkanbeta/flip7-se-sec-1- architecture

> Architecture diagram of the GitHub repository arkanbeta/flip7-se-sec-1-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/arkanbeta/flip7-se-sec-1-
- Repository: https://github.com/arkanbeta/flip7-se-sec-1-

## Overview

Flip 7 Online is a browser-based multiplayer card game: players sign in with Google, create or join private rooms by code, play Flip 7 in real time, and can view profiles, match history, and rules. The graph follows that user journey through the React client, Express services, in-memory room/game state, and MySQL persistence. README documents the full product scope; some unsampled frontend and backend subsystem links are therefore documented rather than source-verified.

Main entry points: [`backend/src/game/gameManager.js`](https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/backend/src/game/gameManager.js) (Live game manager), [`backend/src/app.js`](https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/backend/src/app.js) (API composition), [`backend/src/services/authService.js`](https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/backend/src/services/authService.js) (Auth workflow), [`backend/src/services/roomService.js`](https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/backend/src/services/roomService.js) (Room service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser client"]
  node_webapp["React app<br/>[App.jsx]"]
  node_authui["Sign-in pages"]
  node_lobbyui["Lobby<br/>[LobbyPage.jsx]"]
  node_roomui["Room screen<br/>[RoomPage.jsx]"]
  node_gameui["Game board<br/>[GameBoard.jsx]"]
  node_profileui["Profile and rules"]
  node_api["HTTP client<br/>[api.js]"]
  node_socketclient["Socket client<br/>[socket.js]"]
end

subgraph group_identity["Identity and profiles"]
  node_authprovider["Auth state<br/>[AuthProvider.jsx]"]
  node_authcontroller["Auth endpoints<br/>[authController.js]"]
  node_authservice["Auth workflow<br/>[authService.js]"]
  node_googleoauth["Google OAuth"]
  node_userprofile["User and profile services<br/>[userService.js]"]
end

subgraph group_rooms["Rooms and realtime"]
  node_roomservice["Room service<br/>[roomService.js]"]
  node_roommanager["Room state<br/>[roomManager.js]"]
  node_socketserver["Socket server<br/>[socketServer.js]"]
  node_app["API composition<br/>[app.js]"]
end

subgraph group_play["Gameplay and records"]
  node_gameengine["Flip 7 rules<br/>[flip7Game.js]"]
  node_gamemanager["Live game manager<br/>[gameManager.js]"]
  node_matchservice["Match records<br/>[matchService.js]"]
  node_mysql[("MySQL<br/>[pool.js]")]
end

node_player(("Player"))
node_google(("Google"))

node_player -.->|"uses"| node_webapp
node_webapp -->|"wraps"| node_authprovider
node_authprovider -->|"loads identity"| node_api
node_player -.->|"signs in"| node_google
node_authcontroller -->|"delegates to"| node_authservice
node_authservice -->|"verifies with"| node_googleoauth
node_googleoauth -->|"exchanges code"| node_google
node_authservice -->|"looks up users"| node_userprofile
node_player -.->|"creates or joins"| node_lobbyui
node_lobbyui -.->|"requests rooms"| node_api
node_roomservice -->|"updates room state"| node_roommanager
node_app -->|"configures"| node_roomservice
node_app -->|"creates"| node_roommanager
node_app -->|"creates"| node_gamemanager
node_socketserver -.->|"serves room events"| node_roomservice
node_roomui -.->|"joins live room"| node_socketclient
node_player -.->|"manages room"| node_roomui
node_player -.->|"plays match"| node_gameui
node_gameui -.->|"sends game actions"| node_socketclient
node_gamemanager -->|"runs rules"| node_gameengine
node_gamemanager -->|"updates match state"| node_roommanager
node_gamemanager -->|"reports results"| node_matchservice
node_matchservice -.->|"writes records"| node_mysql
node_player -.->|"views history and rules"| node_profileui

click node_webapp "https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/frontend/src/app/App.jsx"
click node_authui "https://github.com/arkanbeta/flip7-se-sec-1-/tree/main/frontend/src/features/auth"
click node_lobbyui "https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/frontend/src/features/lobby/LobbyPage.jsx"
click node_roomui "https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/frontend/src/features/rooms/RoomPage.jsx"
click node_gameui "https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/frontend/src/features/game/GameBoard.jsx"
click node_profileui "https://github.com/arkanbeta/flip7-se-sec-1-/tree/main/frontend/src/features/profile"
click node_api "https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/frontend/src/services/api.js"
click node_socketclient "https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/frontend/src/services/socket.js"
click node_authprovider "https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/frontend/src/app/AuthProvider.jsx"
click node_authcontroller "https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/backend/src/controllers/authController.js"
click node_authservice "https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/backend/src/services/authService.js"
click node_googleoauth "https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/backend/src/services/googleOAuthService.js"
click node_userprofile "https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/backend/src/services/userService.js"
click node_roomservice "https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/backend/src/services/roomService.js"
click node_roommanager "https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/backend/src/realtime/roomManager.js"
click node_socketserver "https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/backend/src/realtime/socketServer.js"
click node_app "https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/backend/src/app.js"
click node_gameengine "https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/backend/src/game/flip7Game.js"
click node_gamemanager "https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/backend/src/game/gameManager.js"
click node_matchservice "https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/backend/src/services/matchService.js"
click node_mysql "https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/backend/src/db/pool.js"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_webapp,node_authui,node_lobbyui,node_roomui,node_gameui,node_profileui,node_api,node_socketclient toneBlue
class node_authprovider,node_authcontroller,node_authservice,node_googleoauth,node_userprofile toneAmber
class node_roomservice,node_roommanager,node_socketserver,node_app toneMint
class node_gameengine,node_gamemanager,node_matchservice,node_mysql toneRose
class node_player,node_google toneIndigo
```

## Components

### Browser client

- [React app](https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/frontend/src/app/App.jsx): `frontend/src/app/App.jsx`
- [Sign-in pages](https://github.com/arkanbeta/flip7-se-sec-1-/tree/main/frontend/src/features/auth): `frontend/src/features/auth`
- [Lobby](https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/frontend/src/features/lobby/LobbyPage.jsx): `frontend/src/features/lobby/LobbyPage.jsx`
- [Room screen](https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/frontend/src/features/rooms/RoomPage.jsx): `frontend/src/features/rooms/RoomPage.jsx`
- [Game board](https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/frontend/src/features/game/GameBoard.jsx): `frontend/src/features/game/GameBoard.jsx`
- [Profile and rules](https://github.com/arkanbeta/flip7-se-sec-1-/tree/main/frontend/src/features/profile): `frontend/src/features/profile`
- [HTTP client](https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`
- [Socket client](https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/frontend/src/services/socket.js): `frontend/src/services/socket.js`

### Identity and profiles

- [Auth state](https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/frontend/src/app/AuthProvider.jsx): `frontend/src/app/AuthProvider.jsx`
- [Auth endpoints](https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/backend/src/controllers/authController.js): `backend/src/controllers/authController.js`
- [Auth workflow](https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/backend/src/services/authService.js): `backend/src/services/authService.js`
- [Google OAuth](https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/backend/src/services/googleOAuthService.js): `backend/src/services/googleOAuthService.js`
- [User and profile services](https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/backend/src/services/userService.js): `backend/src/services/userService.js`

### Rooms and realtime

- [Room service](https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/backend/src/services/roomService.js): `backend/src/services/roomService.js`
- [Room state](https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/backend/src/realtime/roomManager.js): `backend/src/realtime/roomManager.js`
- [Socket server](https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/backend/src/realtime/socketServer.js): `backend/src/realtime/socketServer.js`
- [API composition](https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/backend/src/app.js): `backend/src/app.js`

### Gameplay and records

- [Flip 7 rules](https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/backend/src/game/flip7Game.js): `backend/src/game/flip7Game.js`
- [Live game manager](https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/backend/src/game/gameManager.js): `backend/src/game/gameManager.js`
- [Match records](https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/backend/src/services/matchService.js): `backend/src/services/matchService.js`
- [MySQL](https://github.com/arkanbeta/flip7-se-sec-1-/blob/main/backend/src/db/pool.js): `backend/src/db/pool.js`

### Other components

- **Player**
- **Google**

## Connections

- Player → React app: uses (evidence: `README.md`)
- React app → Auth state: wraps (evidence: `frontend/src/app/App.jsx`)
- Auth state → HTTP client: loads identity (evidence: `frontend/src/app/AuthProvider.jsx`)
- Player → Google: signs in (evidence: `README.md`)
- Auth endpoints → Auth workflow: delegates to (evidence: `backend/src/controllers/authController.js`)
- Auth workflow → Google OAuth: verifies with (evidence: `backend/src/services/authService.js`)
- Google OAuth → Google: exchanges code (evidence: `backend/src/services/googleOAuthService.js`)
- Auth workflow → User and profile services: looks up users (evidence: `backend/src/services/authService.js`)
- Player → Lobby: creates or joins (evidence: `README.md`)
- Lobby → HTTP client: requests rooms (evidence: `README.md`)
- Room service → Room state: updates room state (evidence: `backend/src/services/roomService.js`)
- API composition → Room service: configures (evidence: `backend/src/app.js`)
- API composition → Room state: creates (evidence: `backend/src/app.js`)
- API composition → Live game manager: creates (evidence: `backend/src/app.js`)
- Socket server → Room service: serves room events (evidence: `README.md`)
- Room screen → Socket client: joins live room (evidence: `README.md`)
- Player → Room screen: manages room (evidence: `README.md`)
- Player → Game board: plays match (evidence: `README.md`)
- Game board → Socket client: sends game actions (evidence: `README.md`)
- Live game manager → Flip 7 rules: runs rules (evidence: `backend/src/game/gameManager.js`)
- Live game manager → Room state: updates match state (evidence: `backend/src/game/gameManager.js`)
- Live game manager → Match records: reports results (evidence: `backend/src/app.js`)
- Match records → MySQL: writes records (evidence: `README.md`)
- Player → Profile and rules: views history and rules (evidence: `README.md`)
