# weceng/ticket-purchase architecture

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

- Interactive diagram: https://gitdiagram.com/weceng/ticket-purchase
- Repository: https://github.com/weceng/ticket-purchase

## Overview

This repository is a Damai ticket-purchase automation tool with separate Selenium web and Appium Android workflows. Users configure an event and attendee details, then run a client that searches or opens the event, selects ticket options and attendees, and may submit the order. Web automation also handles login and environment setup; mobile automation drives the installed app through an Appium server. The web flow is concentrated in Concert, while the mobile flow has original and optimized implementations. Some internal stages are documented but not fully shown in the excerpts.

Main entry points: [`damai/concert.py`](https://github.com/weceng/ticket-purchase/blob/master/damai/concert.py) (Web ticket flow), [`damai_appium/damai_app_v2.py`](https://github.com/weceng/ticket-purchase/blob/master/damai_appium/damai_app_v2.py) (Optimized app bot), [`damai_appium/damai_app.py`](https://github.com/weceng/ticket-purchase/blob/master/damai_appium/damai_app.py) (Original app flow), [`damai/damai.py`](https://github.com/weceng/ticket-purchase/blob/master/damai/damai.py) (Web launcher)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web automation"]
  node_web_runner["Web launcher<br/>[damai.py]"]
  node_web_flow["Web ticket flow<br/>[concert.py]"]
  node_web_login["Login and cookies<br/>[concert.py]"]
  node_web_selection["Event and ticket selection<br/>[concert.py]"]
  node_web_attendees["Attendee selection<br/>[concert.py]"]
  node_web_order["Order submission<br/>[concert.py]"]
end

subgraph group_mobile["Mobile automation"]
  node_mobile_v2["Optimized app bot<br/>[damai_app_v2.py]"]
  node_mobile_legacy["Original app flow<br/>[damai_app.py]"]
end

subgraph group_shared["Configuration and setup"]
  node_web_config["Web settings<br/>[config.py]"]
  node_environment["ChromeDriver checks"]
  node_mobile_config["Mobile settings<br/>[config.py]"]
end

node_user(("Operator"))
node_chrome["Chrome and WebDriver"]
node_appium["Appium server"]
node_android["Damai Android app"]

node_user -->|"configures"| node_web_config
node_user -->|"configures"| node_mobile_config
node_user -->|"starts"| node_web_runner
node_web_runner -->|"loads"| node_web_config
node_web_runner -->|"creates and runs"| node_web_flow
node_web_flow -->|"checks driver"| node_environment
node_web_flow -.->|"drives browser"| node_chrome
node_web_flow -->|"handles login"| node_web_login
node_web_flow -->|"selects event and tickets"| node_web_selection
node_web_flow -->|"selects attendees"| node_web_attendees
node_web_flow -->|"may submit order"| node_web_order
node_user -->|"starts"| node_mobile_v2
node_mobile_v2 -->|"loads"| node_mobile_config
node_mobile_v2 -->|"connects to"| node_appium
node_appium -->|"drives"| node_android
node_mobile_v2 -->|"searches and selects tickets"| node_android
node_mobile_v2 -->|"selects attendees and submits"| node_android
node_mobile_legacy -->|"loads"| node_mobile_config
node_mobile_legacy -->|"connects to"| node_appium
node_mobile_legacy -->|"searches and books"| node_android

click node_web_config "https://github.com/weceng/ticket-purchase/blob/master/damai/config.py"
click node_web_runner "https://github.com/weceng/ticket-purchase/blob/master/damai/damai.py"
click node_web_flow "https://github.com/weceng/ticket-purchase/blob/master/damai/concert.py"
click node_web_login "https://github.com/weceng/ticket-purchase/blob/master/damai/concert.py"
click node_web_selection "https://github.com/weceng/ticket-purchase/blob/master/damai/concert.py"
click node_web_attendees "https://github.com/weceng/ticket-purchase/blob/master/damai/concert.py"
click node_web_order "https://github.com/weceng/ticket-purchase/blob/master/damai/concert.py"
click node_environment "https://github.com/weceng/ticket-purchase/blob/master/damai/check_environment.py"
click node_mobile_config "https://github.com/weceng/ticket-purchase/blob/master/damai_appium/config.py"
click node_mobile_v2 "https://github.com/weceng/ticket-purchase/blob/master/damai_appium/damai_app_v2.py"
click node_mobile_legacy "https://github.com/weceng/ticket-purchase/blob/master/damai_appium/damai_app.py"

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_web_runner,node_web_flow,node_web_login,node_web_selection,node_web_attendees,node_web_order toneBlue
class node_mobile_v2,node_mobile_legacy toneAmber
class node_web_config,node_environment,node_mobile_config,node_appium toneMint
class node_user,node_chrome,node_android toneIndigo
```

## Components

### Web automation

- [Web launcher](https://github.com/weceng/ticket-purchase/blob/master/damai/damai.py): `damai/damai.py`
- [Web ticket flow](https://github.com/weceng/ticket-purchase/blob/master/damai/concert.py): `damai/concert.py`
- [Login and cookies](https://github.com/weceng/ticket-purchase/blob/master/damai/concert.py): `damai/concert.py`
- [Event and ticket selection](https://github.com/weceng/ticket-purchase/blob/master/damai/concert.py): `damai/concert.py`
- [Attendee selection](https://github.com/weceng/ticket-purchase/blob/master/damai/concert.py): `damai/concert.py`
- [Order submission](https://github.com/weceng/ticket-purchase/blob/master/damai/concert.py): `damai/concert.py`

### Mobile automation

- [Optimized app bot](https://github.com/weceng/ticket-purchase/blob/master/damai_appium/damai_app_v2.py): `damai_appium/damai_app_v2.py`
- [Original app flow](https://github.com/weceng/ticket-purchase/blob/master/damai_appium/damai_app.py): `damai_appium/damai_app.py`

### Configuration and setup

- [Web settings](https://github.com/weceng/ticket-purchase/blob/master/damai/config.py): `damai/config.py`
- [ChromeDriver checks](https://github.com/weceng/ticket-purchase/blob/master/damai/check_environment.py): `damai/check_environment.py`
- [Mobile settings](https://github.com/weceng/ticket-purchase/blob/master/damai_appium/config.py): `damai_appium/config.py`

### Other components

- **Operator**
- **Chrome and WebDriver**
- **Appium server**
- **Damai Android app**

## Connections

- Operator → Web settings: configures (evidence: `README.md`)
- Operator → Mobile settings: configures (evidence: `README.md`)
- Operator → Web launcher: starts (evidence: `README.md`)
- Web launcher → Web settings: loads (evidence: `damai/damai.py`)
- Web launcher → Web ticket flow: creates and runs (evidence: `damai/damai.py`)
- Web ticket flow → ChromeDriver checks: checks driver (evidence: `damai/concert.py`)
- Web ticket flow → Chrome and WebDriver: drives browser
- Web ticket flow → Login and cookies: handles login (evidence: `damai/concert.py`)
- Web ticket flow → Event and ticket selection: selects event and tickets (evidence: `README.md`)
- Web ticket flow → Attendee selection: selects attendees (evidence: `damai/concert.py`)
- Web ticket flow → Order submission: may submit order (evidence: `README.md`)
- Operator → Optimized app bot: starts (evidence: `README.md`)
- Optimized app bot → Mobile settings: loads (evidence: `damai_appium/damai_app_v2.py`)
- Optimized app bot → Appium server: connects to (evidence: `README.md`)
- Appium server → Damai Android app: drives (evidence: `README.md`)
- Optimized app bot → Damai Android app: searches and selects tickets (evidence: `damai_appium/damai_app_v2.py`)
- Optimized app bot → Damai Android app: selects attendees and submits (evidence: `damai_appium/damai_app_v2.py`)
- Original app flow → Mobile settings: loads (evidence: `damai_appium/damai_app.py`)
- Original app flow → Appium server: connects to (evidence: `README.md`)
- Original app flow → Damai Android app: searches and books (evidence: `damai_appium/damai_app.py`)
