# ogticrd/cuenta-unica-registry architecture

> Architecture diagram of the GitHub repository ogticrd/cuenta-unica-registry, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ogticrd/cuenta-unica-registry
- Repository: https://github.com/ogticrd/cuenta-unica-registry

## Overview

##### Main Components

a. Client-Side Layer:
- Next.js Frontend (src/app/[lang]/)
- Material UI Components (src/components/)
- Client-side Actions (src/actions/)
- Internationalization System (src/dictionaries/)

b. Server-Side Layer:
- Next.js API Routes (src/app/api/)
- Authentication & Authorization
- Middleware Layer (src/middlewares/)

c. External Services Integration:
- Ory Kratos (IAM)
- Amazon Rekognition Face Liveness
- reCAPTCHA Enterprise
- JCE API (Citizen Identity Verification)
- X-Road Integration
- Email Service

d. Infrastructure Layer:
- Google Cloud Platform
- Docker Containerization
- CI/CD Pipeline (GitHub Actions)

**┌─ Client Layer ─────────────────────────────┐**
- Next.js Pages                            │
- Material UI Components                   │
- Client-side Actions                      │
- i18n Support                             │
- ┬───────────────────────┘
- ↓
**┌─ Server Layer ────────────────────────────┐**
- API Routes                              │
- Server Actions                          │
- Middleware                              │
- ┬───────────────────────┘
- ↓
**┌─ External Services ─────────────────────────┐**
- Ory Kratos (IAM)                         │
- Amazon Rekognition                       │
- reCAPTCHA Enterprise                     │
- JCE API                                  │
- ┘

##### Flow Representation

- Identity Verification Flow (Blue)
- Liveness Detection Flow (Green)
- Account Creation Flow (Orange)
- Authentication Flow (Purple)

##### Key Elements to Highlight

a. Security Components:
- reCAPTCHA Integration
- Password Validation (NIST 800-63B)
- Biometric Verification

b. Integration Points:
- External API Connections
- Identity Management System
- Cloud Services

c. Infrastructure Components:
- Docker Containers
- Cloud Run Services
- CI/CD Pipeline

##### Specific Implementation Details

Technical annotations for:
- TypeScript Implementation
- Next.js Server Components
- Material UI Theming
- Internationalization Support
- Environment Configurations

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Layer"]
        direction TB
        Pages["Next.js Pages"]:::frontend
        UI["Material UI Components"]:::frontend
        ClientActions["Client Actions"]:::frontend
        i18n["i18n Support"]:::frontend
        Theme["Theme Configuration"]:::frontend
    end

    subgraph Server["Server Layer"]
        direction TB
        API["API Routes"]:::backend
        ServerActions["Server Actions"]:::backend
        Middleware["Middleware"]:::backend
        i18nMiddleware["i18n Middleware"]:::backend
    end

    subgraph External["External Services"]
        direction TB
        Ory["Ory Kratos IAM"]:::external
        Rekognition["Amazon Rekognition"]:::external
        ReCaptcha["reCAPTCHA Enterprise"]:::external
        JCE["JCE API"]:::external
        XRoad["X-Road"]:::external
        Email["Email Service"]:::external
    end

    subgraph Core["Core Features"]
        direction TB
        IdVerification["Identity Verification"]:::feature
        LivenessDetection["Liveness Detection"]:::feature
        Registration["Registration System"]:::feature
        AccountCreation["Account Creation"]:::feature
    end

    subgraph Security["Security Layer"]
        direction TB
        Validation["Validation Schemas"]:::security
        PasswordSecurity["Password Security"]:::security
        BiometricAPI["Biometric API"]:::security
    end

    Client --> Server
    Server --> External
    Server --> Core
    Server --> Security

    classDef frontend fill:#3498db,stroke:#2980b9,color:#fff
    classDef backend fill:#2ecc71,stroke:#27ae60,color:#fff
    classDef external fill:#e74c3c,stroke:#c0392b,color:#fff
    classDef feature fill:#9b59b6,stroke:#8e44ad,color:#fff
    classDef security fill:#f1c40f,stroke:#f39c12,color:#000

    click Pages "https://github.com/ogticrd/cuenta-unica-registry/tree/master/src/app/[lang]/"
    click UI "https://github.com/ogticrd/cuenta-unica-registry/tree/master/src/components/"
    click Theme "https://github.com/ogticrd/cuenta-unica-registry/tree/master/src/components/themes/"
    click ClientActions "https://github.com/ogticrd/cuenta-unica-registry/tree/master/src/actions/"
    click API "https://github.com/ogticrd/cuenta-unica-registry/tree/master/src/app/api/"
    click Middleware "https://github.com/ogticrd/cuenta-unica-registry/blob/master/src/middleware.ts"
    click i18nMiddleware "https://github.com/ogticrd/cuenta-unica-registry/blob/master/src/middlewares/i18n.middleware.ts"
    click Ory "https://github.com/ogticrd/cuenta-unica-registry/blob/master/src/common/lib/ory.ts"
    click Rekognition "https://github.com/ogticrd/cuenta-unica-registry/blob/master/src/common/helpers/rekognition.ts"
    click BiometricAPI "https://github.com/ogticrd/cuenta-unica-registry/tree/master/src/app/api/biometric/"
    click IdVerification "https://github.com/ogticrd/cuenta-unica-registry/tree/master/src/app/[lang]/identification/"
    click LivenessDetection "https://github.com/ogticrd/cuenta-unica-registry/tree/master/src/app/[lang]/liveness/"
    click Registration "https://github.com/ogticrd/cuenta-unica-registry/tree/master/src/app/[lang]/register/"
    click AccountCreation "https://github.com/ogticrd/cuenta-unica-registry/tree/master/src/app/[lang]/account-created/"
    click Validation "https://github.com/ogticrd/cuenta-unica-registry/tree/master/src/common/validation-schemas/"
    click PasswordSecurity "https://github.com/ogticrd/cuenta-unica-registry/blob/master/src/actions/pwned.action.ts"
    click i18n "https://github.com/ogticrd/cuenta-unica-registry/tree/master/src/dictionaries/"
```
