# oopman64bit/vc_wallet_hometask architecture

> Architecture diagram of the GitHub repository oopman64bit/vc_wallet_hometask, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/oopman64bit/vc_wallet_hometask
- Repository: https://github.com/oopman64bit/vc_wallet_hometask

## Overview

##### Project type and purpose
- Full-stack application for issuing, storing, sharing, and verifying RSA-signed verifiable credentials.
- Frontend: React SPA on port 3000 (or 80 in Docker).
- Backend: NestJS API on port 3001, file-based storage, Swagger docs at `/api`.

##### Main components
A. Client Layer
1. Browser / React SPA
– Components: IssueCredentialForm, VerifyModal, ShareModal, CredentialCard, Toast, etc.
– Axios-based `api.ts` service with correlation IDs.
B. API Layer
2. NestJS Backend
– Controllers:
- CredentialsController (`POST /api/v1/credentials`, `GET /api/v1/credentials`, `POST /api/v1/credentials/verify`)
- HealthController (`GET /api/v1/health`)
– Modules: CredentialsModule, HealthModule, AppModule
– Services:
- CredentialsService (orchestrates issue/verify flows)
- CryptoService (RSA signing/verifying)
- StorageService (reads/writes `data/credentials.json`)
– Common utilities:
- LoggingInterceptor (Winston logger)
- TransformInterceptor, HttpExceptionFilter, BusinessException
- Configuration (+ `.env` support via `configuration.ts`)
C. Data Layer
3. File-based storage
– `data/credentials.json` (mounted via Docker volume or local `backend/data/`)
D. Infrastructure & DevOps
4. Docker & Docker‐Compose
– Multi‐stage Dockerfile for backend
– `docker-compose.yml` orchestrates backend container (exposes 3001:3001)
5. Swagger UI (hosted at `/api`)
6. Jest Tests
– Unit tests under `src/…/*.spec.ts`
– E2E tests under `test/credentials.e2e-spec.ts`

##### Relationships & data flow
- Backend Controllers route requests into Services and common layers.
- CredentialsService calls CryptoService for signing/verifying, then StorageService to persist or retrieve JSON.
- LoggingInterceptor and ExceptionFilter intercept all requests/responses (cross-cutting).
- HealthController pings HealthService (e.g., always returns “ok”).
- Swagger module introspects Controllers and exposes OpenAPI UI.

##### Architectural patterns & design principles
- Layered architecture (Controllers → Services → Data).
- Module-based organization (NestJS modules).
- Cross-cutting concerns handled via interceptors/filters (logging, error handling, transformations).
- File‐based persistence (simple JSON store, placed in a dedicated data volume).
- Separation of concerns: frontend UI vs. backend API vs. storage.

– Ports, protocols, and data stores are annotated.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Layer
    subgraph "Client Layer"
        direction TB
        SPA["React SPA<br/>(App.tsx, index.tsx)"]:::frontend
        IssueForm["IssueCredentialForm"]:::frontend
        VerifyModal["VerifyModal"]:::frontend
        ShareModal["ShareModal"]:::frontend
        CredCard["CredentialCard"]:::frontend
        ToastComp["Toast"]:::frontend
        APIService["api.ts<br/>(Axios Service)"]:::frontend
    end

    %% API Layer
    subgraph "API Layer"
        direction TB
        Main["main.ts"]:::backend
        AppMod["AppModule"]:::backend
        subgraph "CredentialsModule"
            direction TB
            CredCtrl["CredentialsController"]:::backend
            CredServ["CredentialsService"]:::backend
            CryptoServ["CryptoService"]:::backend
            StorageServ["StorageService"]:::backend
        end
        subgraph "HealthModule"
            direction TB
            HealthCtrl["HealthController"]:::backend
            HealthServ["HealthService"]:::backend
        end
        Swagger["Swagger UI<br/>(OpenAPI)"]:::backend
        subgraph "Common Utilities"
            direction TB
            LogInt["LoggingInterceptor"]:::backend
            TransInt["TransformInterceptor"]:::backend
            ExFilter["HttpExceptionFilter"]:::backend
            BizEx["BusinessException"]:::backend
        end
        Config["configuration.ts"]:::backend
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        FileStore["data/credentials.json"]:::storage
    end

    %% Infrastructure Layer
    subgraph "Infrastructure"
        direction TB
        Dockerfile["Dockerfile (Backend)"]:::infra
        Compose["docker-compose.yml"]:::infra
        UnitTests["CredentialsService.spec.ts"]:::infra
        E2ETests["credentials.e2e-spec.ts"]:::infra
    end

    %% Connections
    SPA -->|"HTTP 3000→3001"| APIService
    SPA --> IssueForm
    SPA --> VerifyModal
    SPA --> ShareModal
    SPA --> CredCard
    SPA --> ToastComp

    APIService -->|"REST API"| CredCtrl
    APIService -->|"REST API"| HealthCtrl

    CredCtrl -->|"calls"| CredServ
    CredCtrl -->|"calls"| CryptoServ
    CredServ -->|"uses"| CryptoServ
    CredServ -->|"persists"| StorageServ
    HealthCtrl -->|"calls"| HealthServ

    LogInt -.-> CredCtrl
    LogInt -.-> HealthCtrl
    ExFilter -.-> CredCtrl
    ExFilter -.-> HealthCtrl
    TransInt -.-> CredCtrl
    TransInt -.-> HealthCtrl

    StorageServ -->|"reads/writes"| FileStore

    Main --> AppMod
    Main --> Swagger
    AppMod --> CredCtrl
    AppMod --> HealthCtrl
    AppMod --> Config

    Dockerfile --> Compose
    FileStore --> Compose
    Main --> Dockerfile

    UnitTests --> CredServ
    E2ETests --> CredCtrl

    %% Click Events
    click SPA "https://github.com/oopman64bit/vc_wallet_hometask/blob/main/frontend/src/App.tsx"
    click SPA "https://github.com/oopman64bit/vc_wallet_hometask/blob/main/frontend/src/index.tsx"
    click IssueForm "https://github.com/oopman64bit/vc_wallet_hometask/blob/main/frontend/src/components/IssueCredentialForm.tsx"
    click VerifyModal "https://github.com/oopman64bit/vc_wallet_hometask/blob/main/frontend/src/components/VerifyModal.tsx"
    click ShareModal "https://github.com/oopman64bit/vc_wallet_hometask/blob/main/frontend/src/components/ShareModal.tsx"
    click CredCard "https://github.com/oopman64bit/vc_wallet_hometask/blob/main/frontend/src/components/CredentialCard.tsx"
    click ToastComp "https://github.com/oopman64bit/vc_wallet_hometask/blob/main/frontend/src/components/Toast.tsx"
    click APIService "https://github.com/oopman64bit/vc_wallet_hometask/blob/main/frontend/src/services/api.ts"
    click Main "https://github.com/oopman64bit/vc_wallet_hometask/blob/main/backend/src/main.ts"
    click AppMod "https://github.com/oopman64bit/vc_wallet_hometask/blob/main/backend/src/app.module.ts"
    click CredCtrl "https://github.com/oopman64bit/vc_wallet_hometask/blob/main/backend/src/credentials/credentials.controller.ts"
    click CredServ "https://github.com/oopman64bit/vc_wallet_hometask/blob/main/backend/src/credentials/services/credentials.service.ts"
    click CryptoServ "https://github.com/oopman64bit/vc_wallet_hometask/blob/main/backend/src/credentials/services/crypto.service.ts"
    click StorageServ "https://github.com/oopman64bit/vc_wallet_hometask/blob/main/backend/src/credentials/services/storage.service.ts"
    click HealthCtrl "https://github.com/oopman64bit/vc_wallet_hometask/blob/main/backend/src/health/health.controller.ts"
    click HealthServ "https://github.com/oopman64bit/vc_wallet_hometask/blob/main/backend/src/health/health.service.ts"
    click LogInt "https://github.com/oopman64bit/vc_wallet_hometask/blob/main/backend/src/common/interceptors/logging.interceptor.ts"
    click TransInt "https://github.com/oopman64bit/vc_wallet_hometask/blob/main/backend/src/common/interceptors/transform.interceptor.ts"
    click ExFilter "https://github.com/oopman64bit/vc_wallet_hometask/blob/main/backend/src/common/filters/http-exception.filter.ts"
    click BizEx "https://github.com/oopman64bit/vc_wallet_hometask/blob/main/backend/src/common/exceptions/business.exception.ts"
    click Config "https://github.com/oopman64bit/vc_wallet_hometask/blob/main/backend/src/config/configuration.ts"
    click FileStore "https://github.com/oopman64bit/vc_wallet_hometask/blob/main/data/credentials.json"
    click Dockerfile "https://github.com/oopman64bit/vc_wallet_hometask/tree/main/backend/Dockerfile"
    click Compose "https://github.com/oopman64bit/vc_wallet_hometask/blob/main/docker-compose.yml"
    click UnitTests "https://github.com/oopman64bit/vc_wallet_hometask/blob/main/backend/src/credentials/services/credentials.service.spec.ts"
    click E2ETests "https://github.com/oopman64bit/vc_wallet_hometask/blob/main/backend/test/credentials.e2e-spec.ts"

    %% Styles
    classDef frontend fill:#cce5ff,stroke:#3399ff,color:#000
    classDef backend fill:#d4edda,stroke:#28a745,color:#000
    classDef storage fill:#ffe5b4,stroke:#ff8c00,color:#000
    classDef infra fill:#e2e3e5,stroke:#6c757d,color:#000
```
