You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 9673b14
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: AGENTS.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,11 +10,11 @@ Track proposals and tasks as `Proposed`, `Approved`, `Implemented`, or `Verified
10
10
11
11
Every implementation task must specify its objective, scope, technical constraints, dependencies, acceptance criteria, validation requirements, and explicit out-of-scope items.
12
12
13
-
Claude provides an implementation report and validation evidence. Codex inspects the Git diff against each acceptance criterion, identifies bugs and architectural violations, reviews test execution evidence, cites files and lines, and recommends approval or rework. Report passing tests only with execution evidence. Follow the [architecture workflow](docs/architecture-workflow.md).
13
+
Claude provides an implementation report and validation evidence. Codex inspects the Git diff against each acceptance criterion, identifies bugs and architectural violations, reviews test execution evidence, cites files and lines, and recommends approval or rework. Report passing tests only with execution evidence. Follow the [architecture workflow](docs/project/architecture-workflow.md).
14
14
15
15
## Project Structure and Style
16
16
17
-
NestJS domains under `src/` group controllers, services, DTOs, and unit tests. Update Swagger decorators and the corresponding guide in `docs/` whenever API behavior changes. Read `docs/database.md` before changing the shared schema in `prisma/control/` or the per-organization schema in `prisma/tenant/`. Add migrations and preserve applied ones.
17
+
NestJS domains under `src/` group controllers, services, DTOs, and unit tests. Update Swagger decorators and the corresponding guide in `docs/modules/` whenever API behavior changes. Read `docs/architecture/database.md` before changing the shared schema in `prisma/control/` or the per-organization schema in `prisma/tenant/`. Add migrations and preserve applied ones.
18
18
19
19
Write code and documentation in English. Reserve comments for complex, non-obvious logic. Use two spaces, single quotes, trailing commas, and `.js` extensions for relative imports. Use PascalCase classes and kebab-case filenames such as `stock-requests.service.ts`.
Copy file name to clipboardExpand all lines: CLAUDE.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,13 +2,13 @@
2
2
3
3
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4
4
5
-
Pango core: the NestJS backend of a multi-tenant inventory SaaS for Colombian SMEs (pymes), with demand forecasting (a separate Python AI service lives outside this repo). The product catalog API is in `docs/catalog.md`; warehouses in `docs/warehouses.md`; inventory movements in `docs/movements.md`; stock queries and lots in `docs/stock.md`; replenishment parameters and stock alerts in `docs/replenishment.md`; departments and internal stock requests in `docs/stock-requests.md`; the demand history in `docs/demand.md`; demand forecasting (runs through the Python service) in `docs/forecasting.md`; the header's cross-module search in `docs/search.md`; the dashboard figures in `docs/dashboard.md`. The database design — conventions, tables, constraints, business rules, planned views, provisioning and the schema-change workflow — is in `docs/database.md`; read it before touching the data model.
5
+
Pango core: the NestJS backend of a multi-tenant inventory SaaS for Colombian SMEs (pymes), with demand forecasting (a separate Python AI service lives outside this repo). The product catalog API is in `docs/modules/catalog.md`; warehouses in `docs/modules/warehouses.md`; inventory movements in `docs/modules/movements.md`; stock queries and lots in `docs/modules/stock.md`; replenishment parameters and stock alerts in `docs/modules/replenishment.md`; departments and internal stock requests in `docs/modules/stock-requests.md`; the demand history in `docs/modules/demand.md`; demand forecasting (runs through the Python service) in `docs/modules/forecasting.md`; the header's cross-module search in `docs/modules/search.md`; the dashboard figures in `docs/modules/dashboard.md`. The database design — conventions, tables, constraints, business rules, planned views, provisioning and the schema-change workflow — is in `docs/architecture/database.md`; read it before touching the data model.
6
6
7
7
## Roles
8
8
9
-
Claude is the senior developer; Codex is the principal software architect (its rules are in `AGENTS.md`); the human user has final approval. The full workflow is in `docs/architecture-workflow.md`.
9
+
Claude is the senior developer; Codex is the principal software architect (its rules are in `AGENTS.md`); the human user has final approval. The full workflow is in `docs/project/architecture-workflow.md`.
10
10
11
-
- Claude implements the agreed scope: source, tests, migrations, dependencies, Swagger and the domain guide in `docs/` for any API change. Claude does not write or change ADRs, task definitions or their status; architecture concerns go to the user as a proposal.
11
+
- Claude implements the agreed scope: source, tests, migrations, dependencies, Swagger and the domain guide in `docs/modules/` for any API change. Claude does not write or change ADRs, task definitions or their status; architecture concerns go to the user as a proposal.
12
12
- Work from a task that states objective, scope, constraints, dependencies, acceptance criteria, validation requirements and out-of-scope items. If the task is missing, incomplete or conflicts with the code, ask before building; don't widen the scope on your own.
13
13
- Finish with an implementation report: what changed (files), how each acceptance criterion is met, and the validation commands run with their results. Only report checks as passing when they were actually run; mark the rest as not run.
14
14
- Treat Codex's review findings as input to verify against the code, not as orders: fix the confirmed ones, and explain to the user any you disagree with.
@@ -57,7 +57,7 @@ Prisma CLI calls always need `--config prisma/control.config.ts` or `--config pr
57
57
58
58
### Auth
59
59
60
-
Details in `docs/auth.md`. Own auth (no Cognito): Argon2id passwords in `public.accounts`, HS256 access JWT (`sub` = account, `org` = organization) and rotating opaque refresh tokens (`public.refresh_tokens`, SHA-256 only). Both travel only as HttpOnly cookies `pango_access_<subdomain>` / `pango_refresh_<subdomain>` (`SameSite=Lax`, `Domain=COOKIE_DOMAIN`; `src/auth/session-cookies.ts`), never in a body; Bearer is accepted as a fallback for non-browser clients. `CsrfGuard` (global, before `AuthGuard`) rejects unsafe requests with a session cookie from an origin outside `APP_BASE_DOMAIN`, so GET routes must never change state. Only owners sign up (`POST /auth/signup` creates account + organization and emails a confirmation link; login is blocked until `accounts.email_verified_at` is set); login takes two steps: the password opens a challenge (`public.login_challenges`, token in the HttpOnly cookie `pango_login_<subdomain>`) and a six-digit code emailed to the account completes it (`POST /auth/login/verify`, `src/auth/login-code.service.ts`; `LOGIN_EMAIL_CODE_ENABLED=false` skips it for local development); after the code the browser is trusted for a while (`src/auth/trusted-device.service.ts`, signed cookie `pango_device_<subdomain>`, no table), so the next logins ask for the password only; employees join through invitations (`public.organization_invitations`, emailed with Resend), which also verify their email. The organization comes from the `X-Tenant` header or the host's subdomain of `APP_BASE_DOMAIN`. `AuthGuard` is global (`@Public()` opts out): it checks the token's organization equals the request's, reloads membership + tenant user on every request, and puts the session on `request.auth` (`@CurrentAuth()`); `@RequirePermissions(...)` passes when any role assignment grants the permission; `ORGANIZATION`-scope permissions then apply everywhere, while handlers narrow `WAREHOUSE`-scope ones (e.g. `user.manage`) with `warehousesWithPermission` / `permissionsInWarehouse` (`src/auth/auth-context.ts`). Only the Owner (system role) has assignments with no warehouse; granting roles goes through `assertCanAssign` (`src/roles/role-policy.ts`). Errors carry a stable `code` (`src/auth/auth-errors.ts`).
60
+
Details in `docs/modules/auth.md`. Own auth (no Cognito): Argon2id passwords in `public.accounts`, HS256 access JWT (`sub` = account, `org` = organization) and rotating opaque refresh tokens (`public.refresh_tokens`, SHA-256 only). Both travel only as HttpOnly cookies `pango_access_<subdomain>` / `pango_refresh_<subdomain>` (`SameSite=Lax`, `Domain=COOKIE_DOMAIN`; `src/auth/session-cookies.ts`), never in a body; Bearer is accepted as a fallback for non-browser clients. `CsrfGuard` (global, before `AuthGuard`) rejects unsafe requests with a session cookie from an origin outside `APP_BASE_DOMAIN`, so GET routes must never change state. Only owners sign up (`POST /auth/signup` creates account + organization and emails a confirmation link; login is blocked until `accounts.email_verified_at` is set); login takes two steps: the password opens a challenge (`public.login_challenges`, token in the HttpOnly cookie `pango_login_<subdomain>`) and a six-digit code emailed to the account completes it (`POST /auth/login/verify`, `src/auth/login-code.service.ts`; `LOGIN_EMAIL_CODE_ENABLED=false` skips it for local development); after the code the browser is trusted for a while (`src/auth/trusted-device.service.ts`, signed cookie `pango_device_<subdomain>`, no table), so the next logins ask for the password only; employees join through invitations (`public.organization_invitations`, emailed with Resend), which also verify their email. The organization comes from the `X-Tenant` header or the host's subdomain of `APP_BASE_DOMAIN`. `AuthGuard` is global (`@Public()` opts out): it checks the token's organization equals the request's, reloads membership + tenant user on every request, and puts the session on `request.auth` (`@CurrentAuth()`); `@RequirePermissions(...)` passes when any role assignment grants the permission; `ORGANIZATION`-scope permissions then apply everywhere, while handlers narrow `WAREHOUSE`-scope ones (e.g. `user.manage`) with `warehousesWithPermission` / `permissionsInWarehouse` (`src/auth/auth-context.ts`). Only the Owner (system role) has assignments with no warehouse; granting roles goes through `assertCanAssign` (`src/roles/role-policy.ts`). Errors carry a stable `code` (`src/auth/auth-errors.ts`).
61
61
62
62
### API documentation (Swagger)
63
63
@@ -69,11 +69,11 @@ Details in `docs/auth.md`. Own auth (no Cognito): Argon2id passwords in `public.
69
69
70
70
### Migrations
71
71
72
-
- Migrations are generated without a shadow DB with `prisma migrate diff --from-config-datasource --to-schema <schema.prisma> --script` (tenant: set `TENANT_SCHEMA=tenant_demo`), then saved as `<yyyymmddhhmmss>_<name>/migration.sql`. Full steps in `docs/database.md`.
72
+
- Migrations are generated without a shadow DB with `prisma migrate diff --from-config-datasource --to-schema <schema.prisma> --script` (tenant: set `TENANT_SCHEMA=tenant_demo`), then saved as `<yyyymmddhhmmss>_<name>/migration.sql`. Full steps in `docs/architecture/database.md`.
73
73
- The tenant `init` migration ends with hand-written SQL (CHECK constraints, partial unique indexes, `NULLS NOT DISTINCT` indexes) that Prisma can't express. The tenant diff always emits `DROP INDEX` for the two `NULLS NOT DISTINCT` indexes — delete those lines from new migrations.
74
74
- Tenant base data (permissions, base movement types, `EA` unit, `Owner` role, settings row) lives in the `base_data` migration, not a seed, so new tenants are born with it. Any migration that adds a permission must also grant it to `Owner`.
75
75
- Don't edit migrations that are already applied; add a new one.
76
-
- Derived values are computed in views (planned, see `docs/database.md`), not stored — except `products.average_cost`. `stock_balances` is a materialized balance that only changes when movements are confirmed; nothing is deleted, mistakes are voided with a reversing movement (`movements.reversal_of_id`).
76
+
- Derived values are computed in views (planned, see `docs/architecture/database.md`), not stored — except `products.average_cost`. `stock_balances` is a materialized balance that only changes when movements are confirmed; nothing is deleted, mistakes are voided with a reversing movement (`movements.reversal_of_id`).
77
77
- Naming: plural `snake_case` tables, `snake_case` columns, singular `snake_case` enum types with `UPPER_CASE` values; Prisma models are singular PascalCase with `@@map`, fields camelCase with `@map`. Keys are `serial`/`integer` (no `bigint`, to avoid `BigInt` in JSON). `created_at`/`updated_at` use `@default(now())` (plus `@updatedAt`) so non-Prisma writers work. Index every foreign key unless it leads a PK/unique index.
|[Authentication and access](modules/auth.md)| Sign-up, login, invitations, users and roles |
8
+
|[Product catalog](modules/catalog.md)| Products, categories and stock units |
9
+
|[Warehouses](modules/warehouses.md)| Warehouses, stores and default locations |
10
+
|[Inventory movements](modules/movements.md)| Receipts, issues, adjustments and transfers |
11
+
|[Stock](modules/stock.md)| Quantities by warehouse, location and lot |
12
+
|[Internal stock requests](modules/stock-requests.md)| Department requests, reservations and fulfillment |
13
+
|[Demand history](modules/demand.md)| Which movements count as demand and how demand is grouped |
14
+
|[Forecasting](modules/forecasting.md)| Forecast runs and integration with the Python service |
15
+
|[Replenishment](modules/replenishment.md)| Manual and calculated reorder points, stock alerts and their resolution |
16
+
|[Search](modules/search.md)| Cross-module search and access rules |
17
+
|[Dashboard](modules/dashboard.md)| Inventory indicators and alerts |
18
+
19
+
## Architecture and project
20
+
21
+
-[Database architecture](architecture/database.md) covers tenant isolation, schema conventions, migrations and provisioning.
22
+
-[Architecture workflow](project/architecture-workflow.md) defines roles, approvals and implementation review.
23
+
-[Project context](project/project-context.md) records decisions, previous work and open questions.
24
+
25
+
## Plans and templates
26
+
27
+
-[CU-11 · Calculated reorder point](plans/cu-11-reorder-point.md) records the design and validation of the implemented feature.
28
+
-[CU-17 · Kardex import](plans/cu-17-kardex-import.md) proposes the movement import workflow. The [standard Pango kardex template](templates/pango-standard-kardex-movement-history-import-v1.csv) defines the CSV format for importing inventory movement history.
29
+
-[Documentation layout](plans/documentation-layout.md) records the organization of these guides.
0 commit comments