# mralaaali-lang/gymcore-erp architecture

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

- Interactive diagram: https://gitdiagram.com/mralaaali-lang/gymcore-erp
- Repository: https://github.com/mralaaali-lang/gymcore-erp

## Overview

GymCore ERP is a multi-tenant SaaS for gym and health-club operations, with a web interface, a companion mobile app, an Express API, and PostgreSQL tenant isolation. The principal workflow is a staff or member user authenticating, entering a role-specific experience, and using client API calls to manage gym records; the server routes requests through controllers to persistent data. Major branches include member, subscription, attendance, and staff operations, platform billing and reporting, and notifications. README documents the product capabilities and RLS; some controller and route internals were not sampled, so uncertain links are omitted.

Main entry points: [`server/src/routes/index.ts`](https://github.com/mralaaali-lang/gymcore-erp/blob/main/server/src/routes/index.ts) (API route registry), [`server/src/app.ts`](https://github.com/mralaaali-lang/gymcore-erp/blob/main/server/src/app.ts) (Express application), [`server/src/config/database.ts`](https://github.com/mralaaali-lang/gymcore-erp/blob/main/server/src/config/database.ts) (PostgreSQL), [`src/App.tsx`](https://github.com/mralaaali-lang/gymcore-erp/blob/main/src/App.tsx) (Web application)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client applications"]
  node_web_app["Web application<br/>[App.tsx]"]
  node_web_routes["Role-based routes<br/>[index.tsx]"]
  node_web_context["Session and gym context"]
  node_web_api["Web API client<br/>[api.ts]"]
  node_mobile_app["Mobile application<br/>[App.tsx]"]
  node_mobile_nav["Mobile navigation<br/>[AppNavigator.tsx]"]
  node_mobile_api["Mobile API client<br/>[api.ts]"]
end

subgraph group_server["API and access"]
  node_api_server["Express application<br/>[app.ts]"]
  node_api_routes["API route registry<br/>[index.ts]"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_tenant_access["Tenant isolation<br/>[tenant.ts]"]
end

subgraph group_gym_ops["Gym operations"]
  node_gym_records["Members and staff<br/>[members.ts]"]
  node_subscriptions["Subscriptions<br/>[subscriptions.ts]"]
  node_attendance["Attendance<br/>[attendance.ts]"]
  node_gym_billing["Gym billing"]
end

subgraph group_platform["Platform services"]
  node_platform_admin["Platform administration<br/>[platformAdmin.ts]"]
  node_platform_billing["Platform billing<br/>[billing.service.ts]"]
  node_analytics["Analytics and reports<br/>[analytics.ts]"]
  node_notifications["Notifications"]
end

subgraph group_persistence["Persistence"]
  node_database[("PostgreSQL<br/>[database.ts]")]
  node_tenant_context["Tenant context<br/>[tenantContext.ts]"]
end

node_user(("Gym user"))

node_user -->|"uses"| node_web_app
node_web_app -->|"renders routes"| node_web_routes
node_web_routes -->|"guards by role"| node_web_context
node_web_context -->|"restores session"| node_web_api
node_web_api -->|"HTTP requests"| node_api_server
node_user -->|"uses"| node_mobile_app
node_mobile_app -->|"opens navigation"| node_mobile_nav
node_mobile_nav -.->|"uses services"| node_mobile_api
node_mobile_api -.->|"HTTP requests"| node_api_server
node_api_server -->|"mounts routes"| node_api_routes
node_api_routes -.->|"routes auth"| node_auth
node_api_routes -.->|"routes operations"| node_gym_records
node_api_routes -.->|"routes operations"| node_subscriptions
node_api_routes -.->|"routes operations"| node_attendance
node_api_routes -->|"routes billing"| node_gym_billing
node_api_routes -.->|"routes platform"| node_platform_admin
node_api_routes -.->|"routes billing"| node_platform_billing
node_api_routes -.->|"routes reports"| node_analytics
node_api_routes -.->|"routes notifications"| node_notifications
node_api_server -->|"uses middleware"| node_tenant_access
node_tenant_access -->|"sets context"| node_tenant_context
node_tenant_context -->|"provides client"| node_database
node_gym_billing -->|"queries data"| node_database
node_platform_billing -.->|"persists billing"| node_database

click node_web_app "https://github.com/mralaaali-lang/gymcore-erp/blob/main/src/App.tsx"
click node_web_routes "https://github.com/mralaaali-lang/gymcore-erp/blob/main/src/routes/index.tsx"
click node_web_context "https://github.com/mralaaali-lang/gymcore-erp/blob/main/src/context/GymBrandContext.tsx"
click node_web_api "https://github.com/mralaaali-lang/gymcore-erp/blob/main/src/services/api.ts"
click node_mobile_app "https://github.com/mralaaali-lang/gymcore-erp/blob/main/mobile/App.tsx"
click node_mobile_nav "https://github.com/mralaaali-lang/gymcore-erp/blob/main/mobile/src/navigation/AppNavigator.tsx"
click node_mobile_api "https://github.com/mralaaali-lang/gymcore-erp/blob/main/mobile/src/services/api.ts"
click node_api_server "https://github.com/mralaaali-lang/gymcore-erp/blob/main/server/src/app.ts"
click node_api_routes "https://github.com/mralaaali-lang/gymcore-erp/blob/main/server/src/routes/index.ts"
click node_auth "https://github.com/mralaaali-lang/gymcore-erp/blob/main/server/src/controllers/auth.ts"
click node_tenant_access "https://github.com/mralaaali-lang/gymcore-erp/blob/main/server/src/middleware/tenant.ts"
click node_gym_records "https://github.com/mralaaali-lang/gymcore-erp/blob/main/server/src/controllers/members.ts"
click node_subscriptions "https://github.com/mralaaali-lang/gymcore-erp/blob/main/server/src/controllers/subscriptions.ts"
click node_attendance "https://github.com/mralaaali-lang/gymcore-erp/blob/main/server/src/controllers/attendance.ts"
click node_gym_billing "https://github.com/mralaaali-lang/gymcore-erp/blob/main/server/src/controllers/billing.controller.ts"
click node_platform_admin "https://github.com/mralaaali-lang/gymcore-erp/blob/main/server/src/controllers/platformAdmin.ts"
click node_platform_billing "https://github.com/mralaaali-lang/gymcore-erp/blob/main/server/src/services/billing.service.ts"
click node_analytics "https://github.com/mralaaali-lang/gymcore-erp/blob/main/server/src/controllers/analytics.ts"
click node_notifications "https://github.com/mralaaali-lang/gymcore-erp/blob/main/server/src/controllers/notificationsEngine.ts"
click node_database "https://github.com/mralaaali-lang/gymcore-erp/blob/main/server/src/config/database.ts"
click node_tenant_context "https://github.com/mralaaali-lang/gymcore-erp/blob/main/server/src/config/tenantContext.ts"

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_app,node_web_routes,node_web_context,node_web_api,node_mobile_app,node_mobile_nav,node_mobile_api,node_user toneBlue
class node_api_server,node_api_routes,node_auth,node_tenant_access toneAmber
class node_gym_records,node_subscriptions,node_attendance,node_gym_billing toneMint
class node_platform_admin,node_platform_billing,node_analytics,node_notifications toneRose
class node_database,node_tenant_context toneIndigo
```

## Components

### Client applications

- [Web application](https://github.com/mralaaali-lang/gymcore-erp/blob/main/src/App.tsx): `src/App.tsx`
- [Role-based routes](https://github.com/mralaaali-lang/gymcore-erp/blob/main/src/routes/index.tsx): `src/routes/index.tsx`
- [Session and gym context](https://github.com/mralaaali-lang/gymcore-erp/blob/main/src/context/GymBrandContext.tsx): `src/context/GymBrandContext.tsx`
- [Web API client](https://github.com/mralaaali-lang/gymcore-erp/blob/main/src/services/api.ts): `src/services/api.ts`
- [Mobile application](https://github.com/mralaaali-lang/gymcore-erp/blob/main/mobile/App.tsx): `mobile/App.tsx`
- [Mobile navigation](https://github.com/mralaaali-lang/gymcore-erp/blob/main/mobile/src/navigation/AppNavigator.tsx): `mobile/src/navigation/AppNavigator.tsx`
- [Mobile API client](https://github.com/mralaaali-lang/gymcore-erp/blob/main/mobile/src/services/api.ts): `mobile/src/services/api.ts`

### API and access

- [Express application](https://github.com/mralaaali-lang/gymcore-erp/blob/main/server/src/app.ts): `server/src/app.ts`
- [API route registry](https://github.com/mralaaali-lang/gymcore-erp/blob/main/server/src/routes/index.ts): `server/src/routes/index.ts`
- [Authentication](https://github.com/mralaaali-lang/gymcore-erp/blob/main/server/src/controllers/auth.ts): `server/src/controllers/auth.ts`
- [Tenant isolation](https://github.com/mralaaali-lang/gymcore-erp/blob/main/server/src/middleware/tenant.ts): `server/src/middleware/tenant.ts`

### Gym operations

- [Members and staff](https://github.com/mralaaali-lang/gymcore-erp/blob/main/server/src/controllers/members.ts): `server/src/controllers/members.ts`
- [Subscriptions](https://github.com/mralaaali-lang/gymcore-erp/blob/main/server/src/controllers/subscriptions.ts): `server/src/controllers/subscriptions.ts`
- [Attendance](https://github.com/mralaaali-lang/gymcore-erp/blob/main/server/src/controllers/attendance.ts): `server/src/controllers/attendance.ts`
- [Gym billing](https://github.com/mralaaali-lang/gymcore-erp/blob/main/server/src/controllers/billing.controller.ts): `server/src/controllers/billing.controller.ts`

### Platform services

- [Platform administration](https://github.com/mralaaali-lang/gymcore-erp/blob/main/server/src/controllers/platformAdmin.ts): `server/src/controllers/platformAdmin.ts`
- [Platform billing](https://github.com/mralaaali-lang/gymcore-erp/blob/main/server/src/services/billing.service.ts): `server/src/services/billing.service.ts`
- [Analytics and reports](https://github.com/mralaaali-lang/gymcore-erp/blob/main/server/src/controllers/analytics.ts): `server/src/controllers/analytics.ts`
- [Notifications](https://github.com/mralaaali-lang/gymcore-erp/blob/main/server/src/controllers/notificationsEngine.ts): `server/src/controllers/notificationsEngine.ts`

### Persistence

- [PostgreSQL](https://github.com/mralaaali-lang/gymcore-erp/blob/main/server/src/config/database.ts): `server/src/config/database.ts`
- [Tenant context](https://github.com/mralaaali-lang/gymcore-erp/blob/main/server/src/config/tenantContext.ts): `server/src/config/tenantContext.ts`

### Other components

- **Gym user**

## Connections

- Gym user → Web application: uses
- Web application → Role-based routes: renders routes (evidence: `src/App.tsx`)
- Role-based routes → Session and gym context: guards by role (evidence: `src/routes/index.tsx`)
- Session and gym context → Web API client: restores session (evidence: `src/context/GymBrandContext.tsx`)
- Web API client → Express application: HTTP requests
- Gym user → Mobile application: uses
- Mobile application → Mobile navigation: opens navigation (evidence: `mobile/App.tsx`)
- Mobile navigation → Mobile API client: uses services
- Mobile API client → Express application: HTTP requests
- Express application → API route registry: mounts routes (evidence: `server/src/app.ts`)
- API route registry → Authentication: routes auth
- API route registry → Members and staff: routes operations
- API route registry → Subscriptions: routes operations
- API route registry → Attendance: routes operations
- API route registry → Gym billing: routes billing
- API route registry → Platform administration: routes platform
- API route registry → Platform billing: routes billing
- API route registry → Analytics and reports: routes reports
- API route registry → Notifications: routes notifications
- Express application → Tenant isolation: uses middleware (evidence: `server/src/app.ts`)
- Tenant isolation → Tenant context: sets context
- Tenant context → PostgreSQL: provides client (evidence: `server/src/config/database.ts`)
- Gym billing → PostgreSQL: queries data (evidence: `server/src/controllers/billing.controller.ts`)
- Platform billing → PostgreSQL: persists billing
