# ganes-ha/cricvault architecture

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

- Interactive diagram: https://gitdiagram.com/ganes-ha/cricvault
- Repository: https://github.com/ganes-ha/cricvault

## Overview

#### Purpose and delivery

CricVault is a lightweight, offline box-cricket scoring application. The entire product is delivered as a static page, with application UI, logic, credentials, and likely local persistence contained in `index.html`. `README.md` documents usage and static hosting.

#### Entry point and runtime

- Primary application entry point: `index.html`
- Documentation and deployment guidance: `README.md`
- Runtime is a browser on mobile or desktop; no server-side application, API, database, build system, or package runtime is present.
- It can be opened directly or served by any static HTTP host, including GitHub Pages or a local Python HTTP server.

#### Authentication and authorization boundary

Client-side login separates users into Scorer and Viewer roles. Scorers can configure matches, manage players, and record balls; Viewers can access live scoring, scorecards, and history while scoring controls remain locked.

- Credential and role definitions are maintained in the `USERS` array in `index.html`.
- This is explicitly a UI-level/shared-device protection boundary, not secure authentication: credentials are exposed in page source and there is no backend validation.

#### Match setup and team-selection stage

Before scoring begins, the app configures teams and player availability. It supports equal-sized teams and an optional common-player mode.

- With common-player mode disabled, players on the opposing team are hidden during selection.
- With it enabled, one shared player is selected first; that player may participate as either batter or bowler but cannot do both within the same match.
- Setup, player management, and match-start controls reside in `index.html`.

#### Ball-by-ball scoring engine

The central control flow is scorer input → ball event validation/classification → match state update → live display/statistics refresh.

- Scorers record each delivery through a keypad or equivalent scoring controls in `index.html`.
- Wides and no-balls add scoring outcomes but do not consume legal-ball counts.
- Wickets trigger a next-batter selection and an explicit choice of who faces the next ball.
- Viewer sessions can observe state but cannot mutate it.

#### Innings completion and chase logic

The scoring engine enforces target-based innings completion:

- During a chase, scoring stops immediately once the target is reached.
- Legal deliveries determine overs progression; extras affect runs and bowling figures according to their classification.
- Match state feeds live views and completed-match outputs within `index.html`.

#### Presentation and score outputs

The application exposes live scoring, scorecard, and match-history views from the same static client application.

- Batting strike rate is calculated as runs / balls × 100.
- Bowling economy is calculated as runs conceded / overs.
- UI state, scoring state, and output rendering are all part of `index.html`; no separate frontend modules are present.

#### Infrastructure and external dependencies

There are no identified external services or backend dependencies. Deployment is static-file hosting:

- GitHub Pages can serve `index.html` directly.
- A local static server can expose the same artifact for LAN/device access.
- Operational security requiring real identity verification would need to be introduced outside this repository, behind a backend or host-level access control.

Main entry points: [`index.html`](https://github.com/ganes-ha/cricvault/blob/main/index.html) (Match state), [`README.md`](https://github.com/ganes-ha/cricvault/blob/main/README.md) (Usage & hosting guide)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_delivery["Static delivery"]
  node_readme["Usage &amp; hosting guide<br/>documentation<br/>[README.md]"]
  node_static_host{{"Static HTTP host<br/>deployment"}}
end

subgraph group_client["Browser application"]
  node_app["CricVault static app<br/>HTML application<br/>[index.html]"]
  node_auth["Login &amp; role gate<br/>client auth<br/>[index.html]"]
  node_users["USERS credentials<br/>role registry<br/>[index.html]"]
  node_setup["Match setup<br/>setup flow<br/>[index.html]"]
  node_scorer_controls["Scorer controls<br/>input UI<br/>[index.html]"]
  node_scoring_engine["Ball scoring engine<br/>domain logic<br/>[index.html]"]
  node_match_state[("Match state<br/>client state<br/>[index.html]")]
  node_innings_logic["Innings &amp; chase rules<br/>domain logic<br/>[index.html]"]
  node_live_view["Live scoring view<br/>presentation<br/>[index.html]"]
  node_scorecard["Scorecard<br/>presentation<br/>[index.html]"]
  node_history["Match history<br/>presentation<br/>[index.html]"]
end

node_browser{{"Mobile or desktop browser<br/>runtime"}}

node_readme -.->|"documents hosting"| node_static_host
node_static_host -->|"serves page"| node_browser
node_browser -->|"loads"| node_app
node_app -->|"initializes"| node_auth
node_users -->|"supplies credentials and roles"| node_auth
node_auth -->|"Scorer access"| node_setup
node_auth -->|"permits Scorer mutations"| node_scorer_controls
node_setup -->|"creates match"| node_match_state
node_scorer_controls -->|"submits ball events"| node_scoring_engine
node_scoring_engine -->|"applies delivery rules"| node_innings_logic
node_innings_logic -->|"updates innings state"| node_match_state
node_match_state -->|"refreshes"| node_live_view
node_match_state -->|"renders statistics"| node_scorecard
node_match_state -->|"provides completed matches"| node_history

click node_readme "https://github.com/ganes-ha/cricvault/blob/main/README.md"
click node_app "https://github.com/ganes-ha/cricvault/blob/main/index.html"
click node_auth "https://github.com/ganes-ha/cricvault/blob/main/index.html"
click node_users "https://github.com/ganes-ha/cricvault/blob/main/index.html"
click node_setup "https://github.com/ganes-ha/cricvault/blob/main/index.html"
click node_scorer_controls "https://github.com/ganes-ha/cricvault/blob/main/index.html"
click node_scoring_engine "https://github.com/ganes-ha/cricvault/blob/main/index.html"
click node_match_state "https://github.com/ganes-ha/cricvault/blob/main/index.html"
click node_innings_logic "https://github.com/ganes-ha/cricvault/blob/main/index.html"
click node_live_view "https://github.com/ganes-ha/cricvault/blob/main/index.html"
click node_scorecard "https://github.com/ganes-ha/cricvault/blob/main/index.html"
click node_history "https://github.com/ganes-ha/cricvault/blob/main/index.html"

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_readme,node_static_host toneBlue
class node_app,node_auth,node_users,node_setup,node_scorer_controls,node_scoring_engine,node_match_state,node_innings_logic,node_live_view,node_scorecard,node_history toneAmber
class node_browser toneNeutral
```

## Components

### Static delivery

- [Usage & hosting guide](https://github.com/ganes-ha/cricvault/blob/main/README.md): documentation · `README.md`
- **Static HTTP host**: deployment · GitHub Pages or a local server can serve the app.

### Browser application

- [CricVault static app](https://github.com/ganes-ha/cricvault/blob/main/index.html): HTML application · UI, logic, credentials, and local state reside in one page. · `index.html`
- [Login & role gate](https://github.com/ganes-ha/cricvault/blob/main/index.html): client auth · UI-level shared-device protection only; credentials are exposed client-side. · `index.html`
- [USERS credentials](https://github.com/ganes-ha/cricvault/blob/main/index.html): role registry · Defines Scorer and Viewer roles. · `index.html`
- [Match setup](https://github.com/ganes-ha/cricvault/blob/main/index.html): setup flow · Configures teams, players, and optional common-player mode. · `index.html`
- [Scorer controls](https://github.com/ganes-ha/cricvault/blob/main/index.html): input UI · Keypad and scoring actions are locked for Viewer sessions. · `index.html`
- [Ball scoring engine](https://github.com/ganes-ha/cricvault/blob/main/index.html): domain logic · Validates and classifies deliveries before updating match state. · `index.html`
- [Match state](https://github.com/ganes-ha/cricvault/blob/main/index.html): client state · Holds innings, players, legal balls, runs, wickets, and target. · `index.html`
- [Innings & chase rules](https://github.com/ganes-ha/cricvault/blob/main/index.html): domain logic · Advances legal balls and stops a chase when its target is reached. · `index.html`
- [Live scoring view](https://github.com/ganes-ha/cricvault/blob/main/index.html): presentation · `index.html`
- [Scorecard](https://github.com/ganes-ha/cricvault/blob/main/index.html): presentation · Calculates batting strike rate and bowling economy. · `index.html`
- [Match history](https://github.com/ganes-ha/cricvault/blob/main/index.html): presentation · `index.html`

### Other components

- **Mobile or desktop browser**: runtime

## Connections

- Usage & hosting guide → Static HTTP host: documents hosting
- Static HTTP host → Mobile or desktop browser: serves page
- Mobile or desktop browser → CricVault static app: loads
- CricVault static app → Login & role gate: initializes
- USERS credentials → Login & role gate: supplies credentials and roles
- Login & role gate → Match setup: Scorer access
- Login & role gate → Scorer controls: permits Scorer mutations
- Match setup → Match state: creates match
- Scorer controls → Ball scoring engine: submits ball events
- Ball scoring engine → Innings & chase rules: applies delivery rules
- Innings & chase rules → Match state: updates innings state
- Match state → Live scoring view: refreshes
- Match state → Scorecard: renders statistics
- Match state → Match history: provides completed matches
