# tamara-vorobyeva/fantasy-game architecture

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

- Interactive diagram: https://gitdiagram.com/tamara-vorobyeva/fantasy-game
- Repository: https://github.com/tamara-vorobyeva/fantasy-game

## Overview

#### Purpose and Entry Points
This repository is a PostgreSQL-based analytics project for the RPG “Secrets of the Darkwood.” It cleans transaction/player data, builds a player-level analytical view, and produces monetization findings for product and marketing decisions. Primary entry points are the analysis script at `src/data-cleansing-analysis.sql` and sample input data at `data/dataset.csv`.

#### Source Data Boundary
The intended source model is a normalized relational game database containing user, event/transaction, item, class, skill, race, and country entities. The checked-in dataset is a limited anonymized extract rather than a runnable database dump: `data/dataset.csv`. PostgreSQL is the processing runtime; DBeaver is the stated operator/client environment.

#### Cleansing and Transaction Qualification
The SQL workflow in `src/data-cleansing-analysis.sql` is the central processing pipeline. It addresses incomplete transaction attribution, especially missing `seller_id` values, and identifies duplicate or anomalous transaction records. This stage separates data-quality remediation from downstream commercial metrics.

#### Outlier Control
Transaction values are statistically bounded using a mean-plus-one-standard-deviation threshold. Records beyond this threshold are isolated from baseline consumer analysis, preventing extreme spenders and abnormal events from distorting average-check, conversion, and purchase-frequency measures. The filtering logic belongs in `src/data-cleansing-analysis.sql`.

#### Player-Level Analytical Data Mart
The core modeled output is a denormalized player-level mart: profiles are joined to transaction history and game dimensions, then aggregated into measures such as payer status, total transaction count, total spend, purchase frequency, and LTV. This creates the analysis boundary between normalized operational tables and ad-hoc reporting. Its construction is implemented in `src/data-cleansing-analysis.sql`.

#### Segmentation and Monetization Analysis
The pipeline evaluates conversion and spend behavior by character race and spending cohort. It compares payer rates, average transaction value, and frequency across segments, enabling targeted conclusions for races such as Demons, Northmen, Humans, and Angels. The same SQL source supports this segmentation: `src/data-cleansing-analysis.sql`.

#### Revenue Concentration and Catalog Analysis
Revenue is ranked and accumulated to perform Pareto analysis, distinguishing whale-driven revenue from broad player behavior. Item-level aggregation identifies catalog concentration and the contribution of individual items to sales. These analyses are downstream consumers of cleansed transactions and mart-level aggregates in `src/data-cleansing-analysis.sql`.

#### Output and Operational Use
The repository does not contain an application service or visualization layer. Its deliverable is SQL-derived analytical results and recommendations, documented in `README.md`; analysts execute the script against PostgreSQL and use the resulting tables/views or query outputs in external reporting tools.

Main entry points: [`src/data-cleansing-analysis.sql`](https://github.com/tamara-vorobyeva/fantasy-game/blob/main/src/data-cleansing-analysis.sql) (Baseline transactions), [`README.md`](https://github.com/tamara-vorobyeva/fantasy-game/blob/main/README.md) (Findings and recommendations), [`data/dataset.csv`](https://github.com/tamara-vorobyeva/fantasy-game/blob/main/data/dataset.csv) (Anonymized dataset extract)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_source["Source Data"]
  node_dataset["Anonymized dataset extract<br/>CSV input<br/>[dataset.csv]"]
  node_operational_model[("Normalized game model<br/>PostgreSQL entities")]
end

subgraph group_pipeline["SQL Processing"]
  node_postgres[("PostgreSQL runtime<br/>database runtime")]
  node_sql_workflow["Cleansing and analysis SQL<br/>SQL pipeline"]
  node_attribution_remediation["Transaction attribution repair<br/>cleansing stage"]
  node_anomaly_detection["Duplicate and anomaly detection<br/>quality stage"]
  node_qualified_transactions["Qualified transactions<br/>clean transaction set"]
  node_outlier_filter["Statistical outlier filter<br/>filter stage"]
  node_baseline_transactions["Baseline transactions<br/>filtered transaction set"]
  node_player_mart[("Player-level analytical mart<br/>denormalized mart")]
end

subgraph group_analysis["Commercial Analysis"]
  node_segment_analysis["Race and spending segmentation<br/>monetization analysis"]
  node_pareto_analysis["Revenue concentration<br/>Pareto analysis"]
  node_catalog_analysis["Item sales concentration<br/>catalog analysis"]
  node_recommendations["Findings and recommendations<br/>documentation output<br/>[README.md]"]
end

node_dataset -->|"loaded into"| node_postgres
node_operational_model -.->|"intended schema"| node_postgres
node_postgres -->|"executed by"| node_sql_workflow
node_sql_workflow -->|"repairs"| node_attribution_remediation
node_sql_workflow -->|"detects"| node_anomaly_detection
node_attribution_remediation -->|"produces"| node_qualified_transactions
node_anomaly_detection -->|"qualifies"| node_qualified_transactions
node_qualified_transactions -->|"bounded by"| node_outlier_filter
node_outlier_filter -->|"produces"| node_baseline_transactions
node_baseline_transactions -->|"aggregated into"| node_player_mart
node_operational_model -->|"supplies dimensions"| node_player_mart
node_player_mart -->|"supports"| node_segment_analysis
node_baseline_transactions -->|"ranked for"| node_pareto_analysis
node_baseline_transactions -->|"aggregated for"| node_catalog_analysis
node_segment_analysis -->|"informs"| node_recommendations
node_pareto_analysis -->|"informs"| node_recommendations
node_catalog_analysis -->|"informs"| node_recommendations

click node_dataset "https://github.com/tamara-vorobyeva/fantasy-game/blob/main/data/dataset.csv"
click node_sql_workflow "https://github.com/tamara-vorobyeva/fantasy-game/blob/main/src/data-cleansing-analysis.sql"
click node_attribution_remediation "https://github.com/tamara-vorobyeva/fantasy-game/blob/main/src/data-cleansing-analysis.sql"
click node_anomaly_detection "https://github.com/tamara-vorobyeva/fantasy-game/blob/main/src/data-cleansing-analysis.sql"
click node_qualified_transactions "https://github.com/tamara-vorobyeva/fantasy-game/blob/main/src/data-cleansing-analysis.sql"
click node_outlier_filter "https://github.com/tamara-vorobyeva/fantasy-game/blob/main/src/data-cleansing-analysis.sql"
click node_baseline_transactions "https://github.com/tamara-vorobyeva/fantasy-game/blob/main/src/data-cleansing-analysis.sql"
click node_player_mart "https://github.com/tamara-vorobyeva/fantasy-game/blob/main/src/data-cleansing-analysis.sql"
click node_segment_analysis "https://github.com/tamara-vorobyeva/fantasy-game/blob/main/src/data-cleansing-analysis.sql"
click node_pareto_analysis "https://github.com/tamara-vorobyeva/fantasy-game/blob/main/src/data-cleansing-analysis.sql"
click node_catalog_analysis "https://github.com/tamara-vorobyeva/fantasy-game/blob/main/src/data-cleansing-analysis.sql"
click node_recommendations "https://github.com/tamara-vorobyeva/fantasy-game/blob/main/README.md"

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_dataset,node_operational_model toneBlue
class node_postgres,node_sql_workflow,node_attribution_remediation,node_anomaly_detection,node_qualified_transactions,node_outlier_filter,node_baseline_transactions,node_player_mart toneAmber
class node_segment_analysis,node_pareto_analysis,node_catalog_analysis,node_recommendations toneMint
```

## Components

### Source Data

- [Anonymized dataset extract](https://github.com/tamara-vorobyeva/fantasy-game/blob/main/data/dataset.csv): CSV input · Limited sample rather than a database dump. · `data/dataset.csv`
- **Normalized game model**: PostgreSQL entities · Users, transactions, items, classes, skills, races, and countries.

### SQL Processing

- **PostgreSQL runtime**: database runtime
- [Cleansing and analysis SQL](https://github.com/tamara-vorobyeva/fantasy-game/blob/main/src/data-cleansing-analysis.sql): SQL pipeline · Central executable workflow. · `src/data-cleansing-analysis.sql`
- [Transaction attribution repair](https://github.com/tamara-vorobyeva/fantasy-game/blob/main/src/data-cleansing-analysis.sql): cleansing stage · Addresses missing seller attribution. · `src/data-cleansing-analysis.sql`
- [Duplicate and anomaly detection](https://github.com/tamara-vorobyeva/fantasy-game/blob/main/src/data-cleansing-analysis.sql): quality stage · `src/data-cleansing-analysis.sql`
- [Qualified transactions](https://github.com/tamara-vorobyeva/fantasy-game/blob/main/src/data-cleansing-analysis.sql): clean transaction set · Transactions suitable for downstream metrics. · `src/data-cleansing-analysis.sql`
- [Statistical outlier filter](https://github.com/tamara-vorobyeva/fantasy-game/blob/main/src/data-cleansing-analysis.sql): filter stage · Excludes values above mean plus one standard deviation. · `src/data-cleansing-analysis.sql`
- [Baseline transactions](https://github.com/tamara-vorobyeva/fantasy-game/blob/main/src/data-cleansing-analysis.sql): filtered transaction set · Consumer-analysis population excluding extreme events. · `src/data-cleansing-analysis.sql`
- [Player-level analytical mart](https://github.com/tamara-vorobyeva/fantasy-game/blob/main/src/data-cleansing-analysis.sql): denormalized mart · Profiles and game dimensions aggregated with payer, spend, frequency, and LTV measures. · `src/data-cleansing-analysis.sql`

### Commercial Analysis

- [Race and spending segmentation](https://github.com/tamara-vorobyeva/fantasy-game/blob/main/src/data-cleansing-analysis.sql): monetization analysis · Compares conversion, transaction value, and frequency. · `src/data-cleansing-analysis.sql`
- [Revenue concentration](https://github.com/tamara-vorobyeva/fantasy-game/blob/main/src/data-cleansing-analysis.sql): Pareto analysis · Separates whale-driven revenue from broad behavior. · `src/data-cleansing-analysis.sql`
- [Item sales concentration](https://github.com/tamara-vorobyeva/fantasy-game/blob/main/src/data-cleansing-analysis.sql): catalog analysis · Aggregates item contribution to sales. · `src/data-cleansing-analysis.sql`
- [Findings and recommendations](https://github.com/tamara-vorobyeva/fantasy-game/blob/main/README.md): documentation output · Product and marketing conclusions from SQL results. · `README.md`

## Connections

- Anonymized dataset extract → PostgreSQL runtime: loaded into
- Normalized game model → PostgreSQL runtime: intended schema
- PostgreSQL runtime → Cleansing and analysis SQL: executed by
- Cleansing and analysis SQL → Transaction attribution repair: repairs
- Cleansing and analysis SQL → Duplicate and anomaly detection: detects
- Transaction attribution repair → Qualified transactions: produces
- Duplicate and anomaly detection → Qualified transactions: qualifies
- Qualified transactions → Statistical outlier filter: bounded by
- Statistical outlier filter → Baseline transactions: produces
- Baseline transactions → Player-level analytical mart: aggregated into
- Normalized game model → Player-level analytical mart: supplies dimensions
- Player-level analytical mart → Race and spending segmentation: supports
- Baseline transactions → Revenue concentration: ranked for
- Baseline transactions → Item sales concentration: aggregated for
- Race and spending segmentation → Findings and recommendations: informs
- Revenue concentration → Findings and recommendations: informs
- Item sales concentration → Findings and recommendations: informs
