# lokashche/netgainz architecture

> Architecture diagram of the GitHub repository lokashche/netgainz, 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/lokashche/netgainz
- Repository: https://github.com/lokashche/netgainz

## Overview

NetGainz is a gym-management and accounting product: owners and staff use a phone-friendly Next.js app, whose API layer fronts a Frappe app that records gym operations and posts accounting through ERPNext. The main workflow spans member and plan setup, billing and collections, expense tracking, and Profit First cash allocation; additional product areas include check-in, enquiries, classes, offers, assessments, and reporting. The README documents the overall REST/ERPNext architecture; sampled routes show direct resource requests, while some backend subsystem links are supported only by the source index. Unsampled implementation details are not inferred.

Main entry points: [`owner-app/app/api`](https://github.com/lokashche/netgainz/tree/develop/owner-app/app/api) (REST API layer), [`netgainz/net_gainz/accounting/billing.py`](https://github.com/lokashche/netgainz/blob/develop/netgainz/net_gainz/accounting/billing.py) (Billing and collections), [`netgainz/net_gainz/accounting/provisioning.py`](https://github.com/lokashche/netgainz/blob/develop/netgainz/net_gainz/accounting/provisioning.py) (ERP master provisioning), [`owner-app/app/(dashboard)`](https://github.com/lokashche/netgainz/tree/develop/owner-app/app/(dashboard)) (Owner web app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_owner_app["Owner app"]
  node_owner_ui["Owner web app"]
  node_api_bff["REST API layer"]
  node_session_auth["Session authentication<br/>[session.ts]"]
end

subgraph group_gym_operations["Gym operations"]
  node_member_records["Member records<br/>[member.py]"]
  node_membership_plans["Plans and memberships<br/>[membership_plan.py]"]
  node_gym_lifecycle["Enquiries and lifecycle"]
  node_front_desk["Check-in and attendance<br/>[checkin.py]"]
  node_packs_passes["Packs and day passes<br/>[packs.py]"]
  node_assessments["Fitness assessments<br/>[assessments.py]"]
  node_classes_coaches["Classes and coaches"]
  node_data_loading["Gym data loading<br/>[data_load.py]"]
end

subgraph group_money_and_books["Money and books"]
  node_accounting_billing["Billing and collections<br/>[billing.py]"]
  node_billing_support["Billing rules"]
  node_erp_provisioning["ERP master provisioning<br/>[provisioning.py]"]
  node_discount_offers["Discounts and offers<br/>[discounts.py]"]
  node_expense_tracking["Expenses<br/>[expense.py]"]
  node_profit_first["Profit First<br/>[calc.py]"]
  node_reports["Reports and dashboards<br/>[reports.py]"]
end

subgraph group_platform["Platform"]
  node_permissions["Role permissions<br/>[permissions.py]"]
  node_erpnext[("ERPNext accounting engine")]
end

node_gym_owner(("Gym owner or staff"))

node_gym_owner -->|"uses"| node_owner_ui
node_owner_ui -->|"calls REST"| node_api_bff
node_api_bff -->|"checks session"| node_session_auth
node_api_bff -->|"requests resources"| node_erpnext
node_api_bff -->|"requests resources"| node_erpnext
node_api_bff -->|"requests resources"| node_erpnext
node_api_bff -.->|"manages records"| node_member_records
node_api_bff -.->|"manages plans"| node_membership_plans
node_api_bff -.->|"supports pipeline"| node_gym_lifecycle
node_api_bff -.->|"supports check-in"| node_front_desk
node_api_bff -.->|"supports sales"| node_packs_passes
node_api_bff -.->|"supports assessments"| node_assessments
node_api_bff -->|"manages classes"| node_classes_coaches
node_api_bff -.->|"supports billing"| node_accounting_billing
node_membership_plans -->|"provisions masters"| node_erp_provisioning
node_accounting_billing -->|"uses billing rules"| node_billing_support
node_accounting_billing -->|"provisions counterparties"| node_erp_provisioning
node_accounting_billing -->|"uses cash logic"| node_profit_first
node_erp_provisioning -->|"creates ERP masters"| node_erpnext
node_api_bff -.->|"supports offers"| node_discount_offers
node_api_bff -.->|"records expenses"| node_expense_tracking
node_api_bff -.->|"shows cash split"| node_profit_first
node_api_bff -.->|"serves reports"| node_reports
node_api_bff -.->|"loads gym data"| node_data_loading
node_api_bff -.->|"checks capabilities"| node_permissions
node_gym_owner -.->|"initiates operations"| node_api_bff

click node_owner_ui "https://github.com/lokashche/netgainz/tree/develop/owner-app/app/(dashboard)"
click node_api_bff "https://github.com/lokashche/netgainz/tree/develop/owner-app/app/api"
click node_session_auth "https://github.com/lokashche/netgainz/blob/develop/owner-app/lib/session.ts"
click node_member_records "https://github.com/lokashche/netgainz/blob/develop/netgainz/net_gainz/doctype/member/member.py"
click node_membership_plans "https://github.com/lokashche/netgainz/blob/develop/netgainz/net_gainz/doctype/membership_plan/membership_plan.py"
click node_gym_lifecycle "https://github.com/lokashche/netgainz/tree/develop/netgainz/net_gainz/operations"
click node_front_desk "https://github.com/lokashche/netgainz/blob/develop/netgainz/net_gainz/operations/checkin.py"
click node_packs_passes "https://github.com/lokashche/netgainz/blob/develop/netgainz/net_gainz/operations/packs.py"
click node_assessments "https://github.com/lokashche/netgainz/blob/develop/netgainz/net_gainz/operations/assessments.py"
click node_classes_coaches "https://github.com/lokashche/netgainz/blob/develop/netgainz/net_gainz/doctype/session_schedule/session_schedule.py"
click node_accounting_billing "https://github.com/lokashche/netgainz/blob/develop/netgainz/net_gainz/accounting/billing.py"
click node_billing_support "https://github.com/lokashche/netgainz/tree/develop/netgainz/net_gainz/accounting"
click node_erp_provisioning "https://github.com/lokashche/netgainz/blob/develop/netgainz/net_gainz/accounting/provisioning.py"
click node_discount_offers "https://github.com/lokashche/netgainz/blob/develop/netgainz/net_gainz/accounting/discounts.py"
click node_expense_tracking "https://github.com/lokashche/netgainz/blob/develop/netgainz/net_gainz/doctype/expense/expense.py"
click node_profit_first "https://github.com/lokashche/netgainz/blob/develop/netgainz/net_gainz/profit_first/calc.py"
click node_reports "https://github.com/lokashche/netgainz/blob/develop/netgainz/net_gainz/profit_first/reports.py"
click node_data_loading "https://github.com/lokashche/netgainz/blob/develop/netgainz/net_gainz/loader/data_load.py"
click node_permissions "https://github.com/lokashche/netgainz/blob/develop/netgainz/net_gainz/permissions.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_owner_ui,node_api_bff,node_session_auth toneBlue
class node_member_records,node_membership_plans,node_gym_lifecycle,node_front_desk,node_packs_passes,node_assessments,node_classes_coaches,node_data_loading toneAmber
class node_accounting_billing,node_billing_support,node_erp_provisioning,node_discount_offers,node_expense_tracking,node_profit_first,node_reports toneMint
class node_permissions,node_erpnext toneRose
class node_gym_owner toneIndigo
```

## Components

### Owner app

- [Owner web app](https://github.com/lokashche/netgainz/tree/develop/owner-app/app/(dashboard)): `owner-app/app/(dashboard)`
- [REST API layer](https://github.com/lokashche/netgainz/tree/develop/owner-app/app/api): `owner-app/app/api`
- [Session authentication](https://github.com/lokashche/netgainz/blob/develop/owner-app/lib/session.ts): `owner-app/lib/session.ts`

### Gym operations

- [Member records](https://github.com/lokashche/netgainz/blob/develop/netgainz/net_gainz/doctype/member/member.py): `netgainz/net_gainz/doctype/member/member.py`
- [Plans and memberships](https://github.com/lokashche/netgainz/blob/develop/netgainz/net_gainz/doctype/membership_plan/membership_plan.py): `netgainz/net_gainz/doctype/membership_plan/membership_plan.py`
- [Enquiries and lifecycle](https://github.com/lokashche/netgainz/tree/develop/netgainz/net_gainz/operations): `netgainz/net_gainz/operations`
- [Check-in and attendance](https://github.com/lokashche/netgainz/blob/develop/netgainz/net_gainz/operations/checkin.py): `netgainz/net_gainz/operations/checkin.py`
- [Packs and day passes](https://github.com/lokashche/netgainz/blob/develop/netgainz/net_gainz/operations/packs.py): `netgainz/net_gainz/operations/packs.py`
- [Fitness assessments](https://github.com/lokashche/netgainz/blob/develop/netgainz/net_gainz/operations/assessments.py): `netgainz/net_gainz/operations/assessments.py`
- [Classes and coaches](https://github.com/lokashche/netgainz/blob/develop/netgainz/net_gainz/doctype/session_schedule/session_schedule.py): `netgainz/net_gainz/doctype/session_schedule/session_schedule.py`
- [Gym data loading](https://github.com/lokashche/netgainz/blob/develop/netgainz/net_gainz/loader/data_load.py): `netgainz/net_gainz/loader/data_load.py`

### Money and books

- [Billing and collections](https://github.com/lokashche/netgainz/blob/develop/netgainz/net_gainz/accounting/billing.py): `netgainz/net_gainz/accounting/billing.py`
- [Billing rules](https://github.com/lokashche/netgainz/tree/develop/netgainz/net_gainz/accounting): `netgainz/net_gainz/accounting`
- [ERP master provisioning](https://github.com/lokashche/netgainz/blob/develop/netgainz/net_gainz/accounting/provisioning.py): `netgainz/net_gainz/accounting/provisioning.py`
- [Discounts and offers](https://github.com/lokashche/netgainz/blob/develop/netgainz/net_gainz/accounting/discounts.py): `netgainz/net_gainz/accounting/discounts.py`
- [Expenses](https://github.com/lokashche/netgainz/blob/develop/netgainz/net_gainz/doctype/expense/expense.py): `netgainz/net_gainz/doctype/expense/expense.py`
- [Profit First](https://github.com/lokashche/netgainz/blob/develop/netgainz/net_gainz/profit_first/calc.py): `netgainz/net_gainz/profit_first/calc.py`
- [Reports and dashboards](https://github.com/lokashche/netgainz/blob/develop/netgainz/net_gainz/profit_first/reports.py): `netgainz/net_gainz/profit_first/reports.py`

### Platform

- [Role permissions](https://github.com/lokashche/netgainz/blob/develop/netgainz/net_gainz/permissions.py): `netgainz/net_gainz/permissions.py`
- **ERPNext accounting engine**

### Other components

- **Gym owner or staff**

## Connections

- Gym owner or staff → Owner web app: uses (evidence: `README.md`)
- Owner web app → REST API layer: calls REST (evidence: `README.md`)
- REST API layer → Session authentication: checks session (evidence: `owner-app/app/api/class-sessions/route.ts`)
- REST API layer → ERPNext accounting engine: requests resources (evidence: `owner-app/app/api/class-sessions/route.ts`)
- REST API layer → ERPNext accounting engine: requests resources (evidence: `owner-app/app/api/bookings/route.ts`)
- REST API layer → ERPNext accounting engine: requests resources (evidence: `owner-app/app/api/enquiries/route.ts`)
- REST API layer → Member records: manages records
- REST API layer → Plans and memberships: manages plans
- REST API layer → Enquiries and lifecycle: supports pipeline
- REST API layer → Check-in and attendance: supports check-in
- REST API layer → Packs and day passes: supports sales
- REST API layer → Fitness assessments: supports assessments
- REST API layer → Classes and coaches: manages classes (evidence: `owner-app/app/api/class-sessions/route.ts`)
- REST API layer → Billing and collections: supports billing
- Plans and memberships → ERP master provisioning: provisions masters (evidence: `netgainz/net_gainz/accounting/provisioning.py`)
- Billing and collections → Billing rules: uses billing rules (evidence: `netgainz/net_gainz/accounting/billing.py`)
- Billing and collections → ERP master provisioning: provisions counterparties (evidence: `netgainz/net_gainz/accounting/billing.py`)
- Billing and collections → Profit First: uses cash logic (evidence: `netgainz/net_gainz/accounting/billing.py`)
- ERP master provisioning → ERPNext accounting engine: creates ERP masters (evidence: `netgainz/net_gainz/accounting/provisioning.py`)
- REST API layer → Discounts and offers: supports offers
- REST API layer → Expenses: records expenses
- REST API layer → Profit First: shows cash split
- REST API layer → Reports and dashboards: serves reports
- REST API layer → Gym data loading: loads gym data
- REST API layer → Role permissions: checks capabilities
- Gym owner or staff → REST API layer: initiates operations
