# jemish-jikadara/ffm-tournament architecture

> Architecture diagram of the GitHub repository jemish-jikadara/ffm-tournament, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-19). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jemish-jikadara/ffm-tournament
- Repository: https://github.com/jemish-jikadara/ffm-tournament

## Overview

This is a Free Fire match and tournament platform with player, team-leader, and staff workflows. Players register or sign in, manage their profile and wallet, and join matches; staff manage match operations and results, while team leaders manage squads and enter BR Squad tournaments. Match services coordinate fees, slot registration, cancellation refunds, prize settlement, and notifications. The Express app wires the routes and shared request middleware. The source index supports many route-to-service and route-to-model links, but some routes and subsystems were not excerpted, and the README contains no capability details.

Main entry points: [`src/app.js`](https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/app.js) (Express app), [`src/routes/admin.js`](https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/routes/admin.js) (Staff operations), [`src/routes/matches.js`](https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/routes/matches.js) (Match participation), [`src/services/wallet.js`](https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/services/wallet.js) (Wallet operations)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_app["Express app<br/>[app.js]"]
  node_browser["Browser assets<br/>[app.js]"]
  node_matchform["Match form UI<br/>[match-form.js]"]
  node_brjoin["BR join UI<br/>[br-join.js]"]
end

subgraph group_identity["Accounts and teams"]
  node_authroutes["Sign-in and registration<br/>[auth.js]"]
  node_auth["Session and access<br/>[auth.js]"]
  node_user[("User accounts<br/>[User.js]")]
  node_teamroutes["Team management<br/>[team.js]"]
  node_team[("Teams and members<br/>[Team.js]")]
end

subgraph group_competition["Matches and tournaments"]
  node_matchroutes["Match participation<br/>[matches.js]"]
  node_admin["Staff operations<br/>[admin.js]"]
  node_matchsvc["Match lifecycle<br/>[match.js]"]
  node_tournament["Tournament entry<br/>[tournamentJoin.js]"]
  node_match[("Match records<br/>[Match.js]")]
  node_gameconfig["Modes and rules<br/>[game.js]"]
  node_playerroutes["Player dashboard<br/>[player.js]"]
end

subgraph group_money["Wallet and records"]
  node_walletsvc["Wallet operations<br/>[wallet.js]"]
  node_wallet[("Wallet balances<br/>[Wallet.js]")]
  node_transactions[("Transactions<br/>[Transaction.js]")]
  node_settings[("System settings<br/>[SystemSettings.js]")]
end

subgraph group_communication["Chat and notifications"]
  node_chatroutes["Chat routes<br/>[chat.js]"]
  node_chatgroup[("Chat groups<br/>[ChatGroup.js]")]
  node_chatmessage[("Chat messages<br/>[ChatMessage.js]")]
  node_notify["Notifications and audit<br/>[notify.js]"]
  node_notification[("User notifications<br/>[Notification.js]")]
  node_audit[("Audit log<br/>[AuditLog.js]")]
end

node_player(("Players and staff"))

node_player -->|"uses"| node_app
node_app -->|"routes requests"| node_authroutes
node_app -->|"routes requests"| node_matchroutes
node_app -->|"routes requests"| node_admin
node_app -->|"routes requests"| node_playerroutes
node_app -->|"routes requests"| node_teamroutes
node_app -->|"routes requests"| node_chatroutes
node_app -->|"attaches user"| node_auth
node_app -->|"serves static files"| node_browser
node_browser -.->|"uses form behavior"| node_matchform
node_browser -.->|"uses join behavior"| node_brjoin
node_authroutes -->|"reads and creates"| node_user
node_authroutes -->|"signs in"| node_auth
node_authroutes -->|"ensures wallet"| node_walletsvc
node_authroutes -->|"sends welcome"| node_notify
node_auth -->|"loads account"| node_user
node_auth -->|"loads balance"| node_wallet
node_auth -->|"counts unread"| node_notification
node_teamroutes -->|"manages teams"| node_team
node_teamroutes -->|"uses accounts"| node_user
node_teamroutes -->|"sends updates"| node_notify
node_matchroutes -->|"manages registrations"| node_match
node_matchroutes -->|"uses team data"| node_team
node_matchroutes -->|"delegates lifecycle"| node_matchsvc
node_matchroutes -->|"delegates tournament entry"| node_tournament
node_matchroutes -->|"sends updates"| node_notify
node_matchroutes -->|"uses game rules"| node_gameconfig
node_matchsvc -->|"reads and updates"| node_match
node_matchsvc -->|"debits and credits"| node_walletsvc
node_matchsvc -->|"updates player stats"| node_user
node_matchsvc -->|"notifies players"| node_notify
node_tournament -->|"updates registrations"| node_match
node_tournament -->|"checks team data"| node_team
node_tournament -->|"uses wallet"| node_walletsvc
node_admin -->|"manages matches"| node_match
node_admin -->|"manages accounts"| node_user
node_admin -->|"accesses balances"| node_wallet
node_admin -->|"manages transactions"| node_transactions
node_admin -->|"manages settings"| node_settings
node_admin -->|"delegates match actions"| node_matchsvc
node_admin -->|"sends notifications"| node_notify
node_playerroutes -->|"reads profiles"| node_user
node_playerroutes -->|"reads matches"| node_match
node_playerroutes -->|"handles wallet actions"| node_walletsvc
node_playerroutes -->|"sends updates"| node_notify
node_walletsvc -->|"updates balances"| node_wallet
node_walletsvc -->|"records transactions"| node_transactions
node_walletsvc -->|"checks freeze setting"| node_settings

click node_app "https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/app.js"
click node_browser "https://github.com/jemish-jikadara/ffm-tournament/blob/main/public/js/app.js"
click node_matchform "https://github.com/jemish-jikadara/ffm-tournament/blob/main/public/js/match-form.js"
click node_brjoin "https://github.com/jemish-jikadara/ffm-tournament/blob/main/public/js/br-join.js"
click node_authroutes "https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/routes/auth.js"
click node_auth "https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/middleware/auth.js"
click node_user "https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/models/User.js"
click node_teamroutes "https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/routes/team.js"
click node_team "https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/models/Team.js"
click node_matchroutes "https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/routes/matches.js"
click node_admin "https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/routes/admin.js"
click node_matchsvc "https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/services/match.js"
click node_tournament "https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/services/tournamentJoin.js"
click node_match "https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/models/Match.js"
click node_gameconfig "https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/config/game.js"
click node_playerroutes "https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/routes/player.js"
click node_walletsvc "https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/services/wallet.js"
click node_wallet "https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/models/Wallet.js"
click node_transactions "https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/models/Transaction.js"
click node_settings "https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/models/SystemSettings.js"
click node_chatroutes "https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/routes/chat.js"
click node_chatgroup "https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/models/ChatGroup.js"
click node_chatmessage "https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/models/ChatMessage.js"
click node_notify "https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/services/notify.js"
click node_notification "https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/models/Notification.js"
click node_audit "https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/models/AuditLog.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_app,node_browser,node_matchform,node_brjoin toneBlue
class node_authroutes,node_auth,node_user,node_teamroutes,node_team toneAmber
class node_matchroutes,node_admin,node_matchsvc,node_tournament,node_match,node_gameconfig,node_playerroutes toneMint
class node_walletsvc,node_wallet,node_transactions,node_settings toneRose
class node_chatroutes,node_chatgroup,node_chatmessage,node_notify,node_notification,node_audit,node_player toneIndigo
```

## Components

### Web application

- [Express app](https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/app.js): `src/app.js`
- [Browser assets](https://github.com/jemish-jikadara/ffm-tournament/blob/main/public/js/app.js): `public/js/app.js`
- [Match form UI](https://github.com/jemish-jikadara/ffm-tournament/blob/main/public/js/match-form.js): `public/js/match-form.js`
- [BR join UI](https://github.com/jemish-jikadara/ffm-tournament/blob/main/public/js/br-join.js): `public/js/br-join.js`

### Accounts and teams

- [Sign-in and registration](https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/routes/auth.js): `src/routes/auth.js`
- [Session and access](https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/middleware/auth.js): `src/middleware/auth.js`
- [User accounts](https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/models/User.js): `src/models/User.js`
- [Team management](https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/routes/team.js): `src/routes/team.js`
- [Teams and members](https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/models/Team.js): `src/models/Team.js`

### Matches and tournaments

- [Match participation](https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/routes/matches.js): `src/routes/matches.js`
- [Staff operations](https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/routes/admin.js): `src/routes/admin.js`
- [Match lifecycle](https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/services/match.js): `src/services/match.js`
- [Tournament entry](https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/services/tournamentJoin.js): `src/services/tournamentJoin.js`
- [Match records](https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/models/Match.js): `src/models/Match.js`
- [Modes and rules](https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/config/game.js): `src/config/game.js`
- [Player dashboard](https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/routes/player.js): `src/routes/player.js`

### Wallet and records

- [Wallet operations](https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/services/wallet.js): `src/services/wallet.js`
- [Wallet balances](https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/models/Wallet.js): `src/models/Wallet.js`
- [Transactions](https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/models/Transaction.js): `src/models/Transaction.js`
- [System settings](https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/models/SystemSettings.js): `src/models/SystemSettings.js`

### Chat and notifications

- [Chat routes](https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/routes/chat.js): `src/routes/chat.js`
- [Chat groups](https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/models/ChatGroup.js): `src/models/ChatGroup.js`
- [Chat messages](https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/models/ChatMessage.js): `src/models/ChatMessage.js`
- [Notifications and audit](https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/services/notify.js): `src/services/notify.js`
- [User notifications](https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/models/Notification.js): `src/models/Notification.js`
- [Audit log](https://github.com/jemish-jikadara/ffm-tournament/blob/main/src/models/AuditLog.js): `src/models/AuditLog.js`

### Other components

- **Players and staff**

## Connections

- Players and staff → Express app: uses (evidence: `src/app.js`)
- Express app → Sign-in and registration: routes requests (evidence: `src/app.js`)
- Express app → Match participation: routes requests (evidence: `src/app.js`)
- Express app → Staff operations: routes requests (evidence: `src/app.js`)
- Express app → Player dashboard: routes requests (evidence: `src/app.js`)
- Express app → Team management: routes requests (evidence: `src/app.js`)
- Express app → Chat routes: routes requests (evidence: `src/app.js`)
- Express app → Session and access: attaches user (evidence: `src/app.js`)
- Express app → Browser assets: serves static files (evidence: `src/app.js`)
- Browser assets → Match form UI: uses form behavior
- Browser assets → BR join UI: uses join behavior
- Sign-in and registration → User accounts: reads and creates (evidence: `src/routes/auth.js`)
- Sign-in and registration → Session and access: signs in (evidence: `src/routes/auth.js`)
- Sign-in and registration → Wallet operations: ensures wallet (evidence: `src/routes/auth.js`)
- Sign-in and registration → Notifications and audit: sends welcome (evidence: `src/routes/auth.js`)
- Session and access → User accounts: loads account (evidence: `src/middleware/auth.js`)
- Session and access → Wallet balances: loads balance (evidence: `src/middleware/auth.js`)
- Session and access → User notifications: counts unread (evidence: `src/middleware/auth.js`)
- Team management → Teams and members: manages teams (evidence: `src/routes/team.js`)
- Team management → User accounts: uses accounts (evidence: `src/routes/team.js`)
- Team management → Notifications and audit: sends updates (evidence: `src/routes/team.js`)
- Match participation → Match records: manages registrations (evidence: `src/routes/matches.js`)
- Match participation → Teams and members: uses team data (evidence: `src/routes/matches.js`)
- Match participation → Match lifecycle: delegates lifecycle (evidence: `src/routes/matches.js`)
- Match participation → Tournament entry: delegates tournament entry (evidence: `src/routes/matches.js`)
- Match participation → Notifications and audit: sends updates (evidence: `src/routes/matches.js`)
- Match participation → Modes and rules: uses game rules (evidence: `src/routes/matches.js`)
- Match lifecycle → Match records: reads and updates (evidence: `src/services/match.js`)
- Match lifecycle → Wallet operations: debits and credits (evidence: `src/services/match.js`)
- Match lifecycle → User accounts: updates player stats (evidence: `src/services/match.js`)
- Match lifecycle → Notifications and audit: notifies players (evidence: `src/services/match.js`)
- Tournament entry → Match records: updates registrations (evidence: `src/services/tournamentJoin.js`)
- Tournament entry → Teams and members: checks team data (evidence: `src/services/tournamentJoin.js`)
- Tournament entry → Wallet operations: uses wallet (evidence: `src/services/tournamentJoin.js`)
- Staff operations → Match records: manages matches (evidence: `src/routes/admin.js`)
- Staff operations → User accounts: manages accounts (evidence: `src/routes/admin.js`)
- Staff operations → Wallet balances: accesses balances (evidence: `src/routes/admin.js`)
- Staff operations → Transactions: manages transactions (evidence: `src/routes/admin.js`)
- Staff operations → System settings: manages settings (evidence: `src/routes/admin.js`)
- Staff operations → Match lifecycle: delegates match actions (evidence: `src/routes/admin.js`)
- Staff operations → Notifications and audit: sends notifications (evidence: `src/routes/admin.js`)
- Player dashboard → User accounts: reads profiles (evidence: `src/routes/player.js`)
- Player dashboard → Match records: reads matches (evidence: `src/routes/player.js`)
- Player dashboard → Wallet operations: handles wallet actions (evidence: `src/routes/player.js`)
- Player dashboard → Notifications and audit: sends updates (evidence: `src/routes/player.js`)
- Wallet operations → Wallet balances: updates balances (evidence: `src/services/wallet.js`)
- Wallet operations → Transactions: records transactions (evidence: `src/services/wallet.js`)
- Wallet operations → System settings: checks freeze setting (evidence: `src/services/wallet.js`)
