|
| 1 | +# Architecture Diagram |
| 2 | + |
| 3 | +```mermaid |
| 4 | +graph TB |
| 5 | + Client[Client App] -->|HTTP/WS| Gateway[NestJS Gateway] |
| 6 | +
|
| 7 | + Gateway --> Auth[Auth Module] |
| 8 | + Gateway --> Users[Users Module] |
| 9 | + Gateway --> Properties[Properties Module] |
| 10 | + Gateway --> Transactions[Transactions Module] |
| 11 | + Gateway --> Documents[Documents Module] |
| 12 | + Gateway --> Search[Search Module] |
| 13 | + Gateway --> Admin[Admin Module] |
| 14 | + Gateway --> Fraud[Fraud Module] |
| 15 | + Gateway --> Notifications[Notifications Module] |
| 16 | +
|
| 17 | + Auth --> JWT[JWT Strategy] |
| 18 | + Auth --> Google[Google OAuth] |
| 19 | + Auth --> MFA[2FA / TOTP] |
| 20 | + Auth --> RateLimit[Rate Limit Guard] |
| 21 | + Auth --> APIKeys[API Key Management] |
| 22 | +
|
| 23 | + Users --> Prisma[(Prisma Client)] |
| 24 | + Properties --> Prisma |
| 25 | + Transactions --> Prisma |
| 26 | + Documents --> Prisma |
| 27 | + Search --> Prisma |
| 28 | + Admin --> Prisma |
| 29 | + Fraud --> Prisma |
| 30 | +
|
| 31 | + Prisma --> PostgreSQL[(PostgreSQL)] |
| 32 | +
|
| 33 | + Properties --> Blockchain[Blockchain Service] |
| 34 | + Blockchain --> Ethereum[Ethereum / Sepolia] |
| 35 | +
|
| 36 | + Documents --> Uploads[File Uploads] |
| 37 | + Uploads --> LocalFS[Local FS / S3] |
| 38 | +
|
| 39 | + Notifications --> WebSocket[WebSocket Gateway] |
| 40 | + Notifications --> Email[Email Service] |
| 41 | + Notifications --> SMS[SMS Service] |
| 42 | +
|
| 43 | + Fraud --> Email |
| 44 | + Admin --> Backup[Backup Service] |
| 45 | + Backup --> PgDump[pg_dump] |
| 46 | +
|
| 47 | + Search --> Cache[(Redis Cache)] |
| 48 | + RateLimit --> Cache |
| 49 | + Cache --> CacheWarming[Cache Warming] |
| 50 | +
|
| 51 | + Admin --> BullMQ[BullMQ Queues] |
| 52 | + Transactions --> BullMQ |
| 53 | +
|
| 54 | + Gateway --> GraphQL[GraphQL / Apollo] |
| 55 | +``` |
| 56 | + |
| 57 | +## Request Flow |
| 58 | + |
| 59 | +```mermaid |
| 60 | +sequenceDiagram |
| 61 | + participant C as Client |
| 62 | + participant G as NestJS Gateway |
| 63 | + participant RL as Rate Limit Guard |
| 64 | + participant AU as Auth Service |
| 65 | + participant S as Feature Service |
| 66 | + participant DB as PostgreSQL |
| 67 | + participant BC as Blockchain |
| 68 | +
|
| 69 | + C->>G: HTTP Request |
| 70 | + G->>RL: canActivate() |
| 71 | + RL->>RL: Check Redis counters |
| 72 | + alt Rate limit exceeded |
| 73 | + RL-->>C: 429 Too Many Requests |
| 74 | + else Within limits |
| 75 | + RL->>G: Allow |
| 76 | + G->>AU: Validate JWT |
| 77 | + AU->>AU: Verify token + roles |
| 78 | + AU->>G: Authenticated context |
| 79 | + G->>S: Handle request |
| 80 | + S->>DB: Query/Mutate |
| 81 | + DB-->>S: Result |
| 82 | + alt Blockchain required |
| 83 | + S->>BC: Record transaction |
| 84 | + BC-->>S: Tx hash |
| 85 | + end |
| 86 | + S-->>C: Response |
| 87 | + end |
| 88 | +``` |
| 89 | + |
| 90 | +## Module Relationships |
| 91 | + |
| 92 | +| Module | Depends On | Provides | |
| 93 | +|--------|-----------|----------| |
| 94 | +| Auth | Users, JWT, Redis | Authentication, 2FA, API keys | |
| 95 | +| Users | Prisma | User CRUD, profiles | |
| 96 | +| Properties | Prisma, Blockchain, Geocoding | Property listings, images | |
| 97 | +| Transactions | Prisma, Blockchain | Transaction lifecycle | |
| 98 | +| Documents | Prisma, Uploads | Document management, signing | |
| 99 | +| Search | Prisma, Redis | Full-text search, facets, autocomplete | |
| 100 | +| Fraud | Prisma, Email | Fraud detection, alerts, auto-block | |
| 101 | +| Admin | Prisma, Backup, BullMQ | Admin ops, backups, reports | |
| 102 | +| Notifications | WebSocket, Email, SMS | Real-time + async notifications | |
0 commit comments