# amigosiamoneycard/money-card architecture

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

## Overview

Money Card is a multi-tenant stored-value card platform: organization administrators issue cards and manage staff, branches, products, and inventory; counter staff open card sessions and record purchases or recharges; administrators and portal users can inspect activity, balances, and reports. The web client calls the Express API, whose controllers perform domain operations against Prisma-backed data. The tree also documents analytics, kitchen, subscriptions, customer history, and a Flutter staff app. Source excerpts establish only selected route/controller links; unsampled feature links are omitted rather than inferred.

Main entry points: [`Backend Money Card/src/config/database.ts`](https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/config/database.ts) (Prisma connection), [`Backend Money Card/src/controllers/admin.controller.ts`](https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/controllers/admin.controller.ts) (Organization administration), [`Backend Money Card/src/routes/index.ts`](https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/routes/index.ts) (API routes), [`Backend Money Card/src/middlewares/auth.middleware.ts`](https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/middlewares/auth.middleware.ts) (Authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web client"]
  node_web["Web application<br/>[App.tsx]"]
  node_features["Business screens"]
  node_api_client["API client<br/>[realClient.ts]"]
end

subgraph group_api["API and access"]
  node_server["HTTP server<br/>[server.ts]"]
  node_routes["API routes<br/>[index.ts]"]
  node_auth["Authentication<br/>[auth.middleware.ts]"]
  node_db_config["Prisma connection<br/>[database.ts]"]
  node_database[("Application database")]
  node_audit["Audit logging"]
  node_email["Email delivery<br/>[email.service.ts]"]
end

subgraph group_operations["Card operations"]
  node_product_routes["Products and inventory routes<br/>[products.routes.ts]"]
  node_products["Products and inventory"]
  node_cards["Card management"]
  node_sessions["Sessions and transactions"]
  node_balance_stream["Balance updates"]
  node_kitchen["Kitchen operations"]
end

subgraph group_management["Tenant management"]
  node_admin_routes["Admin endpoints<br/>[admin.routes.ts]"]
  node_admin["Organization administration"]
  node_staff_routes["Staff endpoints<br/>[staff.routes.ts]"]
  node_staff["Staff management"]
  node_subscriptions["Subscriptions"]
end

subgraph group_insight["Activity and reporting"]
  node_analytics["Analytics"]
  node_reports["Reports"]
  node_history["Customer history"]
end

node_user(("Staff and admins"))

node_user -->|"uses"| node_web
node_web -->|"renders"| node_features
node_features -->|"requests"| node_api_client
node_api_client -->|"calls API"| node_server
node_server -->|"mounts"| node_routes
node_routes -->|"mounts"| node_admin_routes
node_admin_routes -->|"protects"| node_auth
node_admin_routes -->|"dispatches"| node_admin
node_routes -->|"mounts"| node_staff_routes
node_staff_routes -->|"protects"| node_auth
node_staff_routes -->|"dispatches"| node_staff
node_routes -->|"mounts"| node_product_routes
node_product_routes -->|"protects"| node_auth
node_product_routes -->|"dispatches"| node_products
node_sessions -->|"publishes updates"| node_balance_stream
node_admin -->|"sends activation"| node_email
node_admin -->|"records activity"| node_audit
node_auth -->|"loads user"| node_db_config
node_admin -->|"queries"| node_db_config
node_staff -->|"queries"| node_db_config
node_products -->|"queries"| node_db_config
node_cards -->|"queries"| node_db_config
node_sessions -->|"queries"| node_db_config
node_db_config -->|"connects"| node_database
node_admin -.->|"manages plans"| node_subscriptions
node_user -.->|"reviews activity"| node_analytics
node_user -.->|"views reports"| node_reports
node_user -.->|"checks history"| node_history
node_user -.->|"handles orders"| node_kitchen

click node_web "https://github.com/amigosiamoneycard/money-card/blob/main/Frontend%20Money%20Card/src/app/App.tsx"
click node_features "https://github.com/amigosiamoneycard/money-card/tree/main/Frontend%20Money%20Card/src/features"
click node_api_client "https://github.com/amigosiamoneycard/money-card/blob/main/Frontend%20Money%20Card/src/services/api/realClient.ts"
click node_server "https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/server.ts"
click node_routes "https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/routes/index.ts"
click node_auth "https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/middlewares/auth.middleware.ts"
click node_admin_routes "https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/routes/admin.routes.ts"
click node_admin "https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/controllers/admin.controller.ts"
click node_staff_routes "https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/routes/staff.routes.ts"
click node_staff "https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/controllers/staff.controller.ts"
click node_product_routes "https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/routes/products.routes.ts"
click node_products "https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/controllers/products.controller.ts"
click node_cards "https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/controllers/cards.controller.ts"
click node_sessions "https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/controllers/sessions.controller.ts"
click node_balance_stream "https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/services/balanceStream.service.ts"
click node_analytics "https://github.com/amigosiamoneycard/money-card/tree/main/Frontend%20Money%20Card/src/features/analytics"
click node_reports "https://github.com/amigosiamoneycard/money-card/tree/main/Frontend%20Money%20Card/src/features/reports"
click node_history "https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/controllers/customer-history.controller.ts"
click node_kitchen "https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/controllers/kitchen.controller.ts"
click node_subscriptions "https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/controllers/subscription.controller.ts"
click node_db_config "https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/config/database.ts"
click node_audit "https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/services/auditLog.service.ts"
click node_email "https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/services/email.service.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,node_features,node_api_client toneBlue
class node_server,node_routes,node_auth,node_db_config,node_database,node_audit,node_email toneAmber
class node_product_routes,node_products,node_cards,node_sessions,node_balance_stream,node_kitchen toneMint
class node_admin_routes,node_admin,node_staff_routes,node_staff,node_subscriptions toneRose
class node_analytics,node_reports,node_history,node_user toneIndigo
```

## Components

### Web client

- [Web application](https://github.com/amigosiamoneycard/money-card/blob/main/Frontend%20Money%20Card/src/app/App.tsx): `Frontend Money Card/src/app/App.tsx`
- [Business screens](https://github.com/amigosiamoneycard/money-card/tree/main/Frontend%20Money%20Card/src/features): `Frontend Money Card/src/features`
- [API client](https://github.com/amigosiamoneycard/money-card/blob/main/Frontend%20Money%20Card/src/services/api/realClient.ts): `Frontend Money Card/src/services/api/realClient.ts`

### API and access

- [HTTP server](https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/server.ts): `Backend Money Card/src/server.ts`
- [API routes](https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/routes/index.ts): `Backend Money Card/src/routes/index.ts`
- [Authentication](https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/middlewares/auth.middleware.ts): `Backend Money Card/src/middlewares/auth.middleware.ts`
- [Prisma connection](https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/config/database.ts): `Backend Money Card/src/config/database.ts`
- **Application database**
- [Audit logging](https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/services/auditLog.service.ts): `Backend Money Card/src/services/auditLog.service.ts`
- [Email delivery](https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/services/email.service.ts): `Backend Money Card/src/services/email.service.ts`

### Card operations

- [Products and inventory routes](https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/routes/products.routes.ts): `Backend Money Card/src/routes/products.routes.ts`
- [Products and inventory](https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/controllers/products.controller.ts): `Backend Money Card/src/controllers/products.controller.ts`
- [Card management](https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/controllers/cards.controller.ts): `Backend Money Card/src/controllers/cards.controller.ts`
- [Sessions and transactions](https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/controllers/sessions.controller.ts): `Backend Money Card/src/controllers/sessions.controller.ts`
- [Balance updates](https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/services/balanceStream.service.ts): `Backend Money Card/src/services/balanceStream.service.ts`
- [Kitchen operations](https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/controllers/kitchen.controller.ts): `Backend Money Card/src/controllers/kitchen.controller.ts`

### Tenant management

- [Admin endpoints](https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/routes/admin.routes.ts): `Backend Money Card/src/routes/admin.routes.ts`
- [Organization administration](https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/controllers/admin.controller.ts): `Backend Money Card/src/controllers/admin.controller.ts`
- [Staff endpoints](https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/routes/staff.routes.ts): `Backend Money Card/src/routes/staff.routes.ts`
- [Staff management](https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/controllers/staff.controller.ts): `Backend Money Card/src/controllers/staff.controller.ts`
- [Subscriptions](https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/controllers/subscription.controller.ts): `Backend Money Card/src/controllers/subscription.controller.ts`

### Activity and reporting

- [Analytics](https://github.com/amigosiamoneycard/money-card/tree/main/Frontend%20Money%20Card/src/features/analytics): `Frontend Money Card/src/features/analytics`
- [Reports](https://github.com/amigosiamoneycard/money-card/tree/main/Frontend%20Money%20Card/src/features/reports): `Frontend Money Card/src/features/reports`
- [Customer history](https://github.com/amigosiamoneycard/money-card/blob/main/Backend%20Money%20Card/src/controllers/customer-history.controller.ts): `Backend Money Card/src/controllers/customer-history.controller.ts`

### Other components

- **Staff and admins**

## Connections

- Staff and admins → Web application: uses
- Web application → Business screens: renders (evidence: `Frontend Money Card/src/app/App.tsx`)
- Business screens → API client: requests (evidence: `Frontend Money Card/src/services/api/realClient.ts`)
- API client → HTTP server: calls API
- HTTP server → API routes: mounts (evidence: `Backend Money Card/src/server.ts`)
- API routes → Admin endpoints: mounts (evidence: `Backend Money Card/src/routes/index.ts`)
- Admin endpoints → Authentication: protects (evidence: `Backend Money Card/src/routes/admin.routes.ts`)
- Admin endpoints → Organization administration: dispatches (evidence: `Backend Money Card/src/routes/admin.routes.ts`)
- API routes → Staff endpoints: mounts (evidence: `Backend Money Card/src/routes/index.ts`)
- Staff endpoints → Authentication: protects (evidence: `Backend Money Card/src/routes/staff.routes.ts`)
- Staff endpoints → Staff management: dispatches (evidence: `Backend Money Card/src/routes/staff.routes.ts`)
- API routes → Products and inventory routes: mounts (evidence: `Backend Money Card/src/routes/index.ts`)
- Products and inventory routes → Authentication: protects (evidence: `Backend Money Card/src/routes/products.routes.ts`)
- Products and inventory routes → Products and inventory: dispatches (evidence: `Backend Money Card/src/routes/products.routes.ts`)
- Sessions and transactions → Balance updates: publishes updates (evidence: `Backend Money Card/src/controllers/sessions.controller.ts`)
- Organization administration → Email delivery: sends activation (evidence: `Backend Money Card/src/controllers/admin.controller.ts`)
- Organization administration → Audit logging: records activity (evidence: `Backend Money Card/src/controllers/admin.controller.ts`)
- Authentication → Prisma connection: loads user (evidence: `Backend Money Card/src/middlewares/auth.middleware.ts`)
- Organization administration → Prisma connection: queries (evidence: `Backend Money Card/src/controllers/admin.controller.ts`)
- Staff management → Prisma connection: queries (evidence: `Backend Money Card/src/controllers/staff.controller.ts`)
- Products and inventory → Prisma connection: queries (evidence: `Backend Money Card/src/controllers/products.controller.ts`)
- Card management → Prisma connection: queries (evidence: `Backend Money Card/src/controllers/cards.controller.ts`)
- Sessions and transactions → Prisma connection: queries (evidence: `Backend Money Card/src/controllers/sessions.controller.ts`)
- Prisma connection → Application database: connects (evidence: `Backend Money Card/src/config/database.ts`)
- Organization administration → Subscriptions: manages plans
- Staff and admins → Analytics: reviews activity
- Staff and admins → Reports: views reports
- Staff and admins → Customer history: checks history
- Staff and admins → Kitchen operations: handles orders
