# madhvesh77/cricket-score-calculator architecture

> Architecture diagram of the GitHub repository madhvesh77/cricket-score-calculator, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/madhvesh77/cricket-score-calculator
- Repository: https://github.com/madhvesh77/cricket-score-calculator

## Overview

##### Project type and purpose
- Type: Command Line Interface (CLI) simulation program in C.
- Purpose: Interactive ball-by-ball cricket match simulator that prompts the user for each delivery’s event and updates a running scorecard.

##### File structure
- Top level:
– “Cricket scorecard.c”: a single-file C program implementing all logic
– “README.md”: project description
– “Output Screenshots.docx”: sample outputs
- No separate folders or modules; everything lives in one source file.

##### README for insights
- Core functionality:
– User input per ball
– State update (runs, wickets, strike rates, economy)
– Real-time display of the scorecard
- Data tracked: batsmen, bowlers, team totals, statuses.

##### Main components (to include
a. User Interface (CLI)
– Input Handler: reads event strings (“dot ball”, “four”, “wicket”, etc.)
– Output Renderer: prints the updated scorecard
b. Simulation Engine (Controller)
– Event Processor: maps input to state changes
– Rule Engine: applies cricket scoring rules
c. Data Model (State)
– Player Records: batsman and bowler stats
– Match State: total runs, overs, wickets, current striker/non-striker
d. Storage (in-memory)
– Arrays or structs holding player and team data
e. Main Function (Orchestrator)
– Bootstraps the loop: read input → process → render → repeat

##### Relationships and interactions
- User → Input Handler: “Enter event”
- Input Handler → Event Processor: raw event code
- Event Processor → Data Model: update player/match state
- Data Model ←→ Rule Engine: fetch and apply scoring logic
- Data Model → Output Renderer: generate formatted scorecard
- Output Renderer → User: print updated scoreboard

##### Architectural patterns and principles
- Model-View-Controller (MVC-like):
– Model = Data Model (structs)
– Controller = Simulation Engine (event processing + rules)
– View = CLI Output Renderer
- Single responsibility per module for clarity.
- Loop-driven event loop: ensures real-time feedback.

##### Technologies and libraries
- Language: C (standard library)
- No external dependencies—pure console I/O (scanf/printf).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External user
    User("User"):::external

    %% Main orchestrator
    Main["Main Function\n(Bootstrap Event Loop)"]:::processing

    %% User Interface Layer
    subgraph "User Interface (CLI)"
        UI_Input["Input Handler"]:::inputoutput
        UI_Output["Output Renderer"]:::inputoutput
    end

    %% Simulation Engine Layer
    subgraph "Simulation Engine (Controller)"
        SE_Event["Event Processor"]:::processing
        SE_Rule["Rule Engine"]:::processing
    end

    %% Data Model Layer
    subgraph "Data Model (State)"
        DM["Player Records &\nMatch State"]:::data
    end

    %% Storage Layer
    subgraph "Storage (in-memory)"
        Storage["Arrays/Structs\nfor Players & Team Data"]:::data
    end

    %% Documentation
    Docs["Project Documentation\n(README.md)"]:::external
    Screens["Sample Output\nScreenshots"]:::external

    %% Flow arrows
    User -->|"Enter event"| UI_Input
    Main -->|"start loop"| UI_Input
    UI_Input -->|"event code"| SE_Event
    SE_Event -->|"update state"| DM
    DM -->|"fetch/apply rules"| SE_Rule
    SE_Rule -->|"updated stats"| DM
    DM -->|"formatted data"| UI_Output
    UI_Output -->|"print scoreboard"| User
    Main -->|"invoke processing"| SE_Event
    Main -->|"access rules"| SE_Rule
    Main -->|"read/write state"| DM
    Main -->|"render output"| UI_Output
    DM --> Storage
    Storage --> DM

    %% External docs links
    Docs -.-> Main
    Screens -.-> UI_Output

    %% Click Events
    click UI_Input "https://github.com/madhvesh77/cricket-score-calculator/blob/main/Cricket scorecard.c"
    click UI_Output "https://github.com/madhvesh77/cricket-score-calculator/blob/main/Cricket scorecard.c"
    click SE_Event "https://github.com/madhvesh77/cricket-score-calculator/blob/main/Cricket scorecard.c"
    click SE_Rule "https://github.com/madhvesh77/cricket-score-calculator/blob/main/Cricket scorecard.c"
    click DM "https://github.com/madhvesh77/cricket-score-calculator/blob/main/Cricket scorecard.c"
    click Storage "https://github.com/madhvesh77/cricket-score-calculator/blob/main/Cricket scorecard.c"
    click Main "https://github.com/madhvesh77/cricket-score-calculator/blob/main/Cricket scorecard.c"
    click Docs "https://github.com/madhvesh77/cricket-score-calculator/blob/main/README.md"
    click Screens "https://github.com/madhvesh77/cricket-score-calculator/blob/main/Output Screenshots.docx"

    %% Styles
    classDef inputoutput fill:#c8e6c9,stroke:#2e7d32,stroke-width:2px
    classDef processing fill:#bbdefb,stroke:#1565c0,stroke-width:2px
    classDef data fill:#fff9c4,stroke:#f9a825,stroke-width:2px
    classDef external fill:#f0f0f0,stroke:#616161,stroke-width:1px,stroke-dasharray: 4 2
```
