@clidey/dory 0.1.0 → 0.2.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.
Files changed (51) hide show
  1. package/README.md +1 -1
  2. package/docs/api-playground-demo.mdx +119 -0
  3. package/docs/api-reference/openapi.json +366 -0
  4. package/docs/api-reference/operations/create.mdx +5 -0
  5. package/docs/api-reference/operations/delete.mdx +5 -0
  6. package/docs/api-reference/operations/get.mdx +5 -0
  7. package/docs/api-reference/operations/update.mdx +5 -0
  8. package/docs/assets/dory.jpeg +0 -0
  9. package/docs/dory.json +12 -131
  10. package/docs/favicon.svg +75 -0
  11. package/docs/features.mdx +440 -0
  12. package/docs/introduction.mdx +44 -0
  13. package/docs/logo/logo.png +0 -0
  14. package/package.json +3 -2
  15. package/src/mdx/source.tsx +15 -4
  16. package/docs/README.md +0 -2
  17. package/docs/configuration/app-settings/feature-flags.mdx +0 -157
  18. package/docs/configuration/app-settings/user-settings.mdx +0 -201
  19. package/docs/configuration/installation-setup/env-vars.mdx +0 -198
  20. package/docs/configuration/installation-setup/installation.mdx +0 -127
  21. package/docs/integrations/analytics-monitoring/error-tracking.mdx +0 -199
  22. package/docs/integrations/analytics-monitoring/notifications.mdx +0 -189
  23. package/docs/integrations/analytics-monitoring/user-analytics.mdx +0 -182
  24. package/docs/integrations/shopify-integration/shopify-setup.mdx +0 -226
  25. package/docs/integrations/shopify-integration/shopify-webhooks.mdx +0 -207
  26. package/docs/overview/developer-overview/dev-architecture.mdx +0 -292
  27. package/docs/overview/product-intro/app-overview.mdx +0 -167
  28. package/docs/overview/product-intro/architecture.mdx +0 -203
  29. package/docs/overview/product-intro/core-concepts.mdx +0 -267
  30. package/docs/platform-admin/billing-subscriptions/billing.mdx +0 -176
  31. package/docs/platform-admin/system-maintenance/db-migrations.mdx +0 -184
  32. package/docs/platform-admin/system-maintenance/health-monitoring.mdx +0 -222
  33. package/docs/platform-admin/system-maintenance/queue-management.mdx +0 -234
  34. package/docs/platform-admin/user-team-management/teams.mdx +0 -170
  35. package/docs/platform-admin/user-team-management/users.mdx +0 -185
  36. package/docs/support/legal/dependency-analysis.mdx +0 -132
  37. package/docs/support/legal/privacy-terms.mdx +0 -73
  38. package/docs/support/troubleshooting/common-issues.mdx +0 -159
  39. package/docs/usage/api-usage/api-inventory.mdx +0 -213
  40. package/docs/usage/api-usage/api-products.mdx +0 -249
  41. package/docs/usage/api-usage/api-purchase-orders.mdx +0 -289
  42. package/docs/usage/api-usage/api-reports.mdx +0 -227
  43. package/docs/usage/api-usage/api-suppliers.mdx +0 -171
  44. package/docs/usage/api-usage/api-user-management.mdx +0 -171
  45. package/docs/usage/ui-workflows/bundles.mdx +0 -157
  46. package/docs/usage/ui-workflows/demand-planning.mdx +0 -210
  47. package/docs/usage/ui-workflows/favorites.mdx +0 -167
  48. package/docs/usage/ui-workflows/inventory-management.mdx +0 -179
  49. package/docs/usage/ui-workflows/onboarding.mdx +0 -215
  50. package/docs/usage/ui-workflows/purchase-orders.mdx +0 -200
  51. package/docs/usage/ui-workflows/reports.mdx +0 -257
@@ -1,292 +0,0 @@
1
- ---
2
- title: 'Technical Architecture Overview'
3
- description: 'High-level explanation of backend modules, communication patterns, shared resources, and tech stacks.'
4
- ---
5
-
6
- # Technical Architecture Overview
7
-
8
- ## 1. Purpose and Scope
9
-
10
- The **PIM (Product Information Management) Module** is a core backend component responsible for managing products, variants, inventory, collections, locations, suppliers, and related business logic within the Genie application. It serves as the authoritative source for product-related data, synchronizes with external systems (notably Shopify), and supports workflows such as bundles, stock levels, and supplier management.
11
-
12
- This module handles all CRUD operations and complex relations for product data, including tags, bundles, suppliers, and inventory tracking. It also integrates with other subsystems like Sales Orders, Purchase Orders, User Management, Shopify, and Workflow modules.
13
-
14
- **System Boundaries:**
15
- - Owns product/catalog domain data
16
- - Interfaces with Shopify for product and inventory synchronization
17
- - Supports warehouse location and inventory tracking
18
- - Exposes controllers for API usage
19
-
20
- **Architectural Context:**
21
- - Implemented as a NestJS Module using TypeORM for ORM
22
- - Relies on event-driven processing (via BullMQ queues) for asynchronous workflows
23
- - Interacts with shared services such as Slack and Email for notifications
24
-
25
- ## 2. Technical Overview
26
-
27
- The PIM module forms a central part of the Genie backend architecture, acting as the product data hub.
28
-
29
- ### Core Components:
30
- - **Entity Layer:** Defines TypeORM entities representing products, variants, inventory items, collections, suppliers, locations, and related historical or snapshot data.
31
- - **Service Layer:** Contains business logic for managing products, suppliers, tags, bundles, inventory, and variant data.
32
- - **Controller Layer:** API endpoints facilitating product management, inventory control, saved views, dashboards, locations, and bundles.
33
- - **Integration with External Modules:** Forward references to Shopify, Sales Order, Purchase Order, User Management, and Supplier modules enable cross-domain operations.
34
- - **Event Queue Processing:** Uses BullMQ queues and consumers to process asynchronous tasks such as insights synchronization, inventory item history, and snapshot management.
35
-
36
- ### Key Technologies:
37
- - **NestJS Framework:** Modular design with decorators and dependency injection.
38
- - **TypeORM:** ORM for database schema and queries, leveraging PostgreSQL (implied).
39
- - **BullMQ:** Distributed job queue for handling asynchronous tasks.
40
- - **Slack & Email Modules:** For notifications and communication.
41
- - **Event-driven design:** Consumers react to queued events for data synchronization and historical tracking.
42
-
43
- ### Architectural Pattern:
44
- The module employs a layered architecture with clear separation of concerns and uses event-driven paradigms to handle asynchronous processes and external system synchronization efficiently.
45
-
46
- ```mermaid
47
- flowchart TD
48
- subgraph "API Layer"
49
- PC["ProductsController"]
50
- IC["InventoryController"]
51
- LC["LocationsController"]
52
- SC["SavedViewController"]
53
- DC["DashboardController"]
54
- IPC["IdeaProductsController"]
55
- PMC["ProductsMappingController"]
56
- end
57
-
58
- subgraph "Service Layer"
59
- PS["ProductsService"]
60
- IS["InsightsSyncService"]
61
- ISyncS["InsightsScheduledSyncService"]
62
- IIS["InventorySalesMetricsService"]
63
- InvS["InventoryService"]
64
- LocS["LocationsService"]
65
- FavS["FavouritesService"]
66
- IdeaPS["IdeaProductsService"]
67
- SavedVS["SavedViewService"]
68
- DashS["DashboardService"]
69
- DSTS["DailySyncPerformanceTrackerService"]
70
- WebhooksSyncS["WebhooksInsightsSyncService"]
71
- ScheduledTS["ScheduledTasksService"]
72
- PMSnapS["ProductVariantSnapshotService"]
73
- PoBundlesS["PoBundlesService"]
74
- PMappingS["ProductsMappingService"]
75
- end
76
-
77
- subgraph "Entities & DB"
78
- PE["ProductEntity"]
79
- PVE["ProductVariantEntity"]
80
- IIHE["InventoryItemHistoryEntity"]
81
- CE["CollectionEntity"]
82
- CEProd["CollectionProductEntity"]
83
- LE["LocationEntity"]
84
- PVLE["ProductVariantLocationEntity"]
85
- PVCE["ProductVariantComponentEntity"]
86
- PSTE["ProductSupplierEntity"]
87
- PSVTE["ProductSupplierVariantEntity"]
88
- PVTCE["ProductVariantTagEntity"]
89
- PVBLIE["ProductVariantBuyIgnoreEntity"]
90
- PVSLE["ProductVariantShipmentLandedCostEntity"]
91
- end
92
-
93
- subgraph "External Modules"
94
- SOM["SalesOrderModule"]
95
- ShM["ShopifyModule"]
96
- UMM["UserManagementModule"]
97
- TM["TrackingModule"]
98
- CM["CommentModule"]
99
- AM["AssetModule"]
100
- POM["PurchaseOrderModule"]
101
- SupM["SupplierModule"]
102
- EM["EmailModule"]
103
- SM["SlackModule"]
104
- WM["WorkflowModule"]
105
- BM["BillingModule"]
106
- end
107
-
108
- subgraph "Queues & Consumers"
109
- ISyncC["InsightsSyncConsumer"]
110
- IIHC["InventoryItemHisotryConsumer"]
111
- PVSnapC["ProductVariantSnapshotConsumer"]
112
- end
113
-
114
- %% API to services
115
- PC -->|"calls"| PS
116
- IPC -->|"calls"| IdeaPS
117
- PMC -->|"calls"| PMappingS
118
- IC -->|"calls"| InvS
119
- LC -->|"calls"| LocS
120
- SC -->|"calls"| SavedVS
121
- DC -->|"calls"| DashS
122
-
123
- %% Services to Entities
124
- PS -->|"manages"| PE
125
- PS -->|"manages"| PVE
126
- PS -->|"manages"| PVTCE
127
- PS -->|"manages"| PVTTagE[PVTCE]
128
- PS -->|"manages"| PVTCE
129
- InvS -->|"manages"| IIHE
130
- LocS -->|"manages"| LE
131
- SavedVS -->|"manages"| SavedViewE["SavedViewEntity"]
132
- PS -->|"manages"| PVTCE
133
- PS -->|"manages"| PSTE
134
- PS -->|"manages"| PSVTE
135
- PS -->|"manages"| PVBLIE
136
- PS -->|"manages"| PVSLE
137
- WebhooksSyncS -->|"reads/writes"| PE
138
- WebhooksSyncS -->|"reads/writes"| PVE
139
-
140
- %% Consumers consume queue and update services
141
- ISyncC -->|"process events"| IS
142
- IIHC -->|"process events"| InvS
143
- PVSnapC -->|"process events"| PMSnapS
144
-
145
- %% Service dependencies
146
- PS -.->|"depends"| POM
147
- PS -.->|"depends"| WM
148
- PS -.->|"depends"| SM
149
- PS -.->|"depends"| ShM
150
-
151
- %% Module imports
152
- PimModule[PIM Module] --> SOM
153
- PimModule --> ShM
154
- PimModule --> UMM
155
- PimModule --> TM
156
- PimModule --> CM
157
- PimModule --> AM
158
- PimModule --> POM
159
- PimModule --> SupM
160
- PimModule --> EM
161
- PimModule --> SM
162
- PimModule --> WM
163
- PimModule --> BM
164
-
165
- %% External module relationships
166
- ShM -->|"integrates Shopify APIs"| EM
167
- SM -.->|"Slack alerts"| PS
168
-
169
- %% Legend
170
- classDef api fill:#0b74de,stroke:#085aab,color:#fff;
171
- classDef service fill:#2a9d8f,stroke:#207157,color:#fff;
172
- classDef entity fill:#e76f51,stroke:#b04027,color:#fff;
173
- classDef module fill:#264653,stroke:#1b2e3b,color:#fff;
174
- classDef queue fill:#f4a261,stroke:#ce7421,color:#000;
175
-
176
- class PC,IC,LC,SC,DC,IPC,PMC api;
177
- class PS,IS,ISyncS,IIS,InvS,LocS,FavS,IdeaPS,SavedVS,DashS,DSTS,WebhooksSyncS,ScheduledTS,PMSnapS,PoBundlesS,PMappingS service;
178
- class PE,PVE,IIHE,CE,CEProd,LE,PVLE,PVCE,PSTE,PSVTE,PVTCE,PVBLIE,PVSLE entity;
179
- class SOM,ShM,UMM,TM,CM,AM,POM,SupM,EM,SM,WM,BM module;
180
- class ISyncC,IIHC,PVSnapC queue;
181
-
182
- click PC "apps/api/src/pim/controllers/products.controller.ts"
183
- click IC "apps/api/src/pim/controllers/inventory.controller.ts"
184
- click LC "apps/api/src/pim/controllers/locations.controller.ts"
185
- click SC "apps/api/src/pim/controllers/saved-view.controller.ts"
186
- click DC "apps/api/src/pim/controllers/dashboard.controller.ts"
187
- click IPC "apps/api/src/pim/controllers/idea-products.controller.ts"
188
- click PMC "apps/api/src/pim/controllers/products-mapping.controller.ts"
189
-
190
- click PS "apps/api/src/pim/services/products.service.ts"
191
- click IS "apps/api/src/pim/services/insights-sync.service.ts"
192
- click ISyncS "apps/api/src/pim/services/insights-scheduled-sync.service.ts"
193
- click IIS "apps/api/src/pim/services/inventory-sales-metrics.service.ts"
194
- click InvS "apps/api/src/pim/services/inventory.service.ts"
195
- click LocS "apps/api/src/pim/services/locations.service.ts"
196
- click FavS "apps/api/src/pim/services/favourites.service.ts"
197
- click IdeaPS "apps/api/src/pim/services/idea-products.service.ts"
198
- click SavedVS "apps/api/src/pim/services/saved-view.service.ts"
199
- click DashS "apps/api/src/pim/services/dashboard.service.ts"
200
- click DSTS "apps/api/src/pim/services/daily-sync-performance-tracker.service.ts"
201
- click WebhooksSyncS "apps/api/src/pim/services/webhooks-insights-sync.service.ts"
202
- click ScheduledTS "apps/api/src/pim/services/scheduled-tasks.service.ts"
203
- click PMSnapS "apps/api/src/pim/services/product-variant-snapshot.service.ts"
204
- click PoBundlesS "apps/api/src/purchase-order/services/po-bundles.service.ts"
205
- click PMappingS "apps/api/src/pim/services/products-mapping.service.ts"
206
-
207
- click PE "apps/api/src/pim/entities/product.entity.ts"
208
- click PVE "apps/api/src/pim/entities/product-variant.entity.ts"
209
- click IIHE "apps/api/src/pim/entities/inventory-item-history.entity.ts"
210
- click CE "apps/api/src/pim/entities/collection.entity.ts"
211
- click CEProd "apps/api/src/pim/entities/collection-product.entity.ts"
212
- click LE "apps/api/src/pim/entities/location.entity.ts"
213
- click PVLE "apps/api/src/pim/entities/product-variant-location.entity.ts"
214
- click PVCE "apps/api/src/pim/entities/product-variant-component.entity.ts"
215
- click PSTE "apps/api/src/pim/entities/product-supplier.entity.ts"
216
- click PSVTE "apps/api/src/pim/entities/product-supplier-variant.entity.ts"
217
- click PVTCE "apps/api/src/pim/entities/product-variant-tag.entity.ts"
218
- click PVBLIE "apps/api/src/pim/entities/product-variant-buy-ignore.entity.ts"
219
- click PVSLE "apps/api/src/pim/entities/product-variant-shipment-landed-cost.entity.ts"
220
-
221
- click SOM "apps/api/src/sales-order"
222
- click ShM "apps/api/src/shopify"
223
- click UMM "apps/api/src/user-management"
224
- click TM "apps/api/src/tracking"
225
- click CM "apps/api/src/comment"
226
- click AM "apps/api/src/asset"
227
- click POM "apps/api/src/purchase-order"
228
- click SupM "apps/api/src/supplier"
229
- click EM "apps/api/src/email"
230
- click SM "apps/api/src/slack"
231
- click WM "apps/api/src/workflow"
232
- click BM "apps/api/src/billing"
233
-
234
- click ISyncC "apps/api/src/pim/services/insights-sync.consumer.ts"
235
- click IIHC "apps/api/src/pim/services/inventory-item-history.consumer.ts"
236
- click PVSnapC "apps/api/src/pim/services/product-variant-snapshot.consumer.ts"
237
-
238
- style PC fill:#0b74de,stroke:#085aab,color:#fff
239
- style IC fill:#0b74de,stroke:#085aab,color:#fff
240
- style LC fill:#0b74de,stroke:#085aab,color:#fff
241
- style SC fill:#0b74de,stroke:#085aab,color:#fff
242
- style DC fill:#0b74de,stroke:#085aab,color:#fff
243
- style IPC fill:#0b74de,stroke:#085aab,color:#fff
244
- style PMC fill:#0b74de,stroke:#085aab,color:#fff
245
-
246
- style PS fill:#2a9d8f,stroke:#207157,color:#fff
247
- style IS fill:#2a9d8f,stroke:#207157,color:#fff
248
- style ISyncS fill:#2a9d8f,stroke:#207157,color:#fff
249
- style IIS fill:#2a9d8f,stroke:#207157,color:#fff
250
- style InvS fill:#2a9d8f,stroke:#207157,color:#fff
251
- style LocS fill:#2a9d8f,stroke:#207157,color:#fff
252
- style FavS fill:#2a9d8f,stroke:#207157,color:#fff
253
- style IdeaPS fill:#2a9d8f,stroke:#207157,color:#fff
254
- style SavedVS fill:#2a9d8f,stroke:#207157,color:#fff
255
- style DashS fill:#2a9d8f,stroke:#207157,color:#fff
256
- style DSTS fill:#2a9d8f,stroke:#207157,color:#fff
257
- style WebhooksSyncS fill:#2a9d8f,stroke:#207157,color:#fff
258
- style ScheduledTS fill:#2a9d8f,stroke:#207157,color:#fff
259
- style PMSnapS fill:#2a9d8f,stroke:#207157,color:#fff
260
- style PoBundlesS fill:#2a9d8f,stroke:#207157,color:#fff
261
- style PMappingS fill:#2a9d8f,stroke:#207157,color:#fff
262
-
263
- style PE fill:#e76f51,stroke:#b04027,color:#fff
264
- style PVE fill:#e76f51,stroke:#b04027,color:#fff
265
- style IIHE fill:#e76f51,stroke:#b04027,color:#fff
266
- style CE fill:#e76f51,stroke:#b04027,color:#fff
267
- style CEProd fill:#e76f51,stroke:#b04027,color:#fff
268
- style LE fill:#e76f51,stroke:#b04027,color:#fff
269
- style PVLE fill:#e76f51,stroke:#b04027,color:#fff
270
- style PVCE fill:#e76f51,stroke:#b04027,color:#fff
271
- style PSTE fill:#e76f51,stroke:#b04027,color:#fff
272
- style PSVTE fill:#e76f51,stroke:#b04027,color:#fff
273
- style PVTCE fill:#e76f51,stroke:#b04027,color:#fff
274
- style PVBLIE fill:#e76f51,stroke:#b04027,color:#fff
275
- style PVSLE fill:#e76f51,stroke:#b04027,color:#fff
276
-
277
- style SOM fill:#264653,stroke:#1b2e3b,color:#fff
278
- style ShM fill:#264653,stroke:#1b2e3b,color:#fff
279
- style UMM fill:#264653,stroke:#1b2e3b,color:#fff
280
- style TM fill:#264653,stroke:#1b2e3b,color:#fff
281
- style CM fill:#264653,stroke:#1b2e3b,color:#fff
282
- style AM fill:#264653,stroke:#1b2e3b,color:#fff
283
- style POM fill:#264653,stroke:#1b2e3b,color:#fff
284
- style SupM fill:#264653,stroke:#1b2e3b,color:#fff
285
- style EM fill:#264653,stroke:#1b2e3b,color:#fff
286
- style SM fill:#264653,stroke:#1b2e3b,color:#fff
287
- style WM fill:#264653,stroke:#1b2e3b,color:#fff
288
- style BM fill:#264653,stroke:#1b2e3b,color:#fff
289
-
290
- style ISyncC fill:#f4a261,stroke:#ce7421,color:#000
291
- style IIHC fill:#f4a261,stroke:#ce7421,color:#000
292
- style PVSnapC fill:#f4a261,stroke:#ce7421,color:#000
@@ -1,167 +0,0 @@
1
- ---
2
- title: 'Genie App Overview'
3
- description: 'Summary of the product, its purpose, components (front-end, back-end, database), and high-level system responsibilities.'
4
- ---
5
-
6
- # Genie App Overview
7
-
8
- ## Purpose and Scope
9
-
10
- The Genie App is a comprehensive operations management platform primarily used for inventory management, purchase orders, reporting, and demand planning. It targets growing Shopify merchants to streamline inventory workflows and enhance operational visibility.
11
-
12
- This documentation covers the overall structure and key components of the Genie App, detailing the frontend and backend integration, important modules, and interaction patterns within the system.
13
-
14
- ## Architectural Context
15
-
16
- - **Frontend:** Built with Next.js, providing the web UI for users to interact with the system.
17
- - **Backend:** Powered by a NestJS API responsible for business logic, data processing, and integration with third-party services.
18
- - **Database:** PostgreSQL serves as the primary data store.
19
-
20
- The Genie App integrates tightly with Shopify for inventory syncing and offers embedded calendar scheduling features to facilitate user onboarding and support.
21
-
22
- ## Technical Overview
23
-
24
- The Genie App follows a modular architecture with clear separation between frontend UI components and backend services. Key technologies and design principles include:
25
-
26
- - **React with Next.js:** For server-side rendered and client-side web UI delivering fast and SEO-friendly pages.
27
- - **NestJS:** An opinionated Node.js framework leveraging TypeScript, used to implement RESTful APIs.
28
- - **PostgreSQL:** Relational database for core data persistence.
29
- - **Docker and Docker Compose:** Used for local development and integration testing including the Postgres database.
30
- - **TypeORM:** Handles database migrations, schema generation, and database seeding.
31
- - **Cal.com widget embedded:** Provides inline calendar scheduling functionality for user engagement.
32
-
33
- ## High-Level System Flow
34
-
35
- This flow describes major system parts and their interactions:
36
-
37
- 1. **User Interaction (Frontend)**
38
- - Users access the system via the web app UI.
39
- - Authentication is initiated via email with "magic links."
40
- - Core workflows include inventory management, purchase orders, reporting, and onboarding.
41
- 2. **API Layer (Backend)**
42
- - Processes business logic.
43
- - Sends emails including purchase order notifications and reports.
44
- - Handles database migrations and data seeding.
45
- 3. **External Integrations**
46
- - Shopify integration for inventory syncing.
47
- - SendGrid for transactional email delivery.
48
- - Cal.com for demo booking calendar embedded in modals.
49
-
50
- ## Core Components and Responsibilities
51
-
52
- ### Frontend Components
53
-
54
- - **WelcomeModal** (`apps/web/src/components/jasmine/welcome-modal.tsx`):
55
- - Displays a welcome screen with trial details and demo booking calendar.
56
- - Embeds a Cal.com calendar iframe to allow users to book onboarding sessions.
57
- - Uses React hooks like `useStorageState` to control showing the modal.
58
-
59
- - **Registration and Login Pages**:
60
- - Handle user sign-up and login flows using email-based magic links.
61
- - Use `react-hook-form` for form handling and mutations from API calls.
62
-
63
- - **Settings and Billing Pages**:
64
- - Manage subscription plans and billing details.
65
- - Provide links to Shopify Apps page and booking support.
66
-
67
- ### Backend Services
68
-
69
- - **EmailService** (`apps/api/src/email/services/email.service.ts`):
70
- - Centralizes email sending using SendGrid.
71
- - Sends various templated emails: purchase order status, alerts, login verification, invitations, reports, trial expirations, and subscription confirmations.
72
- - Contains helper methods to generate HTML content for different report types.
73
-
74
- - **Database Migrations & Seeding:**
75
- - Managed via TypeORM commands and scripts for schema evolution and initial data.
76
-
77
- - **Error Handling:**
78
- - Customized exception class `GenieException` adds context to errors.
79
- - Integration with Sentry for monitoring and capturing detailed error data.
80
-
81
- ## Code Structure
82
-
83
- ### Frontend Code Structure
84
-
85
- - `apps/web/src/components/jasmine`: Common UI components including modals, typography, buttons, icons, and links.
86
- - `apps/web/src/components/pages/auth`: Login and registration pages.
87
- - `apps/web/src/components/pages/settings`: Settings pages including billing and locations.
88
- - `apps/web/src/components/pages/Onboarding`: Onboarding flow UI components.
89
-
90
- ### Backend Code Structure
91
-
92
- - `apps/api/src/email/services`: Email service implementations.
93
- - `apps/api/src/commons/errors`: Exception and error handling logic.
94
- - `apps/api/src/commons/error-handlers`: Integration with monitoring and logging.
95
-
96
- ## Environment and Configuration
97
-
98
- - Environment variables control API URLs, SendGrid API key, app URLs, and other secrets.
99
- - `.env` files need to be configured with database credentials and integration keys.
100
- - Postgres setup requires creating dedicated users for different concerns (general, task runner, sales metrics), with specific SQL grants.
101
- - Local dev environment setup includes running database via Docker Compose and starting API + frontend concurrently.
102
-
103
- ## Deployment & Development
104
-
105
- - Development servers run using Yarn workspaces commands:
106
- - `yarn workspace @genie/api dev` for backend.
107
- - `yarn workspace @genie/web dev` for frontend.
108
- - Combined `yarn dev` for full stack.
109
-
110
- - Database migrations handled by TypeORM commands:
111
- - Create: `yarn typeorm:create <MigrationName>`
112
- - Generate: `yarn typeorm:generate <MigrationName>`
113
- - Run: `yarn typeorm:run`
114
- - Revert: `yarn typeorm:revert`
115
-
116
- - Seeding local database with initial data using `yarn cmd seed-data`.
117
-
118
- ## Integration Summary
119
-
120
- - **Shopify:** Sync product variants and inventory levels.
121
- - **Cal.com:** Embedded scheduling calendar for booking demos and onboarding sessions inside modals.
122
- - **SendGrid:** Transactional and alert emails with rich HTML templates.
123
-
124
- ## Mermaid Diagram
125
-
126
- ```mermaid
127
- flowchart TD
128
- subgraph Frontend
129
- FE["React / Next.js Web UI"]:::frontend
130
- WM["Welcome Modal (Calendar Embed)"]:::component
131
- Login["Login & Register Pages"]:::component
132
- Settings["Settings & Billing UI"]:::component
133
- end
134
-
135
- subgraph Backend
136
- API["NestJS API Server"]:::backend
137
- EmailSvc["Email Service (SendGrid)"]:::component
138
- DB["PostgreSQL Database"]:::database
139
- ErrorMonitor["Error Handling & Sentry"]:::component
140
- Migration["TypeORM Migration & Seeding"]:::component
141
- end
142
-
143
- subgraph Integrations
144
- Shopify["Shopify Inventory Integration"]:::external
145
- CalCom["Cal.com - Scheduling Widget"]:::external
146
- end
147
-
148
- FE -->|"API Calls"| API
149
- API -->|"Reads/Writes"| DB
150
- API -->|"Sends Emails"| EmailSvc
151
- EmailSvc -->|"SMTP"| SendGrid["SendGrid Service"]:::external
152
- FE -->|"Embeds"| CalCom
153
- API --> Shopify
154
- API --> ErrorMonitor
155
-
156
- classDef frontend fill:#783fd9,stroke:#4e2a99,color:#fff,stroke-width:2px;
157
- classDef backend fill:#337ab7,stroke:#2c5a93,color:#fff,stroke-width:2px;
158
- classDef database fill:#28a745,stroke:#1e7e34,color:#fff,stroke-width:2px;
159
- classDef external fill:#f0ad4e,stroke:#d48806,color:#2d2d2d,stroke-width:2px;
160
- classDef component fill:#563d7c,stroke:#3a2761,color:#fff,stroke-width:1.5px;
161
-
162
- click WM "apps/web/src/components/jasmine/welcome-modal.tsx"
163
- click Login "apps/web/src/components/pages/auth/login.tsx"
164
- click Settings "apps/web/src/components/pages/settings/plans-and-billing-settings.tsx"
165
- click EmailSvc "apps/api/src/email/services/email.service.ts"
166
- click ErrorMonitor "apps/api/src/commons/error-handlers/captureException.ts"
167
- click Migration "README.md"
@@ -1,203 +0,0 @@
1
- ---
2
- title: 'System Architecture'
3
- description: 'Detailed architectural view including front-end (Next.js), back-end (NestJS), database, and integration points with key diagrams.'
4
- ---
5
-
6
- ## System Architecture
7
-
8
- ### 1. Purpose and Scope
9
-
10
- The System Architecture documentation provides an in-depth overview of the core backend modules and their interactions within the Genie application. This documentation explains the responsibilities and boundaries of key modules, especially those related to Shopify integration, Product Information Management (PIM), forecasting, setup/onboarding, administration, sales order processing, billing, and queue management.
11
-
12
- The primary goal is to describe how these modules fit together within the system, highlighting their roles and dependencies, to assist developers in maintaining, extending, and debugging the application.
13
-
14
- ---
15
-
16
- ### 2. Technical Overview
17
-
18
- The backend application is architected as a modular NestJS system, organized into feature modules that encapsulate specific domains or integrations. The core modules are interconnected via shared services, repositories, and message queues (using BullMQ) to provide a scalable, event-driven architecture.
19
-
20
- Main architectural traits include:
21
-
22
- - **Modular Design:** Each domain feature such as Shopify, PIM, Forecast, Admin, Setup, Sales Order, Billing, and User Management is implemented as a NestJS module.
23
- - **Event-Driven Processing:** Modules use BullMQ queues and consumers for asynchronous workflows and task processing (e.g., onboarding, demand planning, webhooks).
24
- - **Database ORM Layer:** TypeORM is used extensively for entity management and database interaction.
25
- - **API Layer:** Controllers expose REST API endpoints per module.
26
-
27
- The application’s core integration is centered around the Shopify module, which interfaces with Shopify stores and pushes data asynchronously into PIM and Forecast layers, feeding into business workflows.
28
-
29
-
30
- ### 3. Core Modules and Their Responsibilities
31
-
32
- #### Shopify Module
33
- - Responsible for handling Shopify API interactions, managing stores, products, orders, and webhooks.
34
- - Processes Shopify webhooks asynchronously via BullMQ queues.
35
- - Contains services for Shopify API calls (`ShopifyApiService`), product management (`ShopifyProductsService`), store management (`ShopifyStoreService`), orders (`ShopifyOrdersService`), and compliance webhooks.
36
- - Hosts controllers for webhook endpoints.
37
- - Integrates with User Management and PIM modules, reflecting multi-directional dependencies.
38
-
39
- #### Product Information Management (PIM) Module
40
- - Manages product entities, inventories, collections, locations, and related data.
41
- - Provides APIs and services for products, inventory, locations, and dashboards.
42
- - Handles extensive entity models such as `ProductVariantEntity`, `InventoryItemEntity`, and `CollectionEntity`.
43
- - Uses BullMQ queues for syncing insights and scheduled background jobs.
44
- - Interacts closely with Shopify (for syncing data) and Sales Order modules.
45
-
46
- #### Forecast Module
47
- - Provides demand planning and forecasting capabilities.
48
- - Uses BullMQ queues for demand plan, forecast, and historical sales data processing.
49
- - Includes services for workflow orchestration, scheduled tasks, and API controllers exposing demand plan functionalities.
50
- - Depends on PIM, Shopify, User Management, and Sales Order modules.
51
-
52
- #### Setup Module
53
- - Manages onboarding flows and Shopify connection setup.
54
- - Implements onboarding progress tracking and syncing initial Shopify data.
55
- - Runs onboarding jobs via BullMQ and resumes flows on module initialization.
56
- - Contains controllers and services specifically for Shopify connection and onboarding.
57
- - Includes Slack and billing integrations to support onboarding notifications and subscription handling.
58
-
59
- #### Admin Module
60
- - Coordinates administrative functionalities including billing, reports, client management, exporting, seeding data, and syncing.
61
- - Aggregates multiple submodules, providing a unified API layer for admin interactions.
62
- - Relies on various modules like Shopify, PIM, Purchase Order, Forecast, Supplier, and User Management.
63
- - Hosts multiple controllers and services for detailed admin features.
64
-
65
- #### Sales Order Module
66
- - Manages sales orders and their items.
67
- - Supports scheduled tasks and Slack service integration for notifications.
68
- - Depends on PIM and Shopify for data consistency.
69
-
70
- #### Billing Module
71
- - Manages subscription and billing workflows.
72
- - Integrates with Shopify and User Management modules.
73
- - Uses email and tracking services.
74
-
75
- #### Queue Module
76
- - Configures BullMQ globally with Redis connection settings.
77
- - Provides a secured Bull Board UI for monitoring queues.
78
- - Applies middleware for UI authentication.
79
-
80
- #### Cmd Module
81
- - Hosts CLI commands for database seeding, reset, Shopify API testing, and demo data handling.
82
- - Operates with PIM, User Management, Purchase Order, Shopify, and Sales Order modules.
83
-
84
- ### 4. Code Structure Overview
85
-
86
- Key modules and files:
87
-
88
- - **Shopify Module** ([apps/api/src/shopify/shopify.module.ts](apps/api/src/shopify/shopify.module.ts))
89
- - Contains services like `ShopifyApiService`, `ShopifyProductsService`, `ShopifyOrdersService`, and webhooks consumer.
90
- - Entities: `ShopifyEventEntity`, `ShopifyStoreEntity`, `ShopifyWebhookEventEntity`.
91
- - Controllers: `WebhooksController`, `ComplianceWebhooksController`.
92
-
93
- - **PIM Module** ([apps/api/src/pim/pim.module.ts](apps/api/src/pim/pim.module.ts))
94
- - Entity and services rich: products, variants, inventory, locations
95
- - Controllers for products, inventory, dashboards, and saved views.
96
- - Background consumers and scheduled tasks.
97
-
98
- - **Forecast Module** ([apps/api/src/forecast/forecast.module.ts](apps/api/src/forecast/forecast.module.ts))
99
- - Handles demand plan entities, consumers, and API controllers.
100
- - Uses BullMQ queues and flows for forecast processing.
101
-
102
- - **Setup Module** ([apps/api/src/setup/setup.module.ts](apps/api/src/setup/setup.module.ts))
103
- - Manages onboarding state and Shopify connection lifecycle.
104
- - Job consumer `OnboardingConsumer` processes onboarding queue jobs.
105
-
106
- - **Admin Module** ([apps/api/src/admin/admin.module.ts](apps/api/src/admin/admin.module.ts))
107
- - Composes various admin-related controllers and services.
108
-
109
- - **Sales Order Module** ([apps/api/src/sales-order/sales-order.module.ts](apps/api/src/sales-order/sales-order.module.ts))
110
- - Sales order entity management and scheduled tasks.
111
-
112
- - **Cmd Module** ([apps/api/src/cmd/cmd.module.ts](apps/api/src/cmd/cmd.module.ts))
113
- - CLI commands for demo data insertion and Shopify API testing.
114
-
115
- - **Billing Module** ([apps/api/src/billing/billing.module.ts](apps/api/src/billing/billing.module.ts))
116
- - Manages billing logic and webhook processing.
117
-
118
- - **Queue Module** ([apps/api/src/queue/queue.module.ts](apps/api/src/queue/queue.module.ts))
119
- - BullMQ and Bull Board setup with ExpressAdapter and UI authentication.
120
-
121
- ### Example snippet from `ShopifyModule` showing imports and providers:
122
-
123
- ```ts
124
- @Module({
125
- imports: [
126
- TypeOrmModule.forFeature([
127
- ShopifyEventEntity,
128
- ShopifyStoreEntity,
129
- ShopifyWebhookEventEntity,
130
- TeamEntity,
131
- ]),
132
- UserManagementModule,
133
- EmailModule,
134
- CommonsModule,
135
- ConfigModule,
136
- forwardRef(() => PimModule),
137
- BullModule.registerQueue({
138
- name: QUEUE.SHOPIFY_WEBHOOKS.name,
139
- }),
140
- ],
141
- providers: [
142
- ShopifyApiService,
143
- ShopifyProductsService,
144
- ShopifyStoreService,
145
- ComplianceWebhooksService,
146
- ShopifyOrdersService,
147
- ShopifyWebhooksService,
148
- ShopifyWebhooksConsumer,
149
- ],
150
- exports: [
151
- TypeOrmModule,
152
- ShopifyApiService,
153
- ShopifyProductsService,
154
- ShopifyStoreService,
155
- ShopifyOrdersService,
156
- ShopifyWebhooksService,
157
- ],
158
- controllers: [ComplianceWebhooksController, WebhooksController],
159
- })
160
- export class ShopifyModule {}
161
- ```
162
-
163
- ### 5. Integration and Data Flow
164
-
165
- - **Shopify Module** acts as the gateway for all Shopify interactions.
166
- - Shopify webhooks arrive at `WebhooksController` and are enqueued in BullMQ queues.
167
- - `ShopifyWebhooksConsumer` processes webhook events asynchronously, allowing decoupled downstream updates.
168
- - Product and inventory data sync flows pass data from Shopify to the **PIM Module**.
169
- - **Forecast Module** consumes product sales and demand data from **PIM** and **Sales Order Modules** to generate demand plans.
170
- - **Setup Module** orchestrates onboarding flows using queues, updating onboarding progress entities.
171
- - **Admin Module** aggregates various modules and exposes management APIs.
172
- - **Billing Module** coordinates billing activities, integrates with Shopify and user management.
173
-
174
- ### 6. Environment & Configuration
175
-
176
- Critical environment dependencies include:
177
- - Redis server configuration for BullMQ queues as specified in `QueueModule`.
178
- - Shopify API keys and credentials managed within configuration modules.
179
- - Google Drive API key used for seeding demo data in commands.
180
- - Snowflake data warehouse credentials for analytics.
181
-
182
- ### 7. Key Non-Functional Requirements
183
-
184
- - **Scalability:** Modular and queue-driven design supports horizontal scaling.
185
- - **Reliability:** Long-running jobs have timeout controls and multiple attempts (e.g., onboarding queue jobs).
186
- - **Security:** API layers enforce JWT and Admin guards; Bull Board UI is secured with middleware.
187
- - **Observability:** Bull Board and logging are integrated for background jobs.
188
-
189
- ### 8. Troubleshooting & Monitoring
190
-
191
- - Queues can be monitored via the Bull Board UI at `/ui/queues`, protected by middleware.
192
- - Logs from background consumers (e.g., onboarding, insights sync) report job status and errors.
193
- - Module-initialization resumes onboarding flows to handle incomplete progress after restarts.
194
-
195
- ---
196
-
197
- For detailed developer insights, refer to module-specific files as indexed above, starting with:
198
- - [Shopify Module](apps/api/src/shopify/shopify.module.ts)
199
- - [PIM Module](apps/api/src/pim/pim.module.ts)
200
- - [Forecast Module](apps/api/src/forecast/forecast.module.ts)
201
- - [Setup Module](apps/api/src/setup/setup.module.ts)
202
-
203
- This architecture overview should equip developers to navigate and evolve the system effectively.