ginskill-init 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.wrangler/cache/pages.json +4 -0
- package/.wrangler/cache/wrangler-account.json +6 -0
- package/DEVELOPMENT.md +510 -0
- package/README.md +104 -0
- package/agents/developer.md +56 -0
- package/agents/frontend-design.md +69 -0
- package/agents/mobile-reviewer.md +36 -0
- package/agents/review-code.md +49 -0
- package/agents/security-scanner.md +50 -0
- package/agents/tester.md +72 -0
- package/bin/cli.js +461 -0
- package/landing/ai-build-ai.png +0 -0
- package/landing/index.html +1495 -0
- package/landing/logo.png +0 -0
- package/package.json +37 -0
- package/skills/active-life-dev/SKILL.md +157 -0
- package/skills/active-life-dev/docs/auth.md +187 -0
- package/skills/active-life-dev/docs/customers.md +216 -0
- package/skills/active-life-dev/docs/integrations.md +209 -0
- package/skills/active-life-dev/docs/inventory.md +192 -0
- package/skills/active-life-dev/docs/modules.md +181 -0
- package/skills/active-life-dev/docs/orders.md +180 -0
- package/skills/active-life-dev/docs/patterns.md +319 -0
- package/skills/active-life-dev/docs/products.md +216 -0
- package/skills/active-life-dev/docs/schema.md +502 -0
- package/skills/active-life-dev/docs/setup.md +169 -0
- package/skills/active-life-dev/docs/vouchers.md +144 -0
- package/skills/ai-asset-generator/SKILL.md +247 -0
- package/skills/ai-asset-generator/docs/gen-image.md +274 -0
- package/skills/ai-asset-generator/docs/genvideo.md +341 -0
- package/skills/ai-asset-generator/docs/remove-background.md +19 -0
- package/skills/ai-asset-generator/lib/bg-remove.mjs +34 -0
- package/skills/ai-asset-generator/lib/env.mjs +48 -0
- package/skills/ai-asset-generator/lib/kie-client.mjs +100 -0
- package/skills/ai-build-ai/SKILL.md +127 -0
- package/skills/ai-build-ai/docs/agent-teams.md +293 -0
- package/skills/ai-build-ai/docs/checkpointing.md +161 -0
- package/skills/ai-build-ai/docs/create-agent.md +399 -0
- package/skills/ai-build-ai/docs/create-mcp.md +395 -0
- package/skills/ai-build-ai/docs/create-skill.md +299 -0
- package/skills/ai-build-ai/docs/headless-mode.md +614 -0
- package/skills/ai-build-ai/docs/hooks.md +578 -0
- package/skills/ai-build-ai/docs/memory-claude-md.md +375 -0
- package/skills/ai-build-ai/docs/output-styles.md +208 -0
- package/skills/ai-build-ai/docs/overview.md +162 -0
- package/skills/ai-build-ai/docs/permissions.md +391 -0
- package/skills/ai-build-ai/docs/plugins.md +396 -0
- package/skills/ai-build-ai/docs/sandbox.md +262 -0
- package/skills/ai-build-ai/docs/team-lead-workflow.md +648 -0
- package/skills/ant-design/SKILL.md +323 -0
- package/skills/ant-design/docs/components.md +160 -0
- package/skills/ant-design/docs/data-entry.md +406 -0
- package/skills/ant-design/docs/display.md +594 -0
- package/skills/ant-design/docs/feedback.md +451 -0
- package/skills/ant-design/docs/key-components.md +414 -0
- package/skills/ant-design/docs/navigation.md +310 -0
- package/skills/ant-design/docs/pro-components.md +543 -0
- package/skills/ant-design/docs/setup.md +213 -0
- package/skills/ant-design/docs/theme.md +265 -0
- package/skills/flutter-performance/SKILL.md +803 -0
- package/skills/flutter-performance/references/flutter-patterns.md +595 -0
- package/skills/icon-generator/SKILL.md +270 -0
- package/skills/mobile-app-review/SKILL.md +321 -0
- package/skills/mobile-app-review/references/apple-review.md +132 -0
- package/skills/mobile-app-review/references/google-play-review.md +203 -0
- package/skills/mongodb/SKILL.md +667 -0
- package/skills/mongodb/references/mongoose-patterns.md +368 -0
- package/skills/nestjs-architecture/SKILL.md +1086 -0
- package/skills/nestjs-architecture/references/advanced-patterns.md +590 -0
- package/skills/performance/SKILL.md +509 -0
- package/skills/react-fsd-architecture/SKILL.md +693 -0
- package/skills/react-fsd-architecture/references/fsd-patterns.md +747 -0
- package/skills/react-native-expo/SKILL.md +128 -0
- package/skills/react-native-expo/references/data-layer.md +252 -0
- package/skills/react-native-expo/references/design-system.md +252 -0
- package/skills/react-native-expo/references/navigation.md +199 -0
- package/skills/react-native-expo/references/performance.md +229 -0
- package/skills/react-native-expo/references/platform-services.md +179 -0
- package/skills/react-native-expo/references/state-management.md +209 -0
- package/skills/react-native-expo/references/ui-patterns.md +301 -0
- package/skills/react-query/SKILL.md +685 -0
- package/skills/react-query/references/query-patterns.md +365 -0
- package/skills/review-code/SKILL.md +374 -0
- package/skills/review-code/references/clean-code-principles.md +395 -0
- package/skills/review-code/references/frontend-patterns.md +136 -0
- package/skills/review-code/references/nestjs-patterns.md +184 -0
- package/skills/security-scanner/SKILL.md +366 -0
- package/skills/security-scanner/references/nestjs-security.md +260 -0
- package/skills/security-scanner/references/nextjs-security.md +201 -0
- package/skills/security-scanner/references/react-native-security.md +199 -0
- package/skills/traefik/SKILL.md +105 -0
- package/skills/traefik/docs/advanced-routing.md +186 -0
- package/skills/traefik/docs/auth-providers.md +137 -0
- package/skills/traefik/docs/cicd-devops.md +396 -0
- package/skills/traefik/docs/core-config.md +171 -0
- package/skills/traefik/docs/distributed-config.md +96 -0
- package/skills/traefik/docs/docker-compose.md +182 -0
- package/skills/traefik/docs/ha-performance.md +177 -0
- package/skills/traefik/docs/kubernetes.md +278 -0
- package/skills/traefik/docs/middleware.md +205 -0
- package/skills/traefik/docs/monitoring.md +357 -0
- package/skills/traefik/docs/security.md +391 -0
- package/skills/traefik/docs/tls-acme.md +155 -0
- package/skills/ui-ux-pro-max/SKILL.md +377 -0
- package/skills/ui-ux-pro-max/data/charts.csv +26 -0
- package/skills/ui-ux-pro-max/data/colors.csv +97 -0
- package/skills/ui-ux-pro-max/data/icons.csv +101 -0
- package/skills/ui-ux-pro-max/data/landing.csv +31 -0
- package/skills/ui-ux-pro-max/data/products.csv +97 -0
- package/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/skills/ui-ux-pro-max/data/stacks/astro.csv +54 -0
- package/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/skills/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
- package/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/skills/ui-ux-pro-max/data/styles.csv +68 -0
- package/skills/ui-ux-pro-max/data/typography.csv +58 -0
- package/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
# Active Life Backend - External Integrations
|
|
2
|
+
|
|
3
|
+
## 1. eTelecom (SIP Phone System)
|
|
4
|
+
|
|
5
|
+
### Purpose
|
|
6
|
+
Call center integration for TeleSales and LiveChat staff. Staff members are assigned SIP extensions to make/receive calls.
|
|
7
|
+
|
|
8
|
+
### Models
|
|
9
|
+
- `EtelecomExtension` — SIP extension config (extensionNumber, password, tenantId, tenantDomain)
|
|
10
|
+
- `OmiCall` — Call log records (callId, direction, fromNumber, toNumber, status, duration, recordingUrl)
|
|
11
|
+
|
|
12
|
+
### Module: `src/etelecom/`
|
|
13
|
+
- **Controller**: Extension management, webhook receiver
|
|
14
|
+
- **Service**: Create extensions, link to staff, process webhooks
|
|
15
|
+
|
|
16
|
+
### Key Endpoints
|
|
17
|
+
```
|
|
18
|
+
POST /api/v1/etelecom/extension — Create SIP extension
|
|
19
|
+
POST /api/v1/etelecom/link-staff — Link staff to extension
|
|
20
|
+
POST /api/v1/etelecom/webhook — Receive call events (Public)
|
|
21
|
+
GET /api/v1/etelecom/calls — List call logs
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### JWT Integration
|
|
25
|
+
Staff JWT payload includes eTelecom data:
|
|
26
|
+
```typescript
|
|
27
|
+
{
|
|
28
|
+
etelecom: {
|
|
29
|
+
extensionNumber: string;
|
|
30
|
+
extensionPassword: string;
|
|
31
|
+
tenantId: string;
|
|
32
|
+
tenantDomain: string;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
### Environment Variables
|
|
38
|
+
```
|
|
39
|
+
ETELECOM_URL= # eTelecom API base URL
|
|
40
|
+
AT_ETELECOM= # eTelecom API token
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## 2. Firebase
|
|
46
|
+
|
|
47
|
+
### Dependencies
|
|
48
|
+
```json
|
|
49
|
+
"firebase": "^11.4.0",
|
|
50
|
+
"firebase-admin": "^12.6.0"
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Usage
|
|
54
|
+
- Push notifications to mobile clients
|
|
55
|
+
- Possible auth integration for social login
|
|
56
|
+
- Firebase Admin SDK for server-side operations
|
|
57
|
+
|
|
58
|
+
### Configuration
|
|
59
|
+
Firebase config expected via environment variables or service account JSON.
|
|
60
|
+
|
|
61
|
+
---
|
|
62
|
+
|
|
63
|
+
## 3. Redis (IORedis)
|
|
64
|
+
|
|
65
|
+
### Dependencies
|
|
66
|
+
```json
|
|
67
|
+
"@nestjs-modules/ioredis": "^2.0.2",
|
|
68
|
+
"ioredis": "^5.8.2"
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
### Usage
|
|
72
|
+
- Session caching
|
|
73
|
+
- Rate limiting support
|
|
74
|
+
- Temporary data storage
|
|
75
|
+
- Queue management (potential)
|
|
76
|
+
|
|
77
|
+
### Setup in AppModule
|
|
78
|
+
```typescript
|
|
79
|
+
import { RedisModule } from '@nestjs-modules/ioredis';
|
|
80
|
+
|
|
81
|
+
RedisModule.forRoot({
|
|
82
|
+
type: 'single',
|
|
83
|
+
url: process.env.REDIS_URL,
|
|
84
|
+
})
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
---
|
|
88
|
+
|
|
89
|
+
## 4. Email (Nodemailer)
|
|
90
|
+
|
|
91
|
+
### Dependencies
|
|
92
|
+
```json
|
|
93
|
+
"@nestjs-modules/mailer": "^1.6.1",
|
|
94
|
+
"nodemailer": "^6.9.14"
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
### Usage
|
|
98
|
+
- Transactional emails (order confirmation, password reset)
|
|
99
|
+
- Templates in `views/mail/templates/` directory
|
|
100
|
+
- EJS template engine
|
|
101
|
+
|
|
102
|
+
### Setup
|
|
103
|
+
```typescript
|
|
104
|
+
import { MailerModule } from '@nestjs-modules/mailer';
|
|
105
|
+
|
|
106
|
+
MailerModule.forRoot({
|
|
107
|
+
transport: {
|
|
108
|
+
host: process.env.MAIL_HOST,
|
|
109
|
+
port: process.env.MAIL_PORT,
|
|
110
|
+
auth: {
|
|
111
|
+
user: process.env.MAIL_USER,
|
|
112
|
+
pass: process.env.MAIL_PASS,
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
defaults: {
|
|
116
|
+
from: process.env.MAIL_FROM,
|
|
117
|
+
},
|
|
118
|
+
template: {
|
|
119
|
+
dir: join(__dirname, '..', 'views', 'mail', 'templates'),
|
|
120
|
+
adapter: new EjsAdapter(),
|
|
121
|
+
},
|
|
122
|
+
})
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## 5. Mongoose (MongoDB - Secondary)
|
|
128
|
+
|
|
129
|
+
### Dependencies
|
|
130
|
+
```json
|
|
131
|
+
"@nestjs/mongoose": "^10.0.0",
|
|
132
|
+
"mongoose": "^8.5.0",
|
|
133
|
+
"mongoose-delete": "^1.0.2"
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
### Usage
|
|
137
|
+
- Secondary database for specific use cases
|
|
138
|
+
- Soft delete support via mongoose-delete plugin
|
|
139
|
+
- NOT the primary database (Prisma/PostgreSQL is primary)
|
|
140
|
+
|
|
141
|
+
### Note
|
|
142
|
+
Some models may use MongoDB for flexible schema requirements or legacy data. Check individual modules for MongoDB vs Prisma usage.
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## 6. Swagger / OpenAPI
|
|
147
|
+
|
|
148
|
+
### Dependency
|
|
149
|
+
```json
|
|
150
|
+
"@nestjs/swagger": "^7.0.0"
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Access
|
|
154
|
+
Available at `/api` endpoint in development.
|
|
155
|
+
|
|
156
|
+
### Usage in Controllers
|
|
157
|
+
```typescript
|
|
158
|
+
@ApiTags('products')
|
|
159
|
+
@ApiBearerAuth()
|
|
160
|
+
@Controller('product')
|
|
161
|
+
export class ProductController {
|
|
162
|
+
@Post()
|
|
163
|
+
@ApiOperation({ summary: 'Create a new product' })
|
|
164
|
+
@ApiResponse({ status: 201, description: 'Product created' })
|
|
165
|
+
create(@Body() dto: CreateProductDto) { }
|
|
166
|
+
}
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
---
|
|
170
|
+
|
|
171
|
+
## 7. Rate Limiting (Throttler)
|
|
172
|
+
|
|
173
|
+
### Dependency
|
|
174
|
+
```json
|
|
175
|
+
"@nestjs/throttler": "^6.0.0"
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Configuration
|
|
179
|
+
```typescript
|
|
180
|
+
ThrottlerModule.forRoot([{
|
|
181
|
+
ttl: 60000, // 60 seconds window
|
|
182
|
+
limit: 10, // Max 10 requests per window
|
|
183
|
+
}])
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
Global rate limiting applied to all endpoints.
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## Integration Architecture
|
|
191
|
+
|
|
192
|
+
```
|
|
193
|
+
┌─────────────┐
|
|
194
|
+
│ Clients │
|
|
195
|
+
│ (Mobile/Web)│
|
|
196
|
+
└──────┬──────┘
|
|
197
|
+
│
|
|
198
|
+
┌──────▼──────┐
|
|
199
|
+
│ NestJS │
|
|
200
|
+
│ API │
|
|
201
|
+
└──────┬──────┘
|
|
202
|
+
│
|
|
203
|
+
┌───────┬───────┼───────┬────────┐
|
|
204
|
+
│ │ │ │ │
|
|
205
|
+
┌────▼──┐ ┌──▼───┐ ┌▼────┐ ┌▼─────┐ ┌▼────────┐
|
|
206
|
+
│Supabase│ │Redis │ │Email│ │Firebase│ │eTelecom │
|
|
207
|
+
│ PG │ │Cache │ │SMTP │ │ Push │ │ SIP │
|
|
208
|
+
└───────┘ └──────┘ └─────┘ └──────┘ └─────────┘
|
|
209
|
+
```
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
# Active Life Backend - Inventory System
|
|
2
|
+
|
|
3
|
+
## Architecture
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
InventoryProduct (warehouse item: SKU, barcode, unit, brand)
|
|
7
|
+
├──< ProductInventoryItem (individual lots with expiry dates)
|
|
8
|
+
└──< InventoryTransaction (import/export records)
|
|
9
|
+
└──> InventorySession (batch import/export session)
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Key Concept: Inventory vs Store Products
|
|
13
|
+
|
|
14
|
+
- **InventoryProduct** — Physical warehouse items (raw materials, actual stock)
|
|
15
|
+
- **StoreProduct** — Customer-facing products (may combine multiple inventory products via combos)
|
|
16
|
+
- **ProductInventoryItem** — Individual lot/batch with quantity, expiry date, lot number
|
|
17
|
+
|
|
18
|
+
**Example**:
|
|
19
|
+
```
|
|
20
|
+
InventoryProduct: "Whey Protein Gold Standard 1kg"
|
|
21
|
+
├── Lot #1: qty=50, expires=2025-06-01, remaining=45
|
|
22
|
+
├── Lot #2: qty=100, expires=2025-09-01, remaining=100
|
|
23
|
+
└── Lot #3: qty=75, expires=2025-12-01, remaining=75
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Models
|
|
27
|
+
|
|
28
|
+
### InventoryProduct
|
|
29
|
+
```prisma
|
|
30
|
+
model InventoryProduct {
|
|
31
|
+
id String @id @default(uuid())
|
|
32
|
+
name String
|
|
33
|
+
sku String? @unique
|
|
34
|
+
barcode String?
|
|
35
|
+
image String?
|
|
36
|
+
unitId String?
|
|
37
|
+
brandId String?
|
|
38
|
+
// Relations
|
|
39
|
+
unit Unit? @relation(...)
|
|
40
|
+
brand Brand? @relation(...)
|
|
41
|
+
items ProductInventoryItem[]
|
|
42
|
+
transactions InventoryTransaction[]
|
|
43
|
+
comboItems StoreProductComboItem[]
|
|
44
|
+
}
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### ProductInventoryItem (Lot/Batch)
|
|
48
|
+
```prisma
|
|
49
|
+
model ProductInventoryItem {
|
|
50
|
+
id String @id @default(uuid())
|
|
51
|
+
inventoryProductId String
|
|
52
|
+
quantity Int // Original imported quantity
|
|
53
|
+
remainingQuantity Int // Current remaining
|
|
54
|
+
expiryDate DateTime?
|
|
55
|
+
lotNumber String?
|
|
56
|
+
createdAt DateTime @default(now())
|
|
57
|
+
updatedAt DateTime @updatedAt
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### InventorySession
|
|
62
|
+
```prisma
|
|
63
|
+
model InventorySession {
|
|
64
|
+
id String @id @default(uuid())
|
|
65
|
+
type InventoryTransactionType // IMPORT or EXPORT
|
|
66
|
+
note String?
|
|
67
|
+
userId String // Staff who created
|
|
68
|
+
transactions InventoryTransaction[]
|
|
69
|
+
createdAt DateTime @default(now())
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### InventoryTransaction
|
|
74
|
+
```prisma
|
|
75
|
+
model InventoryTransaction {
|
|
76
|
+
id String @id @default(uuid())
|
|
77
|
+
sessionId String
|
|
78
|
+
inventoryProductId String
|
|
79
|
+
quantity Int
|
|
80
|
+
expiryDate DateTime?
|
|
81
|
+
lotNumber String?
|
|
82
|
+
orderItemId String? // Links to OrderItem when exporting for orders
|
|
83
|
+
createdAt DateTime @default(now())
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
## Inventory Operations
|
|
88
|
+
|
|
89
|
+
### Import (Stock In)
|
|
90
|
+
```
|
|
91
|
+
POST /api/v1/inventory/import
|
|
92
|
+
Body: CreateInventorySessionDto {
|
|
93
|
+
type: "IMPORT",
|
|
94
|
+
note: "Weekly stock delivery",
|
|
95
|
+
items: [
|
|
96
|
+
{
|
|
97
|
+
inventoryProductId: "uuid",
|
|
98
|
+
quantity: 100,
|
|
99
|
+
expiryDate: "2025-12-01",
|
|
100
|
+
lotNumber: "LOT-2025-001"
|
|
101
|
+
}
|
|
102
|
+
]
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**What happens**:
|
|
107
|
+
1. Creates `InventorySession` (type=IMPORT)
|
|
108
|
+
2. For each item:
|
|
109
|
+
- Creates `InventoryTransaction` record
|
|
110
|
+
- Creates or updates `ProductInventoryItem` (lot)
|
|
111
|
+
- Adds quantity to the lot
|
|
112
|
+
|
|
113
|
+
### Export (Stock Out - Manual)
|
|
114
|
+
```
|
|
115
|
+
POST /api/v1/inventory/export
|
|
116
|
+
Body: CreateInventorySessionDto {
|
|
117
|
+
type: "EXPORT",
|
|
118
|
+
note: "Damaged goods removal",
|
|
119
|
+
items: [
|
|
120
|
+
{ inventoryProductId: "uuid", quantity: 5 }
|
|
121
|
+
]
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Export via Order Processing
|
|
126
|
+
When staff processes an order, they select specific lots:
|
|
127
|
+
```
|
|
128
|
+
PATCH /api/v1/order/:id/process
|
|
129
|
+
Body: {
|
|
130
|
+
items: [{
|
|
131
|
+
orderItemId: "order-item-uuid",
|
|
132
|
+
lots: [{
|
|
133
|
+
inventoryItemId: "lot-uuid", // ProductInventoryItem
|
|
134
|
+
quantity: 2
|
|
135
|
+
}]
|
|
136
|
+
}]
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
**What happens**:
|
|
141
|
+
1. Creates `InventorySession` (type=EXPORT)
|
|
142
|
+
2. For each lot selection:
|
|
143
|
+
- Deducts `remainingQuantity` from `ProductInventoryItem`
|
|
144
|
+
- Creates `InventoryTransaction` with `orderItemId` link
|
|
145
|
+
3. Order status → PROCESSING
|
|
146
|
+
|
|
147
|
+
### Inventory Reversal (Order Cancellation)
|
|
148
|
+
When a PROCESSING order is cancelled:
|
|
149
|
+
1. Finds all `InventoryTransaction` records for the order
|
|
150
|
+
2. Adds quantities back to `ProductInventoryItem.remainingQuantity`
|
|
151
|
+
3. Marks transactions as reversed
|
|
152
|
+
|
|
153
|
+
## Valid Items Query
|
|
154
|
+
|
|
155
|
+
Get non-expired inventory items with remaining stock:
|
|
156
|
+
```
|
|
157
|
+
GET /api/v1/inventory-product/:id/valid-items
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Returns `ProductInventoryItem[]` where:
|
|
161
|
+
- `remainingQuantity > 0`
|
|
162
|
+
- `expiryDate > now()` (or no expiry date)
|
|
163
|
+
- Sorted by expiry date ASC (FIFO)
|
|
164
|
+
|
|
165
|
+
## Key API Endpoints
|
|
166
|
+
|
|
167
|
+
### Inventory Products (Warehouse Items)
|
|
168
|
+
```
|
|
169
|
+
GET /api/v1/inventory-product — List all inventory products
|
|
170
|
+
GET /api/v1/inventory-product/:id — Get with stock details
|
|
171
|
+
POST /api/v1/inventory-product — Create warehouse item
|
|
172
|
+
PATCH /api/v1/inventory-product/:id — Update warehouse item
|
|
173
|
+
DELETE /api/v1/inventory-product/:id — Delete warehouse item
|
|
174
|
+
GET /api/v1/inventory-product/:id/valid-items — Get non-expired lots
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Inventory Sessions (Import/Export)
|
|
178
|
+
```
|
|
179
|
+
GET /api/v1/inventory — List sessions
|
|
180
|
+
GET /api/v1/inventory/:id — Get session with transactions
|
|
181
|
+
POST /api/v1/inventory/import — Import stock
|
|
182
|
+
POST /api/v1/inventory/export — Export stock (manual)
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
## Business Rules
|
|
186
|
+
|
|
187
|
+
1. **FIFO** — Use oldest lots first (sorted by expiry date)
|
|
188
|
+
2. **Expiry tracking** — Items past expiry should not be sold
|
|
189
|
+
3. **Lot traceability** — Every export links back to specific lots
|
|
190
|
+
4. **Order linking** — Export transactions link to order items for audit
|
|
191
|
+
5. **Reversal support** — Cancelled orders restore inventory
|
|
192
|
+
6. **Stock check** — Cannot export more than remaining quantity
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# Active Life Backend - All Modules Reference
|
|
2
|
+
|
|
3
|
+
## Module List (23 total)
|
|
4
|
+
|
|
5
|
+
### Core Business Modules
|
|
6
|
+
|
|
7
|
+
#### 1. Auth Module (`src/auth/`)
|
|
8
|
+
- **Controller**: `AuthController` — Login, register, token refresh
|
|
9
|
+
- **Service**: `AuthService` — JWT signing, password hashing, validation
|
|
10
|
+
- **Strategies**: `JwtStrategy` (staff), `JwtClientStrategy` (customer)
|
|
11
|
+
- **Guard**: `JwtAuthGuard` — Global auth guard, checks @Public, checks isBan
|
|
12
|
+
- **DTOs**:
|
|
13
|
+
- `UserLoginDto` — { phone, password }
|
|
14
|
+
- `ClientLoginDto` — { phone, password }
|
|
15
|
+
- `ClientRegisterDto` — { phone, password, name }
|
|
16
|
+
- `ClientZaloLoginDto` — Zalo OAuth login
|
|
17
|
+
- `UserRegisterDto` — Staff registration (admin only)
|
|
18
|
+
- `AdminUpdateUserDto` — Admin updates user profile
|
|
19
|
+
|
|
20
|
+
#### 2. Product Module (`src/product/`)
|
|
21
|
+
- **Controller**: `ProductController` — CRUD products, combo management
|
|
22
|
+
- **Service**: `ProductService` — Product operations, combo logic, slug generation
|
|
23
|
+
- **DTOs**:
|
|
24
|
+
- `CreateProductDto` — { name, description, images, categoryIds, brandId, unitId, status }
|
|
25
|
+
- `UpdateProductDto` — Partial of create
|
|
26
|
+
- `CreateProductComboDto` — { name, price, comparePrice, items[] }
|
|
27
|
+
- `UpdateProductComboDto` — Partial of combo create
|
|
28
|
+
- `AddComboToProductDto` — Add combo to product
|
|
29
|
+
- `AddComboGiftDto` — Add gift items to combo
|
|
30
|
+
- `ComboItemDto` — { inventoryProductId, quantity }
|
|
31
|
+
|
|
32
|
+
#### 3. Order Module (`src/order/`)
|
|
33
|
+
- **Controller**: `OrderController` — Create, process, ship, deliver, cancel, refund, return
|
|
34
|
+
- **Service**: `OrderService` — Order lifecycle, inventory deduction, status flow
|
|
35
|
+
- **DTOs**:
|
|
36
|
+
- `CreateOrderDto` — Customer creates order
|
|
37
|
+
- `StaffCreateOrderDto` — Staff creates order on behalf
|
|
38
|
+
- `CreateOrderItemDto` — { productId, comboId, quantity }
|
|
39
|
+
- `UpdateOrderStatusDto` — Change order status
|
|
40
|
+
- `UpdateOrderFlowDto` — Process order through stages
|
|
41
|
+
- `CancelOrderDto` — { reason }
|
|
42
|
+
- `ProcessOrderDto` — Process with lot selection
|
|
43
|
+
- `ProcessOrderItemLotDto` — Assign inventory lots to items
|
|
44
|
+
- `RefundOrderDto` — Initiate refund
|
|
45
|
+
- `RefundRequestDto`, `CreateRefundRequestDto`, `CompleteRefundRequestDto` — Refund workflow
|
|
46
|
+
- `ReturnRequestDto`, `CreateReturnRequestDto`, `CompleteReturnRequestDto` — Return workflow
|
|
47
|
+
- `OrderRequestDto` — Query/filter orders
|
|
48
|
+
|
|
49
|
+
#### 4. Inventory Module (`src/inventory/`)
|
|
50
|
+
- **Controller**: `InventoryController` — Import/export sessions
|
|
51
|
+
- **Service**: `InventoryService` — Session management, transaction creation
|
|
52
|
+
- **DTOs**:
|
|
53
|
+
- `CreateInventorySessionDto` — { type, items[], note }
|
|
54
|
+
- `CreateInventoryItemDto` — { inventoryProductId, quantity, expiryDate, lotNumber }
|
|
55
|
+
|
|
56
|
+
#### 5. Inventory Product Module (`src/inventory-product/`)
|
|
57
|
+
- **Controller**: `InventoryProductController` — Warehouse product CRUD
|
|
58
|
+
- **Service**: `InventoryProductService` — Stock tracking, valid items
|
|
59
|
+
- **DTOs**:
|
|
60
|
+
- `CreateInventoryProductDto` — { name, sku, unitId, brandId }
|
|
61
|
+
- `UpdateInventoryProductDto` — Partial update
|
|
62
|
+
- `GetValidItemsDto` — Filter non-expired items
|
|
63
|
+
|
|
64
|
+
#### 6. Category Module (`src/category/`)
|
|
65
|
+
- **Controller**: `CategoryController` — Hierarchical category CRUD
|
|
66
|
+
- **Service**: `CategoryService` — Recursive queries, slug generation
|
|
67
|
+
- **DTOs**:
|
|
68
|
+
- `CreateCategoryDto` — { name, parentId?, image?, description? }
|
|
69
|
+
- `UpdateCategoryDto` — Partial update
|
|
70
|
+
|
|
71
|
+
#### 7. Brand Module (`src/brand/`)
|
|
72
|
+
- **Controller**: `BrandController` — Brand CRUD
|
|
73
|
+
- **Service**: `BrandService` — Brand operations
|
|
74
|
+
- **DTOs**:
|
|
75
|
+
- `CreateBrandDto` — { name, image?, description? }
|
|
76
|
+
- `UpdateBrandDto` — Partial update
|
|
77
|
+
|
|
78
|
+
#### 8. Voucher Module (`src/voucher/`)
|
|
79
|
+
- **Controller**: `VoucherController` — Voucher CRUD, redemption
|
|
80
|
+
- **Service**: `VoucherService` — Voucher lifecycle, usage tracking
|
|
81
|
+
- **DTOs**:
|
|
82
|
+
- `CreateVoucherDto` — { code, type, value, minOrder, maxDiscount, expiryDate, quantity }
|
|
83
|
+
- `UpdateVoucherDto` — Partial update
|
|
84
|
+
- `RedeemVoucherDto` — { code, orderId }
|
|
85
|
+
|
|
86
|
+
#### 9. Client Module (`src/client/`)
|
|
87
|
+
- **Controller**: `ClientController` — Customer CRUD, self-update
|
|
88
|
+
- **Service**: `ClientService` — Customer management, assignment
|
|
89
|
+
- **DTOs**:
|
|
90
|
+
- `CreateClientDto` — { phone, name, email?, address? }
|
|
91
|
+
- `UpdateClientDto` — Staff updates client
|
|
92
|
+
- `UpdateClientSelfDto` — Client updates own profile
|
|
93
|
+
- `UpdateBankInfoDto` — { bankName, accountNumber, accountHolder }
|
|
94
|
+
|
|
95
|
+
#### 10. Cart Module (`src/cart/`)
|
|
96
|
+
- **Controller**: `CartController` — Add, update, remove items, checkout
|
|
97
|
+
- **Service**: `CartService` — Cart operations, checkout flow
|
|
98
|
+
- **DTOs**:
|
|
99
|
+
- `AddToCartDto` — { productId, comboId, quantity }
|
|
100
|
+
- `UpdateCartItemDto` — { quantity }
|
|
101
|
+
- `CheckoutDto` — { voucherCode?, paymentMethod, shippingAddress }
|
|
102
|
+
|
|
103
|
+
#### 11. User Module (`src/user/`)
|
|
104
|
+
- **Controller**: `UserController` — Staff profile management
|
|
105
|
+
- **Service**: `UserService` — Staff CRUD
|
|
106
|
+
- **DTOs**:
|
|
107
|
+
- `UpdateUserDto` — Update staff profile
|
|
108
|
+
- `UpdatePasswordDto` — { oldPassword, newPassword }
|
|
109
|
+
|
|
110
|
+
#### 12. Role Module (`src/role/`)
|
|
111
|
+
- **Controller**: `RoleController` — Role CRUD (Admin only)
|
|
112
|
+
- **Service**: `RoleService` — Role management
|
|
113
|
+
- **No DTOs** — Uses inline types
|
|
114
|
+
|
|
115
|
+
### CRM / Lookup Modules
|
|
116
|
+
|
|
117
|
+
#### 13. Customer Source (`src/customer-source/`)
|
|
118
|
+
- Lookup table for where customers come from (Facebook, Zalo, Walk-in, etc.)
|
|
119
|
+
- **DTO**: `CreateCustomerSourceDto` — { name, description? }
|
|
120
|
+
|
|
121
|
+
#### 14. Customer Status (`src/customer-status/`)
|
|
122
|
+
- Lookup table for customer lifecycle status (New, Active, Inactive, etc.)
|
|
123
|
+
- **DTO**: `CreateCustomerStatusDto` — { name, description? }
|
|
124
|
+
|
|
125
|
+
#### 15. Customer Detail Status (`src/customer-detail-status/`)
|
|
126
|
+
- Granular customer status (Interested, Following Up, Purchased, etc.)
|
|
127
|
+
- **DTO**: `CreateCustomerDetailStatusDto` — { name, description? }
|
|
128
|
+
|
|
129
|
+
#### 16. Interaction Status (`src/interaction-status/`)
|
|
130
|
+
- Call/chat interaction statuses (Connected, No Answer, Busy, etc.)
|
|
131
|
+
- **DTO**: `CreateInteractionStatusDto` — { name, description? }
|
|
132
|
+
|
|
133
|
+
#### 17. Interaction Result (`src/interaction-result/`)
|
|
134
|
+
- Outcomes of customer interactions (Interested, Not Interested, Callback, etc.)
|
|
135
|
+
- **DTO**: `CreateInteractionResultDto` — { name, description? }
|
|
136
|
+
|
|
137
|
+
#### 18. Interaction Type (`src/interaction-type/`)
|
|
138
|
+
- Types of interactions (Phone Call, Zalo Chat, In-store, etc.)
|
|
139
|
+
- **DTO**: `CreateInteractionTypeDto` — { name, description? }
|
|
140
|
+
|
|
141
|
+
### Utility Modules
|
|
142
|
+
|
|
143
|
+
#### 19. Unit Module (`src/unit/`)
|
|
144
|
+
- Units of measurement (kg, liter, box, piece, etc.)
|
|
145
|
+
- **DTOs**: `CreateUnitDto`, `UpdateUnitDto` — { name, abbreviation? }
|
|
146
|
+
|
|
147
|
+
#### 20. Report Module (`src/report/`)
|
|
148
|
+
- Business analytics and reporting
|
|
149
|
+
- **No DTOs** — Query params based
|
|
150
|
+
|
|
151
|
+
#### 21. Seed Module (`src/seed/`)
|
|
152
|
+
- Database seeding for development/staging
|
|
153
|
+
- **No DTOs** — Hardcoded seed data
|
|
154
|
+
|
|
155
|
+
#### 22. Etelecom Module (`src/etelecom/`)
|
|
156
|
+
- SIP phone system integration for call center
|
|
157
|
+
- **DTOs**:
|
|
158
|
+
- `CreateEtelecomExtensionDto` — { extensionNumber, extensionPassword, tenantId, tenantDomain }
|
|
159
|
+
- `LinkStaffExtensionDto` — { userId, extensionId }
|
|
160
|
+
- `WebhookBodyDto` — Incoming call webhook data
|
|
161
|
+
|
|
162
|
+
---
|
|
163
|
+
|
|
164
|
+
## Module Import Pattern
|
|
165
|
+
|
|
166
|
+
All modules are imported in `src/app.module.ts`:
|
|
167
|
+
|
|
168
|
+
```typescript
|
|
169
|
+
@Module({
|
|
170
|
+
imports: [
|
|
171
|
+
ConfigModule.forRoot({ isGlobal: true }),
|
|
172
|
+
ThrottlerModule.forRoot([{ ttl: 60000, limit: 10 }]),
|
|
173
|
+
// ... all feature modules
|
|
174
|
+
AuthModule,
|
|
175
|
+
ProductModule,
|
|
176
|
+
OrderModule,
|
|
177
|
+
// etc.
|
|
178
|
+
],
|
|
179
|
+
})
|
|
180
|
+
export class AppModule {}
|
|
181
|
+
```
|