# axrealz/alphaelite.winforms architecture

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

- Interactive diagram: https://gitdiagram.com/axrealz/alphaelite.winforms
- Repository: https://github.com/axrealz/alphaelite.winforms

## Overview

AlphaElite is a multi-tenant gym-management system with a master administration layer and tenant-facing member operations. The repository includes both a WinForms application and an ASP.NET API. The main flow is tenant selection and authentication, followed by tenant-scoped operations such as members, attendance, payments, inquiries and feedback; master administrators also manage companies and versioned subscriptions. The excerpts establish authentication and subscription persistence behavior, but not most UI or API call paths, so those connections are marked unverified or omitted.

Main entry points: [`WinFormsLibrary1/services/TenantAuthenticationService.cs`](https://github.com/axrealz/alphaelite.winforms/blob/master/WinFormsLibrary1/services/TenantAuthenticationService.cs) (Tenant login), [`AlphaElite.api/Controllers`](https://github.com/axrealz/alphaelite.winforms/tree/master/AlphaElite.api/Controllers) (Tenant API operations), [`AlphaElite.winforms/MasterDashboardForm.cs`](https://github.com/axrealz/alphaelite.winforms/blob/master/AlphaElite.winforms/MasterDashboardForm.cs) (Master admin screens), [`WinFormsLibrary1/data/MasterAlphaEliteDbContext.cs`](https://github.com/axrealz/alphaelite.winforms/blob/master/WinFormsLibrary1/data/MasterAlphaEliteDbContext.cs) (Master database context)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Applications and API"]
  node_winforms["WinForms application<br/>[Program.cs]"]
  node_api["ASP.NET API<br/>[Program.cs]"]
  node_apiops["Tenant API operations<br/>[Controllers]"]
end

subgraph group_tenant["Tenant access and operations"]
  node_login["Tenant login"]
  node_tenantresolve["Tenant database resolution"]
  node_tenantconnect["Tenant connection factory"]
  node_tenantfactory["Tenant context factory"]
  node_membership["Member and attendance<br/>[Member.cs]"]
  node_billing["Tenant payments and subscriptions<br/>[Payment.cs]"]
  node_engagement["Inquiries and feedback<br/>[Inquiry.cs]"]
end

subgraph group_master["Master administration"]
  node_masteradmin["Master administration services"]
  node_identity["Master identity"]
  node_bi["Business intelligence"]
  node_subscriptions["Subscription management"]
  node_masterui["Master admin screens"]
end

subgraph group_domain["Domain and persistence"]
  node_companies["Company and tenant records<br/>[Company.cs]"]
  node_planversions["Plan version snapshots"]
  node_domainrecords["Business domain records<br/>[entities]"]
  node_masterdb[("Master database context")]
  node_tenantdb[("Standard tenant context")]
  node_tenantcdb[("Branch-aware tenant context")]
end

node_admin(("Admin user"))
node_gymuser(("Gym user"))

node_gymuser -.->|"uses"| node_winforms
node_admin -.->|"uses"| node_winforms
node_gymuser -.->|"requests"| node_api
node_winforms -.->|"authenticates via"| node_login
node_winforms -.->|"presents"| node_masterui
node_api -.->|"routes to"| node_apiops
node_apiops -.->|"opens tenant context"| node_tenantfactory
node_apiops -.->|"operates on"| node_membership
node_apiops -.->|"operates on"| node_billing
node_apiops -.->|"operates on"| node_engagement
node_login -->|"reads tenant directory"| node_masterdb
node_login -->|"resolves tenant"| node_tenantresolve
node_login -->|"creates options"| node_tenantconnect
node_login -->|"queries accounts"| node_tenantdb
node_login -->|"queries accounts"| node_tenantcdb
node_tenantfactory -.->|"creates context"| node_tenantdb
node_masterui -.->|"administers tenants"| node_masteradmin
node_masterui -.->|"manages plans"| node_subscriptions
node_masterui -.->|"views insights"| node_bi
node_masterui -.->|"manages identities"| node_identity
node_masteradmin -->|"persists administration"| node_masterdb
node_subscriptions -->|"reads and writes"| node_masterdb
node_subscriptions -->|"publishes snapshots"| node_planversions
node_subscriptions -->|"manages subscriptions"| node_companies
node_masterdb -->|"maps"| node_companies
node_masterdb -->|"maps"| node_planversions
node_tenantdb -->|"maps tenant records"| node_domainrecords
node_tenantcdb -->|"maps branch records"| node_domainrecords

click node_winforms "https://github.com/axrealz/alphaelite.winforms/blob/master/AlphaElite.winforms/Program.cs"
click node_api "https://github.com/axrealz/alphaelite.winforms/blob/master/AlphaElite.api/Program.cs"
click node_apiops "https://github.com/axrealz/alphaelite.winforms/tree/master/AlphaElite.api/Controllers"
click node_login "https://github.com/axrealz/alphaelite.winforms/blob/master/WinFormsLibrary1/services/TenantAuthenticationService.cs"
click node_tenantresolve "https://github.com/axrealz/alphaelite.winforms/blob/master/WinFormsLibrary1/services/TenantDatabaseResolver.cs"
click node_tenantconnect "https://github.com/axrealz/alphaelite.winforms/blob/master/WinFormsLibrary1/services/TenantDbConnectionFactory.cs"
click node_tenantfactory "https://github.com/axrealz/alphaelite.winforms/blob/master/WinFormsLibrary1/services/ITenantDbContextFactory.cs"
click node_membership "https://github.com/axrealz/alphaelite.winforms/blob/master/AlphaElite.domain/entities/Member.cs"
click node_billing "https://github.com/axrealz/alphaelite.winforms/blob/master/AlphaElite.domain/entities/Payment.cs"
click node_engagement "https://github.com/axrealz/alphaelite.winforms/blob/master/AlphaElite.domain/entities/Inquiry.cs"
click node_masteradmin "https://github.com/axrealz/alphaelite.winforms/blob/master/WinFormsLibrary1/services/MasterTenantAdminService.cs"
click node_identity "https://github.com/axrealz/alphaelite.winforms/blob/master/WinFormsLibrary1/services/MasterIdentityService.cs"
click node_bi "https://github.com/axrealz/alphaelite.winforms/blob/master/WinFormsLibrary1/services/MasterBusinessIntelligenceService.cs"
click node_subscriptions "https://github.com/axrealz/alphaelite.winforms/blob/master/WinFormsLibrary1/services/SubscriptionService.cs"
click node_masterui "https://github.com/axrealz/alphaelite.winforms/blob/master/AlphaElite.winforms/MasterDashboardForm.cs"
click node_companies "https://github.com/axrealz/alphaelite.winforms/blob/master/AlphaElite.domain/entities/Company.cs"
click node_planversions "https://github.com/axrealz/alphaelite.winforms/blob/master/AlphaElite.domain/entities/SubscriptionPlanVersion.cs"
click node_domainrecords "https://github.com/axrealz/alphaelite.winforms/tree/master/AlphaElite.domain/entities"
click node_masterdb "https://github.com/axrealz/alphaelite.winforms/blob/master/WinFormsLibrary1/data/MasterAlphaEliteDbContext.cs"
click node_tenantdb "https://github.com/axrealz/alphaelite.winforms/blob/master/WinFormsLibrary1/data/TenantAlphaEliteDbContext.cs"
click node_tenantcdb "https://github.com/axrealz/alphaelite.winforms/blob/master/WinFormsLibrary1/data/TenantCAlphaEliteDbContext.cs"

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_winforms,node_api,node_apiops,node_admin,node_gymuser toneBlue
class node_login,node_tenantresolve,node_tenantconnect,node_tenantfactory,node_membership,node_billing,node_engagement toneAmber
class node_masteradmin,node_identity,node_bi,node_subscriptions,node_masterui toneMint
class node_companies,node_planversions,node_domainrecords,node_masterdb,node_tenantdb,node_tenantcdb toneRose
```

## Components

### Applications and API

- [WinForms application](https://github.com/axrealz/alphaelite.winforms/blob/master/AlphaElite.winforms/Program.cs): `AlphaElite.winforms/Program.cs`
- [ASP.NET API](https://github.com/axrealz/alphaelite.winforms/blob/master/AlphaElite.api/Program.cs): `AlphaElite.api/Program.cs`
- [Tenant API operations](https://github.com/axrealz/alphaelite.winforms/tree/master/AlphaElite.api/Controllers): `AlphaElite.api/Controllers`

### Tenant access and operations

- [Tenant login](https://github.com/axrealz/alphaelite.winforms/blob/master/WinFormsLibrary1/services/TenantAuthenticationService.cs): `WinFormsLibrary1/services/TenantAuthenticationService.cs`
- [Tenant database resolution](https://github.com/axrealz/alphaelite.winforms/blob/master/WinFormsLibrary1/services/TenantDatabaseResolver.cs): `WinFormsLibrary1/services/TenantDatabaseResolver.cs`
- [Tenant connection factory](https://github.com/axrealz/alphaelite.winforms/blob/master/WinFormsLibrary1/services/TenantDbConnectionFactory.cs): `WinFormsLibrary1/services/TenantDbConnectionFactory.cs`
- [Tenant context factory](https://github.com/axrealz/alphaelite.winforms/blob/master/WinFormsLibrary1/services/ITenantDbContextFactory.cs): `WinFormsLibrary1/services/ITenantDbContextFactory.cs`
- [Member and attendance](https://github.com/axrealz/alphaelite.winforms/blob/master/AlphaElite.domain/entities/Member.cs): `AlphaElite.domain/entities/Member.cs`
- [Tenant payments and subscriptions](https://github.com/axrealz/alphaelite.winforms/blob/master/AlphaElite.domain/entities/Payment.cs): `AlphaElite.domain/entities/Payment.cs`
- [Inquiries and feedback](https://github.com/axrealz/alphaelite.winforms/blob/master/AlphaElite.domain/entities/Inquiry.cs): `AlphaElite.domain/entities/Inquiry.cs`

### Master administration

- [Master administration services](https://github.com/axrealz/alphaelite.winforms/blob/master/WinFormsLibrary1/services/MasterTenantAdminService.cs): `WinFormsLibrary1/services/MasterTenantAdminService.cs`
- [Master identity](https://github.com/axrealz/alphaelite.winforms/blob/master/WinFormsLibrary1/services/MasterIdentityService.cs): `WinFormsLibrary1/services/MasterIdentityService.cs`
- [Business intelligence](https://github.com/axrealz/alphaelite.winforms/blob/master/WinFormsLibrary1/services/MasterBusinessIntelligenceService.cs): `WinFormsLibrary1/services/MasterBusinessIntelligenceService.cs`
- [Subscription management](https://github.com/axrealz/alphaelite.winforms/blob/master/WinFormsLibrary1/services/SubscriptionService.cs): `WinFormsLibrary1/services/SubscriptionService.cs`
- [Master admin screens](https://github.com/axrealz/alphaelite.winforms/blob/master/AlphaElite.winforms/MasterDashboardForm.cs): `AlphaElite.winforms/MasterDashboardForm.cs`

### Domain and persistence

- [Company and tenant records](https://github.com/axrealz/alphaelite.winforms/blob/master/AlphaElite.domain/entities/Company.cs): `AlphaElite.domain/entities/Company.cs`
- [Plan version snapshots](https://github.com/axrealz/alphaelite.winforms/blob/master/AlphaElite.domain/entities/SubscriptionPlanVersion.cs): `AlphaElite.domain/entities/SubscriptionPlanVersion.cs`
- [Business domain records](https://github.com/axrealz/alphaelite.winforms/tree/master/AlphaElite.domain/entities): `AlphaElite.domain/entities`
- [Master database context](https://github.com/axrealz/alphaelite.winforms/blob/master/WinFormsLibrary1/data/MasterAlphaEliteDbContext.cs): `WinFormsLibrary1/data/MasterAlphaEliteDbContext.cs`
- [Standard tenant context](https://github.com/axrealz/alphaelite.winforms/blob/master/WinFormsLibrary1/data/TenantAlphaEliteDbContext.cs): `WinFormsLibrary1/data/TenantAlphaEliteDbContext.cs`
- [Branch-aware tenant context](https://github.com/axrealz/alphaelite.winforms/blob/master/WinFormsLibrary1/data/TenantCAlphaEliteDbContext.cs): `WinFormsLibrary1/data/TenantCAlphaEliteDbContext.cs`

### Other components

- **Admin user**
- **Gym user**

## Connections

- Gym user → WinForms application: uses
- Admin user → WinForms application: uses
- Gym user → ASP.NET API: requests
- WinForms application → Tenant login: authenticates via
- WinForms application → Master admin screens: presents
- ASP.NET API → Tenant API operations: routes to
- Tenant API operations → Tenant context factory: opens tenant context (evidence: `AlphaElite.api/Controllers/PaymentsController.cs`)
- Tenant API operations → Member and attendance: operates on (evidence: `AlphaElite.api/Controllers/MembersController.cs`)
- Tenant API operations → Tenant payments and subscriptions: operates on (evidence: `AlphaElite.api/Controllers/PaymentsController.cs`)
- Tenant API operations → Inquiries and feedback: operates on (evidence: `AlphaElite.api/Controllers/InquiriesController.cs`)
- Tenant login → Master database context: reads tenant directory (evidence: `WinFormsLibrary1/services/TenantAuthenticationService.cs`)
- Tenant login → Tenant database resolution: resolves tenant (evidence: `WinFormsLibrary1/services/TenantAuthenticationService.cs`)
- Tenant login → Tenant connection factory: creates options (evidence: `WinFormsLibrary1/services/TenantAuthenticationService.cs`)
- Tenant login → Standard tenant context: queries accounts (evidence: `WinFormsLibrary1/services/TenantAuthenticationService.cs`)
- Tenant login → Branch-aware tenant context: queries accounts (evidence: `WinFormsLibrary1/services/TenantAuthenticationService.cs`)
- Tenant context factory → Standard tenant context: creates context (evidence: `WinFormsLibrary1/services/ITenantDbContextFactory.cs`)
- Master admin screens → Master administration services: administers tenants
- Master admin screens → Subscription management: manages plans
- Master admin screens → Business intelligence: views insights
- Master admin screens → Master identity: manages identities
- Master administration services → Master database context: persists administration (evidence: `WinFormsLibrary1/services/MasterTenantAdminService.cs`)
- Subscription management → Master database context: reads and writes (evidence: `WinFormsLibrary1/services/SubscriptionService.cs`)
- Subscription management → Plan version snapshots: publishes snapshots (evidence: `WinFormsLibrary1/services/SubscriptionService.cs`)
- Subscription management → Company and tenant records: manages subscriptions (evidence: `WinFormsLibrary1/services/SubscriptionService.cs`)
- Master database context → Company and tenant records: maps (evidence: `WinFormsLibrary1/data/MasterAlphaEliteDbContext.cs`)
- Master database context → Plan version snapshots: maps (evidence: `WinFormsLibrary1/data/MasterAlphaEliteDbContext.cs`)
- Standard tenant context → Business domain records: maps tenant records (evidence: `WinFormsLibrary1/data/TenantAlphaEliteDbContext.cs`)
- Branch-aware tenant context → Business domain records: maps branch records (evidence: `WinFormsLibrary1/data/TenantCAlphaEliteDbContext.cs`)
