# sengchhunyeang/topupgame architecture

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

- Interactive diagram: https://gitdiagram.com/sengchhunyeang/topupgame
- Repository: https://github.com/sengchhunyeang/topupgame

## Overview

ELLASTORE is a Flask game top-up storefront with a browser-based purchase flow and an admin panel for order and subscriber operations. A customer selects a game and product, enters player details, optionally applies a coupon, and submits an order; the server validates inputs and calculates the price before saving a pending-payment order. The README documents the broader UI and admin capabilities; source excerpts confirm key API and service calls. Payment processing is not connected, and player lookup is a demo mock.

Main entry points: [`ellastore/routes/api.py`](https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/routes/api.py) (JSON API), [`ellastore/admin/views.py`](https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/admin/views.py) (Admin Pages), [`ellastore/static/js/pages/topup.js`](https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/static/js/pages/topup.js) (Top-up Flow), [`ellastore/services/orders.py`](https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/services/orders.py) (Order Service)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront"]
  node_app["Flask App<br/>[__init__.py]"]
  node_page_routes["Store Pages<br/>[pages.py]"]
  node_page_templates["Store Templates"]
  node_frontend_entry["Frontend Entry<br/>[main.js]"]
  node_home_page["Home Interactions<br/>[home.js]"]
  node_topup_ui["Top-up Flow<br/>[topup.js]"]
  node_choice_group["Product And Payment Selection<br/>[choice-group.js]"]
  node_player_check["Player Check UI<br/>[player-check.js]"]
  node_coupon_ui["Coupon UI<br/>[coupon-field.js]"]
  node_api_client["Browser API Client<br/>[api.js]"]
  node_content["Site Content<br/>[content.py]"]
end

subgraph group_purchase["Purchase API"]
  node_api_routes["JSON API<br/>[api.py]"]
  node_player_service["Player Validation<br/>[players.py]"]
  node_coupon_service["Coupon Service<br/>[coupons.py]"]
  node_order_service["Order Service<br/>[orders.py]"]
  node_subscriber_service["Subscriber Service<br/>[subscribers.py]"]
end

subgraph group_operations["Admin Operations"]
  node_admin_auth["Admin Authentication<br/>[auth.py]"]
  node_admin_views["Admin Pages<br/>[views.py]"]
  node_reports["Dashboard Reports<br/>[reports.py]"]
  node_admin_templates["Admin Templates"]
end

subgraph group_data["Catalog And Data"]
  node_catalog["Game Catalog<br/>[catalog.py]"]
  node_sqlite[("SQLite Database<br/>[db.py]")]
end

node_customer(("Customer"))

node_customer -->|"browses"| node_page_routes
node_page_routes -->|"loads games"| node_catalog
node_page_routes -->|"loads copy"| node_content
node_page_routes -->|"renders"| node_page_templates
node_app -->|"registers"| node_page_routes
node_app -->|"registers"| node_api_routes
node_frontend_entry -->|"dispatches"| node_home_page
node_frontend_entry -->|"dispatches"| node_topup_ui
node_customer -->|"enters details"| node_topup_ui
node_topup_ui -->|"uses"| node_choice_group
node_topup_ui -->|"uses"| node_player_check
node_topup_ui -->|"uses"| node_coupon_ui
node_topup_ui -->|"submits requests"| node_api_client
node_api_client -->|"calls JSON API"| node_api_routes
node_api_routes -->|"reads games"| node_catalog
node_api_routes -->|"validates player"| node_player_service
node_api_routes -->|"redeems coupon"| node_coupon_service
node_api_routes -->|"creates order"| node_order_service
node_api_routes -->|"subscribes email"| node_subscriber_service
node_order_service -->|"validates and names"| node_player_service
node_order_service -->|"applies discount"| node_coupon_service
node_order_service -->|"writes and reads orders"| node_sqlite
node_subscriber_service -->|"stores subscribers"| node_sqlite
node_admin_views -->|"guards pages"| node_admin_auth
node_admin_views -->|"manages orders"| node_order_service
node_admin_views -->|"loads aggregates"| node_reports
node_admin_views -->|"lists subscribers"| node_subscriber_service
node_admin_views -->|"lists games"| node_catalog
node_admin_views -->|"renders"| node_admin_templates
node_reports -->|"queries metrics"| node_sqlite
node_reports -->|"labels games"| node_catalog
node_reports -->|"uses order statuses"| node_order_service

click node_app "https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/__init__.py"
click node_page_routes "https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/routes/pages.py"
click node_page_templates "https://github.com/sengchhunyeang/topupgame/tree/main/ellastore/templates"
click node_frontend_entry "https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/static/js/main.js"
click node_home_page "https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/static/js/pages/home.js"
click node_topup_ui "https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/static/js/pages/topup.js"
click node_choice_group "https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/static/js/components/choice-group.js"
click node_player_check "https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/static/js/components/player-check.js"
click node_coupon_ui "https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/static/js/components/coupon-field.js"
click node_api_client "https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/static/js/lib/api.js"
click node_api_routes "https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/routes/api.py"
click node_catalog "https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/catalog.py"
click node_content "https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/content.py"
click node_player_service "https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/services/players.py"
click node_coupon_service "https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/services/coupons.py"
click node_order_service "https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/services/orders.py"
click node_subscriber_service "https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/services/subscribers.py"
click node_sqlite "https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/db.py"
click node_admin_auth "https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/admin/auth.py"
click node_admin_views "https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/admin/views.py"
click node_reports "https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/services/reports.py"
click node_admin_templates "https://github.com/sengchhunyeang/topupgame/tree/main/ellastore/templates/admin"

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_page_routes,node_page_templates,node_frontend_entry,node_home_page,node_topup_ui,node_choice_group,node_player_check,node_coupon_ui,node_api_client,node_content toneBlue
class node_api_routes,node_player_service,node_coupon_service,node_order_service,node_subscriber_service toneAmber
class node_admin_auth,node_admin_views,node_reports,node_admin_templates toneMint
class node_catalog,node_sqlite toneRose
class node_customer toneIndigo
```

## Components

### Storefront

- [Flask App](https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/__init__.py): `ellastore/__init__.py`
- [Store Pages](https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/routes/pages.py): `ellastore/routes/pages.py`
- [Store Templates](https://github.com/sengchhunyeang/topupgame/tree/main/ellastore/templates): `ellastore/templates`
- [Frontend Entry](https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/static/js/main.js): `ellastore/static/js/main.js`
- [Home Interactions](https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/static/js/pages/home.js): `ellastore/static/js/pages/home.js`
- [Top-up Flow](https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/static/js/pages/topup.js): `ellastore/static/js/pages/topup.js`
- [Product And Payment Selection](https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/static/js/components/choice-group.js): `ellastore/static/js/components/choice-group.js`
- [Player Check UI](https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/static/js/components/player-check.js): `ellastore/static/js/components/player-check.js`
- [Coupon UI](https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/static/js/components/coupon-field.js): `ellastore/static/js/components/coupon-field.js`
- [Browser API Client](https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/static/js/lib/api.js): `ellastore/static/js/lib/api.js`
- [Site Content](https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/content.py): `ellastore/content.py`

### Purchase API

- [JSON API](https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/routes/api.py): `ellastore/routes/api.py`
- [Player Validation](https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/services/players.py): `ellastore/services/players.py`
- [Coupon Service](https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/services/coupons.py): `ellastore/services/coupons.py`
- [Order Service](https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/services/orders.py): `ellastore/services/orders.py`
- [Subscriber Service](https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/services/subscribers.py): `ellastore/services/subscribers.py`

### Admin Operations

- [Admin Authentication](https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/admin/auth.py): `ellastore/admin/auth.py`
- [Admin Pages](https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/admin/views.py): `ellastore/admin/views.py`
- [Dashboard Reports](https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/services/reports.py): `ellastore/services/reports.py`
- [Admin Templates](https://github.com/sengchhunyeang/topupgame/tree/main/ellastore/templates/admin): `ellastore/templates/admin`

### Catalog And Data

- [Game Catalog](https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/catalog.py): `ellastore/catalog.py`
- [SQLite Database](https://github.com/sengchhunyeang/topupgame/blob/main/ellastore/db.py): `ellastore/db.py`

### Other components

- **Customer**

## Connections

- Customer → Store Pages: browses (evidence: `README.md`)
- Store Pages → Game Catalog: loads games (evidence: `ellastore/routes/pages.py`)
- Store Pages → Site Content: loads copy (evidence: `ellastore/routes/pages.py`)
- Store Pages → Store Templates: renders (evidence: `README.md`)
- Flask App → Store Pages: registers (evidence: `ellastore/__init__.py`)
- Flask App → JSON API: registers (evidence: `ellastore/__init__.py`)
- Frontend Entry → Home Interactions: dispatches (evidence: `ellastore/static/js/main.js`)
- Frontend Entry → Top-up Flow: dispatches (evidence: `ellastore/static/js/main.js`)
- Customer → Top-up Flow: enters details (evidence: `README.md`)
- Top-up Flow → Product And Payment Selection: uses (evidence: `ellastore/static/js/pages/topup.js`)
- Top-up Flow → Player Check UI: uses (evidence: `ellastore/static/js/pages/topup.js`)
- Top-up Flow → Coupon UI: uses (evidence: `ellastore/static/js/pages/topup.js`)
- Top-up Flow → Browser API Client: submits requests (evidence: `ellastore/static/js/pages/topup.js`)
- Browser API Client → JSON API: calls JSON API (evidence: `README.md`)
- JSON API → Game Catalog: reads games (evidence: `ellastore/routes/api.py`)
- JSON API → Player Validation: validates player (evidence: `ellastore/routes/api.py`)
- JSON API → Coupon Service: redeems coupon (evidence: `ellastore/routes/api.py`)
- JSON API → Order Service: creates order (evidence: `ellastore/routes/api.py`)
- JSON API → Subscriber Service: subscribes email (evidence: `ellastore/routes/api.py`)
- Order Service → Player Validation: validates and names (evidence: `ellastore/services/orders.py`)
- Order Service → Coupon Service: applies discount (evidence: `ellastore/services/orders.py`)
- Order Service → SQLite Database: writes and reads orders (evidence: `ellastore/services/orders.py`)
- Subscriber Service → SQLite Database: stores subscribers (evidence: `ellastore/services/subscribers.py`)
- Admin Pages → Admin Authentication: guards pages (evidence: `ellastore/admin/views.py`)
- Admin Pages → Order Service: manages orders (evidence: `ellastore/admin/views.py`)
- Admin Pages → Dashboard Reports: loads aggregates (evidence: `ellastore/admin/views.py`)
- Admin Pages → Subscriber Service: lists subscribers (evidence: `ellastore/admin/views.py`)
- Admin Pages → Game Catalog: lists games (evidence: `ellastore/admin/views.py`)
- Admin Pages → Admin Templates: renders (evidence: `README.md`)
- Dashboard Reports → SQLite Database: queries metrics (evidence: `ellastore/services/reports.py`)
- Dashboard Reports → Game Catalog: labels games (evidence: `ellastore/services/reports.py`)
- Dashboard Reports → Order Service: uses order statuses (evidence: `ellastore/services/reports.py`)
