Skip to content

Commit 0a47c3d

Browse files
committed
docs: replace ASCII architecture diagrams with Mermaid
Convert all 6 architecture diagrams (root, prisma, auth, notifications, storage, audit-log) from ASCII art to Mermaid graph diagrams with color- coded nodes for better visual clarity on GitHub.
1 parent e853f67 commit 0a47c3d

6 files changed

Lines changed: 175 additions & 94 deletions

File tree

README.md

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,29 @@ Each module is a self-contained feature -- own Prisma schema, feature flags, pro
66

77
## Architecture
88

9+
```mermaid
10+
graph TD
11+
App["Your NestJS App"]
12+
13+
App --> Prisma["PrismaModule<br/><code>@bbv/nestjs-prisma</code>"]
14+
App --> Pagination["PaginationDto, paginate()<br/><code>@bbv/nestjs-pagination</code>"]
15+
App --> Response["TransformInterceptor, Filter<br/><code>@bbv/nestjs-response</code>"]
16+
17+
Prisma --> Auth["AuthModule<br/><code>@bbv/nestjs-auth</code>"]
18+
Prisma --> Notifications["NotificationModule<br/><code>@bbv/nestjs-notifications</code>"]
19+
Prisma --> Storage["StorageModule<br/><code>@bbv/nestjs-storage</code>"]
20+
Prisma --> AuditLog["AuditLogModule<br/><code>@bbv/nestjs-audit-log</code>"]
21+
22+
style Prisma fill:#e3f2fd,stroke:#1565c0
23+
style Auth fill:#fce4ec,stroke:#c62828
24+
style Notifications fill:#fce4ec,stroke:#c62828
25+
style Storage fill:#fce4ec,stroke:#c62828
26+
style AuditLog fill:#fce4ec,stroke:#c62828
27+
style Pagination fill:#f3e5f5,stroke:#6a1b9a
28+
style Response fill:#f3e5f5,stroke:#6a1b9a
929
```
10-
Your NestJS App
11-
|
12-
+-- PrismaModule (@bbv/nestjs-prisma) <-- foundation, all plugins depend on this
13-
| |
14-
| +-- AuthModule (@bbv/nestjs-auth) Tier 1 plugin
15-
| +-- NotificationModule (@bbv/nestjs-notifications) Tier 1 plugin
16-
| +-- StorageModule (@bbv/nestjs-storage) Tier 1 plugin
17-
| +-- AuditLogModule (@bbv/nestjs-audit-log) Tier 1 plugin
18-
|
19-
+-- PaginationDto, paginate() (@bbv/nestjs-pagination) Tier 2 utility
20-
+-- TransformInterceptor, Filter (@bbv/nestjs-response) Tier 2 utility
21-
```
30+
31+
> **Blue** = Foundation &nbsp;|&nbsp; **Red** = Tier 1 Plugin Modules &nbsp;|&nbsp; **Purple** = Tier 2 Utilities
2232
2333
## Packages
2434

packages/nestjs-audit-log/README.md

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -206,22 +206,38 @@ When `features.registerController` is enabled:
206206

207207
## Architecture
208208

209-
```
210-
AuditLogModule (global)
211-
forRoot() / forRootAsync()
212-
|
213-
+-- AuditContextMiddleware -- captures userId, IP, UA via AsyncLocalStorage
214-
| (applied to all routes)
215-
|
216-
+-- createAuditMiddleware() -- Prisma $use middleware for auto CRUD tracking
217-
| +-- excludes configured entities/fields
218-
| +-- sanitizes sensitive data ([REDACTED])
219-
| +-- tracks old/new values on updates
220-
|
221-
+-- @Audited() decorator -- route-level audit via AuditedInterceptor
222-
|
223-
+-- AuditLogService -- log(), findAll(), findByEntity(), cleanup()
224-
+-- AuditLogController -- opt-in REST API for querying logs
209+
```mermaid
210+
graph TD
211+
Module["AuditLogModule (global)<br/>forRoot() / forRootAsync()"]
212+
213+
CtxMW["AuditContextMiddleware<br/>captures userId, IP, UA<br/>via AsyncLocalStorage"]
214+
PrismaMW["createAuditMiddleware()<br/>Prisma $use for auto CRUD"]
215+
Decorator["@Audited() decorator<br/>route-level audit via<br/>AuditedInterceptor"]
216+
Service["AuditLogService<br/>log(), findAll(), findByEntity(), cleanup()"]
217+
Controller["AuditLogController<br/>/audit-logs<br/><i>opt-in</i>"]
218+
219+
Module --> CtxMW
220+
Module --> PrismaMW
221+
Module --> Decorator
222+
Module --> Service
223+
Module --> Controller
224+
225+
CtxMW -->|"provides context"| PrismaMW
226+
CtxMW -->|"provides context"| Decorator
227+
PrismaMW -->|"writes entries"| Service
228+
Decorator -->|"writes entries"| Service
229+
Controller -->|"queries"| Service
230+
231+
PrismaMW -.-> Exclude["Exclude entities/fields"]
232+
PrismaMW -.-> Sanitize["Sanitize sensitive data"]
233+
PrismaMW -.-> Changes["Track old/new values"]
234+
235+
style Module fill:#e3f2fd,stroke:#1565c0
236+
style Service fill:#fff3e0,stroke:#e65100
237+
style Controller fill:#e8f5e9,stroke:#2e7d32
238+
style CtxMW fill:#fce4ec,stroke:#c62828
239+
style PrismaMW fill:#fce4ec,stroke:#c62828
240+
style Decorator fill:#f3e5f5,stroke:#6a1b9a
225241
```
226242

227243
## License

packages/nestjs-auth/README.md

Lines changed: 41 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -266,22 +266,47 @@ providers: {
266266

267267
## Architecture
268268

269-
```
270-
AuthModule
271-
forRoot() / forRootAsync()
272-
|
273-
+-- AuthController (/auth) -- registration, login, social, verify, reset, profile, sessions
274-
+-- OrganizationController (/organizations) -- CRUD + membership (feature-gated)
275-
|
276-
+-- AuthService -- business logic, token generation, user management
277-
+-- OrganizationService -- org CRUD, member management
278-
|
279-
+-- JwtStrategy -- Passport JWT validation
280-
+-- LocalStrategy -- Passport email/password validation
281-
+-- GoogleStrategy -- Passport Google OAuth (conditionally registered)
282-
|
283-
+-- JwtAuthGuard -- route protection, @Public() support
284-
+-- RolesGuard -- @Roles() enforcement
269+
```mermaid
270+
graph TD
271+
Module["AuthModule<br/>forRoot() / forRootAsync()"]
272+
273+
subgraph Controllers
274+
AuthCtrl["AuthController<br/>/auth"]
275+
OrgCtrl["OrganizationController<br/>/organizations"]
276+
end
277+
278+
subgraph Services
279+
AuthSvc["AuthService<br/>business logic, tokens, users"]
280+
OrgSvc["OrganizationService<br/>org CRUD, members"]
281+
end
282+
283+
subgraph Strategies ["Passport Strategies"]
284+
JWT["JwtStrategy"]
285+
Local["LocalStrategy"]
286+
Google["GoogleStrategy<br/><i>conditional</i>"]
287+
end
288+
289+
subgraph Guards
290+
JwtGuard["JwtAuthGuard<br/>@Public() support"]
291+
RolesGuard["RolesGuard<br/>@Roles() enforcement"]
292+
end
293+
294+
Module --> Controllers
295+
Module --> Services
296+
Module --> Strategies
297+
Module --> Guards
298+
299+
AuthCtrl --> AuthSvc
300+
OrgCtrl --> OrgSvc
301+
AuthSvc --> JWT
302+
AuthSvc --> Local
303+
AuthSvc --> Google
304+
305+
style Module fill:#e3f2fd,stroke:#1565c0
306+
style AuthCtrl fill:#e8f5e9,stroke:#2e7d32
307+
style OrgCtrl fill:#e8f5e9,stroke:#2e7d32
308+
style AuthSvc fill:#fff3e0,stroke:#e65100
309+
style OrgSvc fill:#fff3e0,stroke:#e65100
285310
```
286311

287312
## License

packages/nestjs-notifications/README.md

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -266,30 +266,38 @@ Preferences are checked automatically before sending. If a user has disabled a c
266266

267267
## Architecture
268268

269-
```
270-
NotificationModule
271-
forRoot() / forRootAsync()
272-
|
273-
+-- NotificationService -- unified send() API, routes to channels
274-
| |
275-
| +-- routeEmail() -- queues to BullMQ 'notifications-email'
276-
| +-- routeInApp() -- delegates to InAppService
277-
| +-- routeSms() -- queues to BullMQ 'notifications-sms'
278-
|
279-
+-- EmailProcessor -- BullMQ worker, uses EMAIL_PROVIDER
280-
| +-- SmtpEmailProvider -- nodemailer
281-
| +-- SendGridEmailProvider -- SendGrid API
282-
|
283-
+-- SmsProcessor -- BullMQ worker, uses SMS_PROVIDER
284-
| +-- TwilioSmsProvider -- Twilio API
285-
|
286-
+-- InAppService -- direct Prisma writes (no queue)
287-
+-- InAppController -- REST API for in-app notifications
288-
|
289-
+-- PreferenceService -- user notification preferences
290-
+-- PreferenceController -- REST API for preferences
291-
|
292-
+-- TemplateService -- Handlebars template rendering + caching
269+
```mermaid
270+
graph TD
271+
Module["NotificationModule<br/>forRoot() / forRootAsync()"]
272+
NService["NotificationService<br/>unified send() API"]
273+
274+
Module --> NService
275+
Module --> Templates["TemplateService<br/>Handlebars + caching"]
276+
277+
NService -->|"channel: email"| EmailQ["BullMQ Queue<br/>notifications-email"]
278+
NService -->|"channel: in_app"| InApp["InAppService<br/>direct Prisma writes"]
279+
NService -->|"channel: sms"| SmsQ["BullMQ Queue<br/>notifications-sms"]
280+
281+
EmailQ --> EmailProc["EmailProcessor"]
282+
EmailProc --> SMTP["SmtpEmailProvider<br/>nodemailer"]
283+
EmailProc --> SendGrid["SendGridEmailProvider"]
284+
285+
SmsQ --> SmsProc["SmsProcessor"]
286+
SmsProc --> Twilio["TwilioSmsProvider"]
287+
288+
InApp --> InAppCtrl["InAppController<br/>/notifications"]
289+
290+
Module --> PrefSvc["PreferenceService"]
291+
PrefSvc --> PrefCtrl["PreferenceController<br/>/notification-preferences"]
292+
293+
style Module fill:#e3f2fd,stroke:#1565c0
294+
style NService fill:#fff3e0,stroke:#e65100
295+
style EmailQ fill:#fce4ec,stroke:#c62828
296+
style SmsQ fill:#fce4ec,stroke:#c62828
297+
style InApp fill:#e8f5e9,stroke:#2e7d32
298+
style SMTP fill:#f3e5f5,stroke:#6a1b9a
299+
style SendGrid fill:#f3e5f5,stroke:#6a1b9a
300+
style Twilio fill:#f3e5f5,stroke:#6a1b9a
293301
```
294302

295303
## License

packages/nestjs-prisma/README.md

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -174,16 +174,25 @@ describe('UserService', () => {
174174

175175
## Architecture
176176

177-
```
178-
PrismaModule
179-
forRoot() / forRootAsync() --> registers PrismaService as provider + export
180-
|
181-
PrismaService (extends PrismaClient)
182-
onModuleInit() --> $connect()
183-
onModuleDestroy() --> $disconnect()
184-
185-
softDeleteMiddleware() --> opt-in Prisma middleware
186-
createMockPrismaService() --> testing utility (Proxy-based)
177+
```mermaid
178+
graph TD
179+
Module["PrismaModule<br/>forRoot() / forRootAsync()"]
180+
Service["PrismaService<br/><i>extends PrismaClient</i>"]
181+
Init["onModuleInit() → $connect()"]
182+
Destroy["onModuleDestroy() → $disconnect()"]
183+
SoftDelete["softDeleteMiddleware()<br/>opt-in Prisma middleware"]
184+
Mock["createMockPrismaService()<br/>testing utility (Proxy-based)"]
185+
186+
Module -->|registers & exports| Service
187+
Service --> Init
188+
Service --> Destroy
189+
Module -.->|optional| SoftDelete
190+
Module -.->|testing| Mock
191+
192+
style Module fill:#e3f2fd,stroke:#1565c0
193+
style Service fill:#e3f2fd,stroke:#1565c0
194+
style SoftDelete fill:#fff3e0,stroke:#e65100
195+
style Mock fill:#f3e5f5,stroke:#6a1b9a
187196
```
188197

189198
## License

packages/nestjs-storage/README.md

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -223,22 +223,35 @@ When `features.registerController` is enabled:
223223

224224
## Architecture
225225

226-
```
227-
StorageModule
228-
forRoot() / forRootAsync()
229-
|
230-
+-- StorageController (/storage) -- opt-in REST endpoints
231-
|
232-
+-- StorageService -- upload, getUrl, delete, exists
233-
| +-- validates file (size, MIME type)
234-
| +-- delegates to StorageProvider
235-
| +-- tracks in Prisma (if trackUploads)
236-
|
237-
+-- StorageProvider (interface)
238-
+-- S3StorageProvider -- AWS SDK v3
239-
+-- FirebaseStorageProvider
240-
+-- DOSpacesStorageProvider
241-
+-- LocalStorageProvider -- filesystem
226+
```mermaid
227+
graph TD
228+
Module["StorageModule<br/>forRoot() / forRootAsync()"]
229+
Controller["StorageController<br/>/storage<br/><i>opt-in</i>"]
230+
Service["StorageService<br/>upload, getUrl, delete, exists"]
231+
Validate["Validate file<br/>size & MIME type"]
232+
Track["Track in Prisma<br/><i>if trackUploads</i>"]
233+
234+
Module --> Controller
235+
Module --> Service
236+
237+
Service --> Validate
238+
Service --> Provider
239+
Service -.-> Track
240+
241+
subgraph Provider ["StorageProvider (interface)"]
242+
S3["S3StorageProvider<br/>AWS SDK v3"]
243+
Firebase["FirebaseStorageProvider"]
244+
DO["DOSpacesStorageProvider"]
245+
Local["LocalStorageProvider<br/>filesystem"]
246+
end
247+
248+
style Module fill:#e3f2fd,stroke:#1565c0
249+
style Service fill:#fff3e0,stroke:#e65100
250+
style Controller fill:#e8f5e9,stroke:#2e7d32
251+
style S3 fill:#f3e5f5,stroke:#6a1b9a
252+
style Firebase fill:#f3e5f5,stroke:#6a1b9a
253+
style DO fill:#f3e5f5,stroke:#6a1b9a
254+
style Local fill:#f3e5f5,stroke:#6a1b9a
242255
```
243256

244257
## License

0 commit comments

Comments
 (0)