# jordi7-7/pos-store architecture

> Architecture diagram of the GitHub repository jordi7-7/pos-store, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jordi7-7/pos-store
- Repository: https://github.com/jordi7-7/pos-store

## Overview

This is a multi-tenant retail POS backend: users authenticate, select a branch and cash register, look up products, and run sales against cash sessions; the API also manages inventory, purchasing, customers, staff, media, and reports. Controllers dispatch commands and queries through Nest CQRS, while some controllers use TypeORM directly. The tree documents these feature areas, but excerpts show only selected controller and handler wiring; unsampled connections are not inferred.

Main entry points: [`src/config/data-source.ts`](https://github.com/jordi7-7/pos-store/blob/main/src/config/data-source.ts) (Relational database), [`src/modules/sales/infrastructure/controllers/sales.controller.ts`](https://github.com/jordi7-7/pos-store/blob/main/src/modules/sales/infrastructure/controllers/sales.controller.ts) (Sales and cash), [`src/modules/auth/infrastructure/controllers/auth.controller.ts`](https://github.com/jordi7-7/pos-store/blob/main/src/modules/auth/infrastructure/controllers/auth.controller.ts) (Authentication), [`src/modules/products/infrastructure/controllers/products.controller.ts`](https://github.com/jordi7-7/pos-store/blob/main/src/modules/products/infrastructure/controllers/products.controller.ts) (Products and stock)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["API and access"]
  node_auth["Authentication<br/>[auth.controller.ts]"]
  node_users["Staff accounts"]
  node_roles["Roles and permissions"]
end

subgraph group_catalog["Catalog and inventory"]
  node_products["Products and stock"]
  node_product_handlers["Catalog handlers"]
end

subgraph group_commerce["POS and purchasing"]
  node_sales["Sales and cash"]
  node_sales_handlers["Sales handlers"]
  node_purchases["Purchasing"]
  node_purchase_handlers["Purchase handlers"]
end

subgraph group_operations["Store operations"]
  node_branches["Branches"]
  node_customers["Customers"]
  node_reports["Reports"]
  node_tenants["Tenant settings"]
  node_media["Product media"]
end

subgraph group_platform["Shared infrastructure"]
  node_s3[("Object storage")]
  node_typeorm[("Relational database<br/>[data-source.ts]")]
  node_redis[("Redis service<br/>[redis.service.ts]")]
  node_tenant_context["Tenant context"]
end

node_client(("POS client"))

node_client -->|"authenticates"| node_auth
node_client -->|"manages catalog"| node_products
node_client -->|"runs POS"| node_sales
node_client -->|"records purchases"| node_purchases
node_client -->|"manages customers"| node_customers
node_client -->|"requests reports"| node_reports
node_auth -->|"reads profile"| node_typeorm
node_auth -->|"authenticates staff"| node_users
node_users -->|"reads and writes"| node_typeorm
node_roles -->|"reads and writes"| node_typeorm
node_products -->|"dispatches commands and queries"| node_product_handlers
node_sales -->|"dispatches commands and queries"| node_sales_handlers
node_sales -->|"queries records"| node_typeorm
node_purchases -->|"dispatches commands and queries"| node_purchase_handlers
node_customers -->|"dispatches via CQRS"| node_typeorm
node_reports -->|"queries reports"| node_typeorm
node_branches -->|"queries branches"| node_typeorm
node_tenants -->|"manages tenant data"| node_typeorm
node_media -->|"stores image records"| node_typeorm
node_media -->|"uploads and deletes files"| node_s3
node_tenant_context -->|"sets tenant context"| node_client
node_sales_handlers -->|"stores session data"| node_typeorm
node_products -.->|"supplies POS lookup"| node_sales
node_redis -.->|"support integration"| node_typeorm

click node_auth "https://github.com/jordi7-7/pos-store/blob/main/src/modules/auth/infrastructure/controllers/auth.controller.ts"
click node_users "https://github.com/jordi7-7/pos-store/blob/main/src/modules/users/infrastructure/controllers/users.controller.ts"
click node_roles "https://github.com/jordi7-7/pos-store/blob/main/src/modules/roles/infrastructure/controllers/roles.controller.ts"
click node_products "https://github.com/jordi7-7/pos-store/blob/main/src/modules/products/infrastructure/controllers/products.controller.ts"
click node_product_handlers "https://github.com/jordi7-7/pos-store/tree/main/src/modules/products/application"
click node_branches "https://github.com/jordi7-7/pos-store/blob/main/src/modules/branches/infrastructure/controllers/branches.controller.ts"
click node_sales "https://github.com/jordi7-7/pos-store/blob/main/src/modules/sales/infrastructure/controllers/sales.controller.ts"
click node_sales_handlers "https://github.com/jordi7-7/pos-store/tree/main/src/modules/sales/application"
click node_purchases "https://github.com/jordi7-7/pos-store/blob/main/src/modules/purchases/infrastructure/controllers/purchases.controller.ts"
click node_purchase_handlers "https://github.com/jordi7-7/pos-store/tree/main/src/modules/purchases/application"
click node_customers "https://github.com/jordi7-7/pos-store/blob/main/src/modules/customers/infrastructure/controllers/customers.controller.ts"
click node_reports "https://github.com/jordi7-7/pos-store/blob/main/src/modules/reports/infrastructure/controllers/reports.controller.ts"
click node_tenants "https://github.com/jordi7-7/pos-store/blob/main/src/modules/tenants/infrastructure/controllers/tenants.controller.ts"
click node_media "https://github.com/jordi7-7/pos-store/blob/main/src/modules/media/infrastructure/controllers/media.controller.ts"
click node_typeorm "https://github.com/jordi7-7/pos-store/blob/main/src/config/data-source.ts"
click node_redis "https://github.com/jordi7-7/pos-store/blob/main/src/common/redis/redis.service.ts"
click node_tenant_context "https://github.com/jordi7-7/pos-store/blob/main/src/common/tenant/tenant.middleware.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_auth,node_users,node_roles,node_client toneBlue
class node_products,node_product_handlers toneAmber
class node_sales,node_sales_handlers,node_purchases,node_purchase_handlers toneMint
class node_branches,node_customers,node_reports,node_tenants,node_media toneRose
class node_s3,node_typeorm,node_redis,node_tenant_context toneIndigo
```

## Components

### API and access

- [Authentication](https://github.com/jordi7-7/pos-store/blob/main/src/modules/auth/infrastructure/controllers/auth.controller.ts): `src/modules/auth/infrastructure/controllers/auth.controller.ts`
- [Staff accounts](https://github.com/jordi7-7/pos-store/blob/main/src/modules/users/infrastructure/controllers/users.controller.ts): `src/modules/users/infrastructure/controllers/users.controller.ts`
- [Roles and permissions](https://github.com/jordi7-7/pos-store/blob/main/src/modules/roles/infrastructure/controllers/roles.controller.ts): `src/modules/roles/infrastructure/controllers/roles.controller.ts`

### Catalog and inventory

- [Products and stock](https://github.com/jordi7-7/pos-store/blob/main/src/modules/products/infrastructure/controllers/products.controller.ts): `src/modules/products/infrastructure/controllers/products.controller.ts`
- [Catalog handlers](https://github.com/jordi7-7/pos-store/tree/main/src/modules/products/application): `src/modules/products/application`

### POS and purchasing

- [Sales and cash](https://github.com/jordi7-7/pos-store/blob/main/src/modules/sales/infrastructure/controllers/sales.controller.ts): `src/modules/sales/infrastructure/controllers/sales.controller.ts`
- [Sales handlers](https://github.com/jordi7-7/pos-store/tree/main/src/modules/sales/application): `src/modules/sales/application`
- [Purchasing](https://github.com/jordi7-7/pos-store/blob/main/src/modules/purchases/infrastructure/controllers/purchases.controller.ts): `src/modules/purchases/infrastructure/controllers/purchases.controller.ts`
- [Purchase handlers](https://github.com/jordi7-7/pos-store/tree/main/src/modules/purchases/application): `src/modules/purchases/application`

### Store operations

- [Branches](https://github.com/jordi7-7/pos-store/blob/main/src/modules/branches/infrastructure/controllers/branches.controller.ts): `src/modules/branches/infrastructure/controllers/branches.controller.ts`
- [Customers](https://github.com/jordi7-7/pos-store/blob/main/src/modules/customers/infrastructure/controllers/customers.controller.ts): `src/modules/customers/infrastructure/controllers/customers.controller.ts`
- [Reports](https://github.com/jordi7-7/pos-store/blob/main/src/modules/reports/infrastructure/controllers/reports.controller.ts): `src/modules/reports/infrastructure/controllers/reports.controller.ts`
- [Tenant settings](https://github.com/jordi7-7/pos-store/blob/main/src/modules/tenants/infrastructure/controllers/tenants.controller.ts): `src/modules/tenants/infrastructure/controllers/tenants.controller.ts`
- [Product media](https://github.com/jordi7-7/pos-store/blob/main/src/modules/media/infrastructure/controllers/media.controller.ts): `src/modules/media/infrastructure/controllers/media.controller.ts`

### Shared infrastructure

- **Object storage**
- [Relational database](https://github.com/jordi7-7/pos-store/blob/main/src/config/data-source.ts): `src/config/data-source.ts`
- [Redis service](https://github.com/jordi7-7/pos-store/blob/main/src/common/redis/redis.service.ts): `src/common/redis/redis.service.ts`
- [Tenant context](https://github.com/jordi7-7/pos-store/blob/main/src/common/tenant/tenant.middleware.ts): `src/common/tenant/tenant.middleware.ts`

### Other components

- **POS client**

## Connections

- POS client → Authentication: authenticates
- POS client → Products and stock: manages catalog
- POS client → Sales and cash: runs POS
- POS client → Purchasing: records purchases
- POS client → Customers: manages customers
- POS client → Reports: requests reports
- Authentication → Relational database: reads profile
- Authentication → Staff accounts: authenticates staff
- Staff accounts → Relational database: reads and writes
- Roles and permissions → Relational database: reads and writes
- Products and stock → Catalog handlers: dispatches commands and queries
- Sales and cash → Sales handlers: dispatches commands and queries
- Sales and cash → Relational database: queries records
- Purchasing → Purchase handlers: dispatches commands and queries
- Customers → Relational database: dispatches via CQRS
- Reports → Relational database: queries reports
- Branches → Relational database: queries branches
- Tenant settings → Relational database: manages tenant data
- Product media → Relational database: stores image records
- Product media → Object storage: uploads and deletes files
- Tenant context → POS client: sets tenant context
- Sales handlers → Relational database: stores session data
- Products and stock → Sales and cash: supplies POS lookup
- Redis service → Relational database: support integration
