# eclipse-tractusx/portal-frontend-registration architecture

> Architecture diagram of the GitHub repository eclipse-tractusx/portal-frontend-registration, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/eclipse-tractusx/portal-frontend-registration
- Repository: https://github.com/eclipse-tractusx/portal-frontend-registration

## Overview

##### Project Type and Purpose
- This is a React + TypeScript single-page application (SPA) responsible for the “registration” sub-flow of the larger Portal system. It provides the UI for capturing company data, handling multi-step forms, file uploads, and integrating with backend APIs (Portal-Backend) and the IAM service for authentication/authorization.

##### Main Components
a. Presentation Layer (Client Browser / SPA)
- src/components: all React UI components (forms, steppers, drag-and-drop, snackbars, error pages).
- Routing/ProtectedRoute for guarded routes (src/helpers/authorisation/ProtectedRoute.tsx).
b. State Management Layer
- Redux Toolkit slices under src/state/features (application, applicationCompanyRole, applicationDocuments, etc.) – each slice handles a domain.
- Global store in src/state/features/store.ts.
- Utility wrappers in src/state/utils (rtkUtil.ts).
c. Service Layer (API Wrappers & Utilities)
- RequestService.ts: central HTTP client for REST calls.
- UserService.js: IAM interactions (login, token refresh).
- EnvironmentService.ts: runtime configuration (injected via Docker/Nginx).
- I18nService.ts: locale loading (src/locales).
d. Data & Assets
- src/locales: JSON translations for EN/DE.
- src/styles: CSS assets and fonts.
e. External Systems
- Portal-Backend: REST API endpoints for registration flows.
- IAM Service (Portal-IAM): authentication, user info.
f. Build & Deployment
- Vite dev server (vite.config.ts) for local dev.
- Dockerfiles under .conf/ and Nginx config for production container.
- CI/CD workflows (.github/workflows).

##### Component Relationships & Data Flows
- End user (browser) loads SPA → Nginx (or Vite dev server) serves static assets.
- UI components dispatch Redux actions → RTK Query (applicationApiSlice, etc.) uses RequestService to call Portal-Backend REST endpoints.
- For protected routes, ProtectedRoute checks auth state via UserService against IAM.
- EnvironmentService supplies API base URLs & feature flags injected at build/runtime.
- I18nService fetches locale files; UI chooses text accordingly.
- File upload components post documents via applicationDocumentsApiSlice to backend storage endpoints.
- Global state updates reflect in UI; errors propagate to ErrorPage or Snackbar.

##### Architectural Patterns & Principles
- SPA with clear separation: Presentation vs State vs Data Access
- Component-based UI (React)
- Redux Toolkit (RTK Query) for declarative data fetching
- ProtectedRoute pattern for auth guards
- Environment injection via Docker/Nginx for 12-factor compliance
- Localization via JSON assets

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client Browser Layer
    subgraph "Client Browser (UI)" 
        direction TB
        UIComponents["React Components"]:::frontend
        ProtectedRoute["ProtectedRoute"]:::frontend
    end

    %% State Management Layer
    subgraph "State Management (Redux)" 
        direction TB
        Store["Redux Store"]:::state
        ApplicationSlice["applicationApiSlice"]:::state
        CompanyRoleSlice["applicationCompanyRoleApiSlice"]:::state
        DocumentsSlice["applicationDocumentsApiSlice"]:::state
        InviteUserSlice["applicationInviteUserApiSlice"]:::state
        VerifyRegisterSlice["applicationVerifyRegisterApiSlice"]:::state
        UserSlice["userApiSlice"]:::state
        RtkUtil["rtkUtil"]:::state
    end

    %% Service Layer
    subgraph "Service Layer (API & Utilities)" 
        direction TB
        RequestService["RequestService"]:::service
        UserService["UserService"]:::service
        EnvService["EnvironmentService"]:::service
        I18nService["I18nService"]:::service
    end

    %% External Systems
    subgraph "External APIs" 
        direction TB
        PortalBackend["Portal-Backend (REST API)"]:::external
        IAMService["Portal-IAM Service"]:::external
    end

    %% Static Asset Server
    subgraph "Static Asset Hosting" 
        direction TB
        ViteServer["Vite Dev Server"]:::infra
        NginxContainer["Nginx Docker"]:::infra
        StaticAssets["public/ & src/assets"]:::infra
    end

    %% Build & Deployment
    subgraph "Build & Deployment" 
        direction TB
        DockerFull["Dockerfile.full"]:::infra
        DockerPre["Dockerfile.prebuilt"]:::infra
        NginxConf["nginx.conf"]:::infra
        CICD["CI/CD Workflows"]:::infra
    end

    %% Connections
    UIComponents -->|dispatch actions| Store
    ProtectedRoute -->|auth guard| UserService
    Store -->|uses slices| ApplicationSlice
    Store --> CompanyRoleSlice
    Store --> DocumentsSlice
    Store --> InviteUserSlice
    Store --> VerifyRegisterSlice
    Store --> UserSlice
    Store --> RtkUtil

    ApplicationSlice -->|HTTP calls| RequestService
    CompanyRoleSlice --> RequestService
    DocumentsSlice --> RequestService
    InviteUserSlice --> RequestService
    VerifyRegisterSlice --> RequestService
    UserSlice --> RequestService

    RequestService -->|GET/POST| PortalBackend
    UserService -->|OIDC/OpenID| IAMService
    EnvService -->|config injection| NginxContainer
    I18nService -->|load JSON| StaticAssets

    staticServerArrow1[ViteServer serves SPA] --> UIComponents
    staticServerArrow2[NginxContainer serves built assets] --> UIComponents

    DockerFull --> NginxContainer
    DockerPre --> NginxContainer
    NginxConf --> NginxContainer
    CICD --> DockerFull
    CICD --> DockerPre

    %% Click Events
    click UIComponents "https://github.com/eclipse-tractusx/portal-frontend-registration/tree/main/src/components"
    click ProtectedRoute "https://github.com/eclipse-tractusx/portal-frontend-registration/blob/main/src/helpers/authorisation/ProtectedRoute.tsx"
    click Store "https://github.com/eclipse-tractusx/portal-frontend-registration/blob/main/src/state/features/store.ts"
    click ApplicationSlice "https://github.com/eclipse-tractusx/portal-frontend-registration/blob/main/src/state/features/application/applicationApiSlice.ts"
    click CompanyRoleSlice "https://github.com/eclipse-tractusx/portal-frontend-registration/blob/main/src/state/features/applicationCompanyRole/applicationCompanyRoleApiSlice.ts"
    click DocumentsSlice "https://github.com/eclipse-tractusx/portal-frontend-registration/blob/main/src/state/features/applicationDocuments/applicationDocumentsApiSlice.ts"
    click InviteUserSlice "https://github.com/eclipse-tractusx/portal-frontend-registration/blob/main/src/state/features/applicationInviteUser/applicationInviteUserApiSlice.ts"
    click VerifyRegisterSlice "https://github.com/eclipse-tractusx/portal-frontend-registration/blob/main/src/state/features/applicationVerifyRegister/applicationVerifyRegisterApiSlice.ts"
    click UserSlice "https://github.com/eclipse-tractusx/portal-frontend-registration/blob/main/src/state/features/user/userApiSlice.ts"
    click RtkUtil "https://github.com/eclipse-tractusx/portal-frontend-registration/blob/main/src/state/utils/rtkUtil.ts"
    click RequestService "https://github.com/eclipse-tractusx/portal-frontend-registration/blob/main/src/services/RequestService.ts"
    click UserService "https://github.com/eclipse-tractusx/portal-frontend-registration/blob/main/src/services/UserService.js"
    click EnvService "https://github.com/eclipse-tractusx/portal-frontend-registration/blob/main/src/services/EnvironmentService.ts"
    click I18nService "https://github.com/eclipse-tractusx/portal-frontend-registration/blob/main/src/services/I18nService.ts"
    click StaticAssets "https://github.com/eclipse-tractusx/portal-frontend-registration/tree/main/public/"
    click ViteServer "https://github.com/eclipse-tractusx/portal-frontend-registration/blob/main/vite.config.ts"
    click DockerFull "https://github.com/eclipse-tractusx/portal-frontend-registration/blob/main/.conf/Dockerfile.full"
    click DockerPre "https://github.com/eclipse-tractusx/portal-frontend-registration/blob/main/.conf/Dockerfile.prebuilt"
    click NginxConf "https://github.com/eclipse-tractusx/portal-frontend-registration/blob/main/.conf/nginx.conf"
    click CICD "https://github.com/eclipse-tractusx/portal-frontend-registration/tree/main/.github/workflows/"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,color:#0366d6
    classDef state fill:#E6F7E6,stroke:#28A745,color:#155724
    classDef service fill:#FFF4E6,stroke:#FF8C00,color:#663C00
    classDef external fill:#F0F0F0,stroke:#6C757D,color:#343A40
    classDef infra fill:#F8F9FA,stroke:#6C757D,color:#495057
```
