# oscarbz-011/joapycore architecture

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

- Interactive diagram: https://gitdiagram.com/oscarbz-011/joapycore
- Repository: https://github.com/oscarbz-011/joapycore

## Overview

This is a multi-tenant business management application: a Next.js dashboard and a NestJS API for authentication, tenant and user administration, inventory, procurement, sales, and billing. The principal workflow is signing in or registering, receiving tenant-scoped credentials, then using dashboard operations subject to permissions and enabled modules. The backend is organized around controllers and services, with repositories and Prisma providing a persistence layer. The README is empty; connections for unsampled domain modules are therefore limited to documented module wiring or omitted where call sites were not shown.

Main entry points: [`BACK/src/auth/auth.service.ts`](https://github.com/oscarbz-011/joapycore/blob/main/BACK/src/auth/auth.service.ts) (Authentication service), [`front/lib/auth-context.tsx`](https://github.com/oscarbz-011/joapycore/blob/main/front/lib/auth-context.tsx) (Auth context), [`front/lib/api/client.ts`](https://github.com/oscarbz-011/joapycore/blob/main/front/lib/api/client.ts) (HTTP client), [`front/app/(dashboard)/dashboard`](https://github.com/oscarbz-011/joapycore/tree/main/front/app/(dashboard)/dashboard) (Dashboard and settings)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_frontend["Web dashboard"]
  node_auth_pages["Login and registration"]
  node_dashboard["Dashboard and settings"]
  node_auth_context["Auth context<br/>[auth-context.tsx]"]
  node_auth_api["Auth API client<br/>[auth.ts]"]
  node_api_client["HTTP client<br/>[client.ts]"]
  node_token_store["Token store<br/>[token-store.ts]"]
  node_users_api["Users API client<br/>[users.ts]"]
  node_roles_api["Roles API client<br/>[roles.ts]"]
end

subgraph group_identity["Identity and access"]
  node_auth_controller["Authentication routes<br/>[auth.controller.ts]"]
  node_auth_service["Authentication service<br/>[auth.service.ts]"]
  node_access_controls["JWT and permission controls"]
  node_user_management["Users and roles"]
end

subgraph group_tenant["Tenant administration"]
  node_tenant_management["Tenant and module settings"]
end

subgraph group_operations["Business operations"]
  node_inventory["Inventory"]
  node_procurement["Procurement"]
  node_sales["Sales"]
  node_billing["Billing"]
end

subgraph group_persistence["Persistence"]
  node_prisma["Prisma service<br/>[prisma.service.ts]"]
  node_user_repository["User repository"]
  node_refresh_repository["Refresh-token repository"]
end

node_operator(("Operator"))

node_operator -.->|"starts session"| node_auth_pages
node_auth_pages -->|"uses context"| node_auth_context
node_dashboard -->|"uses context"| node_auth_context
node_auth_context -->|"calls"| node_auth_api
node_auth_context -->|"stores tokens"| node_token_store
node_auth_api -->|"uses"| node_api_client
node_api_client -->|"reads and updates"| node_token_store
node_users_api -->|"uses"| node_api_client
node_roles_api -->|"uses"| node_api_client
node_dashboard -->|"calls"| node_users_api
node_dashboard -->|"calls"| node_roles_api
node_auth_controller -->|"delegates to"| node_auth_service
node_auth_service -->|"queries users"| node_user_repository
node_auth_service -->|"manages refresh tokens"| node_refresh_repository
node_auth_service -->|"runs transaction"| node_prisma
node_user_repository -->|"queries"| node_prisma
node_user_management -->|"uses"| node_user_repository
node_tenant_management -->|"provides tenant data"| node_auth_service
node_inventory -.->|"serves inventory routes"| node_inventory
node_procurement -.->|"serves purchasing routes"| node_procurement
node_billing -.->|"serves invoices"| node_billing

click node_auth_pages "https://github.com/oscarbz-011/joapycore/tree/main/front/app/(auth)"
click node_dashboard "https://github.com/oscarbz-011/joapycore/tree/main/front/app/(dashboard)/dashboard"
click node_auth_context "https://github.com/oscarbz-011/joapycore/blob/main/front/lib/auth-context.tsx"
click node_auth_api "https://github.com/oscarbz-011/joapycore/blob/main/front/lib/api/auth.ts"
click node_api_client "https://github.com/oscarbz-011/joapycore/blob/main/front/lib/api/client.ts"
click node_token_store "https://github.com/oscarbz-011/joapycore/blob/main/front/lib/token-store.ts"
click node_users_api "https://github.com/oscarbz-011/joapycore/blob/main/front/lib/api/users.ts"
click node_roles_api "https://github.com/oscarbz-011/joapycore/blob/main/front/lib/api/roles.ts"
click node_auth_controller "https://github.com/oscarbz-011/joapycore/blob/main/BACK/src/auth/auth.controller.ts"
click node_auth_service "https://github.com/oscarbz-011/joapycore/blob/main/BACK/src/auth/auth.service.ts"
click node_access_controls "https://github.com/oscarbz-011/joapycore/tree/main/BACK/src/common/guards"
click node_user_management "https://github.com/oscarbz-011/joapycore/tree/main/BACK/src/users"
click node_tenant_management "https://github.com/oscarbz-011/joapycore/tree/main/BACK/src/tenants"
click node_inventory "https://github.com/oscarbz-011/joapycore/tree/main/BACK/src/modules/inventory"
click node_procurement "https://github.com/oscarbz-011/joapycore/tree/main/BACK/src/modules/procurement"
click node_sales "https://github.com/oscarbz-011/joapycore/tree/main/BACK/src/modules/sales"
click node_billing "https://github.com/oscarbz-011/joapycore/tree/main/BACK/src/modules/billing"
click node_prisma "https://github.com/oscarbz-011/joapycore/blob/main/BACK/src/prisma/prisma.service.ts"
click node_user_repository "https://github.com/oscarbz-011/joapycore/blob/main/BACK/src/users/repositories/users.repository.ts"
click node_refresh_repository "https://github.com/oscarbz-011/joapycore/blob/main/BACK/src/auth/repositories/refresh-tokens.repository.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_pages,node_dashboard,node_auth_context,node_auth_api,node_api_client,node_token_store,node_users_api,node_roles_api toneBlue
class node_auth_controller,node_auth_service,node_access_controls,node_user_management toneAmber
class node_tenant_management toneMint
class node_inventory,node_procurement,node_sales,node_billing toneRose
class node_prisma,node_user_repository,node_refresh_repository,node_operator toneIndigo
```

## Components

### Web dashboard

- [Login and registration](https://github.com/oscarbz-011/joapycore/tree/main/front/app/(auth)): `front/app/(auth)`
- [Dashboard and settings](https://github.com/oscarbz-011/joapycore/tree/main/front/app/(dashboard)/dashboard): `front/app/(dashboard)/dashboard`
- [Auth context](https://github.com/oscarbz-011/joapycore/blob/main/front/lib/auth-context.tsx): `front/lib/auth-context.tsx`
- [Auth API client](https://github.com/oscarbz-011/joapycore/blob/main/front/lib/api/auth.ts): `front/lib/api/auth.ts`
- [HTTP client](https://github.com/oscarbz-011/joapycore/blob/main/front/lib/api/client.ts): `front/lib/api/client.ts`
- [Token store](https://github.com/oscarbz-011/joapycore/blob/main/front/lib/token-store.ts): `front/lib/token-store.ts`
- [Users API client](https://github.com/oscarbz-011/joapycore/blob/main/front/lib/api/users.ts): `front/lib/api/users.ts`
- [Roles API client](https://github.com/oscarbz-011/joapycore/blob/main/front/lib/api/roles.ts): `front/lib/api/roles.ts`

### Identity and access

- [Authentication routes](https://github.com/oscarbz-011/joapycore/blob/main/BACK/src/auth/auth.controller.ts): `BACK/src/auth/auth.controller.ts`
- [Authentication service](https://github.com/oscarbz-011/joapycore/blob/main/BACK/src/auth/auth.service.ts): `BACK/src/auth/auth.service.ts`
- [JWT and permission controls](https://github.com/oscarbz-011/joapycore/tree/main/BACK/src/common/guards): `BACK/src/common/guards`
- [Users and roles](https://github.com/oscarbz-011/joapycore/tree/main/BACK/src/users): `BACK/src/users`

### Tenant administration

- [Tenant and module settings](https://github.com/oscarbz-011/joapycore/tree/main/BACK/src/tenants): `BACK/src/tenants`

### Business operations

- [Inventory](https://github.com/oscarbz-011/joapycore/tree/main/BACK/src/modules/inventory): `BACK/src/modules/inventory`
- [Procurement](https://github.com/oscarbz-011/joapycore/tree/main/BACK/src/modules/procurement): `BACK/src/modules/procurement`
- [Sales](https://github.com/oscarbz-011/joapycore/tree/main/BACK/src/modules/sales): `BACK/src/modules/sales`
- [Billing](https://github.com/oscarbz-011/joapycore/tree/main/BACK/src/modules/billing): `BACK/src/modules/billing`

### Persistence

- [Prisma service](https://github.com/oscarbz-011/joapycore/blob/main/BACK/src/prisma/prisma.service.ts): `BACK/src/prisma/prisma.service.ts`
- [User repository](https://github.com/oscarbz-011/joapycore/blob/main/BACK/src/users/repositories/users.repository.ts): `BACK/src/users/repositories/users.repository.ts`
- [Refresh-token repository](https://github.com/oscarbz-011/joapycore/blob/main/BACK/src/auth/repositories/refresh-tokens.repository.ts): `BACK/src/auth/repositories/refresh-tokens.repository.ts`

### Other components

- **Operator**

## Connections

- Operator → Login and registration: starts session
- Login and registration → Auth context: uses context (evidence: `front/app/(auth)/login/page.tsx`)
- Dashboard and settings → Auth context: uses context (evidence: `front/app/(dashboard)/dashboard/page.tsx`)
- Auth context → Auth API client: calls (evidence: `front/lib/auth-context.tsx`)
- Auth context → Token store: stores tokens (evidence: `front/lib/auth-context.tsx`)
- Auth API client → HTTP client: uses (evidence: `front/lib/api/auth.ts`)
- HTTP client → Token store: reads and updates (evidence: `front/lib/api/client.ts`)
- Users API client → HTTP client: uses (evidence: `front/lib/api/users.ts`)
- Roles API client → HTTP client: uses
- Dashboard and settings → Users API client: calls (evidence: `front/app/(dashboard)/dashboard/settings/users/page.tsx`)
- Dashboard and settings → Roles API client: calls (evidence: `front/app/(dashboard)/dashboard/settings/roles/page.tsx`)
- Authentication routes → Authentication service: delegates to (evidence: `BACK/src/auth/auth.controller.ts`)
- Authentication service → User repository: queries users (evidence: `BACK/src/auth/auth.service.ts`)
- Authentication service → Refresh-token repository: manages refresh tokens (evidence: `BACK/src/auth/auth.service.ts`)
- Authentication service → Prisma service: runs transaction (evidence: `BACK/src/auth/auth.service.ts`)
- User repository → Prisma service: queries (evidence: `BACK/src/users/repositories/users.repository.ts`)
- Users and roles → User repository: uses (evidence: `BACK/src/users/services/users.service.ts`)
- Tenant and module settings → Authentication service: provides tenant data (evidence: `BACK/src/auth/auth.service.ts`)
- Inventory → Inventory: serves inventory routes
- Procurement → Procurement: serves purchasing routes
- Billing → Billing: serves invoices
