# mohammadfaqeh/competition architecture

> Architecture diagram of the GitHub repository mohammadfaqeh/competition, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mohammadfaqeh/competition
- Repository: https://github.com/mohammadfaqeh/competition

## Overview

This is a static web application for running an annual Quran memorization competition. The main workflow is: administrators register or import participants and configure committees; the system assigns fair, non-repeating exam positions; committee chair and member assess independently; the chair compares and finalizes the score; administrators review and export results. It supports both offline, device-local operation and a shared Supabase mode with role-based access. Quran text and page imagery support the exam interface. The graph follows the README and sampled cloud/backup code; most application internals and SQL procedures were not sampled, so uncertain wiring is omitted.

Main entry points: [`app.js`](https://github.com/mohammadfaqeh/competition/blob/main/app.js) (Competition Application), [`supabase/functions/auto-backup/index.ts`](https://github.com/mohammadfaqeh/competition/blob/main/supabase/functions/auto-backup/index.ts) (Scheduled Cloud Backup), [`cloud.js`](https://github.com/mohammadfaqeh/competition/blob/main/cloud.js) (Cloud and RPC Layer), [`supabase/schema.sql`](https://github.com/mohammadfaqeh/competition/blob/main/supabase/schema.sql) (Supabase Competition Data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Access and State"]
  node_gateway["Mode and Login Gateway<br/>[app.js]"]
  node_app["Competition Application<br/>[app.js]"]
  node_cloud["Cloud and RPC Layer<br/>[cloud.js]"]
  node_local_state[("Device Local State")]
  node_supabase[("Supabase Competition Data<br/>[schema.sql]")]
end

subgraph group_setup["Competition Setup"]
  node_participant_manager["Participant Management<br/>[app.js]"]
  node_import["Participant Import<br/>[app.js]"]
  node_committee_setup["Committee Setup<br/>[app.js]"]
end

subgraph group_exam["Exam Workflow"]
  node_draw["Position Draw<br/>[app.js]"]
  node_quran_data["Quran and Line Data<br/>[quran-data.js]"]
  node_page_images["Mushaf Page Images"]
  node_assessment["Independent Assessment<br/>[app.js]"]
  node_score_review["Compare and Finalize<br/>[app.js]"]
end

subgraph group_operations["Results and Operations"]
  node_dr_requests["Emergency Manual Scores<br/>[app.js]"]
  node_results["Results and Export<br/>[app.js]"]
  node_backup["Scheduled Cloud Backup<br/>[index.ts]"]
end

node_administrator(("Administrator"))
node_committee_users(("Committee Chair / Member"))
node_email_service["Email Delivery"]

node_administrator -->|"selects mode"| node_gateway
node_committee_users -->|"signs in"| node_gateway
node_gateway -->|"opens"| node_app
node_administrator -->|"manages participants"| node_participant_manager
node_participant_manager -->|"imports roster"| node_import
node_administrator -->|"configures committees"| node_committee_setup
node_participant_manager -->|"updates roster"| node_app
node_committee_setup -->|"provides assignments"| node_app
node_app -->|"uses cloud mode"| node_cloud
node_cloud -->|"reads and writes"| node_supabase
node_app -->|"reads and writes offline"| node_local_state
node_app -->|"requests position draw"| node_draw
node_draw -->|"uses verse layout"| node_quran_data
node_app -->|"starts exam"| node_assessment
node_assessment -->|"displays pages"| node_page_images
node_assessment -->|"submits assessment"| node_score_review
node_score_review -->|"finalizes score"| node_results
node_committee_users -->|"records errors"| node_assessment
node_administrator -->|"reviews requests"| node_dr_requests
node_dr_requests -->|"approves manual score"| node_results
node_administrator -->|"exports results"| node_results
node_backup -->|"reads competition data"| node_supabase
node_backup -.->|"sends backup"| node_email_service

click node_participant_manager "https://github.com/mohammadfaqeh/competition/blob/main/app.js"
click node_import "https://github.com/mohammadfaqeh/competition/blob/main/app.js"
click node_committee_setup "https://github.com/mohammadfaqeh/competition/blob/main/app.js"
click node_gateway "https://github.com/mohammadfaqeh/competition/blob/main/app.js"
click node_app "https://github.com/mohammadfaqeh/competition/blob/main/app.js"
click node_cloud "https://github.com/mohammadfaqeh/competition/blob/main/cloud.js"
click node_supabase "https://github.com/mohammadfaqeh/competition/blob/main/supabase/schema.sql"
click node_draw "https://github.com/mohammadfaqeh/competition/blob/main/app.js"
click node_quran_data "https://github.com/mohammadfaqeh/competition/blob/main/data/quran-data.js"
click node_page_images "https://github.com/mohammadfaqeh/competition/tree/main/assets/quran-pages"
click node_assessment "https://github.com/mohammadfaqeh/competition/blob/main/app.js"
click node_score_review "https://github.com/mohammadfaqeh/competition/blob/main/app.js"
click node_dr_requests "https://github.com/mohammadfaqeh/competition/blob/main/app.js"
click node_results "https://github.com/mohammadfaqeh/competition/blob/main/app.js"
click node_backup "https://github.com/mohammadfaqeh/competition/blob/main/supabase/functions/auto-backup/index.ts"

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_gateway,node_app,node_cloud,node_local_state,node_supabase toneBlue
class node_participant_manager,node_import,node_committee_setup toneAmber
class node_draw,node_quran_data,node_page_images,node_assessment,node_score_review toneMint
class node_dr_requests,node_results,node_backup toneRose
class node_administrator,node_committee_users,node_email_service toneIndigo
```

## Components

### Access and State

- [Mode and Login Gateway](https://github.com/mohammadfaqeh/competition/blob/main/app.js): `app.js`
- [Competition Application](https://github.com/mohammadfaqeh/competition/blob/main/app.js): `app.js`
- [Cloud and RPC Layer](https://github.com/mohammadfaqeh/competition/blob/main/cloud.js): `cloud.js`
- **Device Local State**
- [Supabase Competition Data](https://github.com/mohammadfaqeh/competition/blob/main/supabase/schema.sql): `supabase/schema.sql`

### Competition Setup

- [Participant Management](https://github.com/mohammadfaqeh/competition/blob/main/app.js): `app.js`
- [Participant Import](https://github.com/mohammadfaqeh/competition/blob/main/app.js): `app.js`
- [Committee Setup](https://github.com/mohammadfaqeh/competition/blob/main/app.js): `app.js`

### Exam Workflow

- [Position Draw](https://github.com/mohammadfaqeh/competition/blob/main/app.js): `app.js`
- [Quran and Line Data](https://github.com/mohammadfaqeh/competition/blob/main/data/quran-data.js): `data/quran-data.js`
- [Mushaf Page Images](https://github.com/mohammadfaqeh/competition/tree/main/assets/quran-pages): `assets/quran-pages`
- [Independent Assessment](https://github.com/mohammadfaqeh/competition/blob/main/app.js): `app.js`
- [Compare and Finalize](https://github.com/mohammadfaqeh/competition/blob/main/app.js): `app.js`

### Results and Operations

- [Emergency Manual Scores](https://github.com/mohammadfaqeh/competition/blob/main/app.js): `app.js`
- [Results and Export](https://github.com/mohammadfaqeh/competition/blob/main/app.js): `app.js`
- [Scheduled Cloud Backup](https://github.com/mohammadfaqeh/competition/blob/main/supabase/functions/auto-backup/index.ts): `supabase/functions/auto-backup/index.ts`

### Other components

- **Administrator**
- **Committee Chair / Member**
- **Email Delivery**

## Connections

- Administrator → Mode and Login Gateway: selects mode
- Committee Chair / Member → Mode and Login Gateway: signs in
- Mode and Login Gateway → Competition Application: opens
- Administrator → Participant Management: manages participants
- Participant Management → Participant Import: imports roster
- Administrator → Committee Setup: configures committees
- Participant Management → Competition Application: updates roster
- Committee Setup → Competition Application: provides assignments
- Competition Application → Cloud and RPC Layer: uses cloud mode
- Cloud and RPC Layer → Supabase Competition Data: reads and writes
- Competition Application → Device Local State: reads and writes offline
- Competition Application → Position Draw: requests position draw
- Position Draw → Quran and Line Data: uses verse layout
- Competition Application → Independent Assessment: starts exam
- Independent Assessment → Mushaf Page Images: displays pages
- Independent Assessment → Compare and Finalize: submits assessment
- Compare and Finalize → Results and Export: finalizes score
- Committee Chair / Member → Independent Assessment: records errors
- Administrator → Emergency Manual Scores: reviews requests
- Emergency Manual Scores → Results and Export: approves manual score
- Administrator → Results and Export: exports results
- Scheduled Cloud Backup → Supabase Competition Data: reads competition data
- Scheduled Cloud Backup → Email Delivery: sends backup
