System Architecture

Enterprise and Military Grade Identity Verification Platform

Comprehensive system design, database schemas, and infrastructure breakdown

Three-Level User Hierarchy

Level 3

System Admins

Platform Operators

  • Manage all tenants
  • Access all fraud cases
  • Platform-wide security
  • Package management
  • System metrics

Table: gg-profiles (userType: SYSTEM_ADMIN)

Level 2

Tenant Admins

Organization Administrators

  • Manage their tenant only
  • View tenant fraud cases
  • Create applications
  • Manage API keys
  • Configure features

Table: gg-profiles (userType: TENANT_ADMIN)

Level 1

External Users

End-Users (Widget)

  • Verified via widget
  • No dashboard access
  • 4-factor verification
  • Verification results only
  • Tenant-scoped access

Table: gg-external-profiles

Database Schema (DynamoDB)

gg-profiles (Internal Users)

Purpose: System Admins and Tenant Admins

Core Fields:
  • profileId (PK) - UUID
  • tenantId - Tenant association
  • email - User email
  • userType - SYSTEM_ADMIN | TENANT_ADMIN
  • firstName, lastName, mobile
  • verificationStatus - PENDING | VERIFIED | REJECTED
  • verifiedFactors[] - Array of completed factors
GSI Indexes:
  • TenantIndex: tenantId (PK)
  • EmailIndex: email (PK)
  • DocumentHashIndex: documentHash (PK)
  • MobileHashIndex: mobileHash (PK)
  • FaceHashIndex: faceHash (PK)
Biometric Data: Face images, document scans stored in S3. Only S3 keys stored in DynamoDB.
gg-external-profiles (External Users)

Purpose: End-users verified through widget

Core Fields:
  • externalProfileId (PK) - UUID
  • tenantId - Tenant isolation
  • email, mobile, fullName
  • verificationStatus
  • verifiedFactors[] - EMAIL, MOBILE, FACE, DOCUMENT
  • applicationAccess[] - Array of app permissions
  • sessionId - Links to widget session
GSI Indexes:
  • TenantIndex: tenantId (PK)
  • EmailIndex: email (PK)
  • DocumentHashIndex: documentHash (PK)
  • MobileHashIndex: mobileHash (PK)
  • FaceHashIndex: faceHash (PK)
Tenant Isolation: All queries filtered by tenantId + applicationId to prevent cross-tenant data leakage.
gg-tenants

Purpose: Tenant organizations

  • tenantId (PK)
  • tenantName, domain
  • settings (requiredFactors, fraudThreshold)
  • status (ACTIVE | SUSPENDED | DELETED)
gg-applications

Purpose: API keys per tenant

  • applicationId (PK)
  • tenantId, applicationName
  • publicKey, secretKey (hashed)
  • allowedOrigins[], webhookUrl
gg-fraud-cases

Purpose: Fraud detection cases

  • fraudCaseId (PK)
  • profileId | externalProfileId
  • detectionType (DOCUMENT | MOBILE | FACE)
  • status (PENDING | CONFIRMED | NOT_FRAUD)
gg-audit-logs

Purpose: Security audit trail

  • logId (PK)
  • eventType, userId, tenantId
  • ipAddress, userAgent
  • timestamp (GSI)

JWT Structure

Token Claims
{
  // Standard Claims
  "sub": "profileId or externalProfileId",
  "email": "user@example.com",
  "iat": 1234567890,
  "exp": 1234571490,
  
  // Custom Claims (CRITICAL)
  "custom:tenantId": "tenant-uuid",
  "custom:userType": "SYSTEM_ADMIN | TENANT_ADMIN | EXTERNAL_USER",
  "custom:verificationStatus": "VERIFIED"
}
Tenant Isolation
Validation Flow:
  1. API Gateway receives request with Authorization header
  2. Lambda authorizer validates JWT signature
  3. Extract tenantId from custom:tenantId claim
  4. Pass tenantId to Lambda via context
  5. Lambda enforces: jwt.tenantId === resource.tenantId
  6. Return 403 if mismatch
Security: Every Lambda function validates tenant isolation. No exceptions.

Infrastructure Stacks (SST v3)

AuthStack

Single Cognito User Pool

  • Custom JWT attributes
  • Password policy (12 chars min)
  • MFA optional
  • Deletion protection: ACTIVE
DatabaseStack

7 DynamoDB Tables

  • Pay-per-request billing
  • Point-in-time recovery
  • Deletion protection: true
  • Removal policy: RETAIN
StorageStack

3 Private S3 Buckets

  • Biometrics (face images)
  • Documents (ID scans)
  • Voiceprints (audio samples)
  • AES-256 encryption
ApiStack

API Gateway + 59 Lambdas

  • 47 API routes
  • JWT authorizer
  • CORS enabled
  • Rate limiting (50 req/s)
FraudStack

Async Fraud Detection

  • SQS queue + DLQ
  • Fraud Lambda (concurrency: 10)
  • CloudWatch alarm on DLQ
  • 3-strike system
EventStack

EventBridge Bus

  • 6 event rules
  • Webhook dispatcher
  • Email notifications
  • Audit logging

Data Flow Diagrams

Internal User Signup Flow
Dashboard
    ↓
Cognito (email verification)
    ↓
Lambda Signup
    ↓
DynamoDB Profiles
    ↓
SQS Fraud Queue
External User Widget Flow
Widget SDK
    ↓
API Gateway
    ↓
Lambda Widget
    ↓
DynamoDB External Profiles
    ↓
SQS Fraud Queue
Fraud Detection Flow
SQS Queue → Lambda Fraud → GSI Query (Hash Indexes) → Rekognition CompareFaces
                                                                              ↓
                                                                    Fraud Cases + Audit Logs