# interview-repo/vitasystems architecture

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

- Interactive diagram: https://gitdiagram.com/interview-repo/vitasystems
- Repository: https://github.com/interview-repo/vitasystems

## Overview

##### Project type and purpose
- This is a single-page front-end web application built with React, TypeScript, and Vite.
- Its purpose is to guide users through a multi-step form (budget selection, contact info, service selection, submit request, success confirmation) and to provide a tracking dashboard (login + project status tracking).
- It communicates with a remote backend via an HTTP API (see src/api/http-client.ts, auth-manager.ts).

##### File structure
- Top-level entries:
- public, index.html: static assets and app shell
- src: all application code
- src/api: API-layer (HTTP client, auth manager, types, endpoints)
- src/common/utils: shared utilities (formatDate, sleep, storage abstraction)
- src/components: generic UI components (navigation, progress bar)
- src/features: feature modules, each implementing a slice of UX
– form: multi-step form sub-directories per step
– tracking: dashboard and login sub-directories
- src/hooks: custom React hooks (multi-step form, tracking, copy to clipboard)
- Config & tooling:
– Vite (vite.config.ts) for dev/build
– ESLint (eslint.config.js)
– Tailwind CSS (tailwind.config.js)
– TypeScript configs (tsconfig.app.json, tsconfig.node.json)
– Vercel config for deployment

##### Key insights from README
- Project scaffold: React + TypeScript + Vite, with ESLint and optional plugins.
- No backend code shipped here—this repo only holds the front-end layer.

##### Main components
a. Client / UI Layer
– React app (entry point src/main.tsx → App.tsx)
– Presentation components under src/components & src/features
– State management via React hooks (useMultiStepForm, useTracking)
b. API Layer
– HTTP client (src/api/http-client.ts)
– Auth manager (src/api/auth-manager.ts) handling tokens, login/logout flows
– Constants / types defining contract with backend (src/api/constants.ts, types.ts)
c. Local Persistence
– storage util (src/common/utils/storage.ts) for caching tokens or form state
d. Build & Deployment
– Vite dev server → HMR → produces production bundle
– Vercel config (vercel.json) for CD
e. External Services
– Backend REST endpoints (authentication, form submission, tracking data)
– Optional third-party APIs (if any, not shown here)

##### Relationships and interactions
- User interacts with the React UI → triggers actions in feature modules → invoke hooks → calls API layer.
- HTTP client attaches auth token via auth-manager → sends requests to backend → receives JSON → mapping to types → UI updates.
- Local storage reads/writes tokens and form progress.

##### Architectural patterns and design principles
- Layered architecture: Presentation (components) → Business logic (feature modules + hooks) → API layer → Persistence / external
- “Feature-first” directory structure: keeps code for each feature (form, tracking) co-located.
- Separation of concerns: common utilities in one place; API concerns abstracted away from components.

##### Final recommendations
- Custom hooks as first-class elements to show where state and side effects live.
- Async flow: how auth-manager obtains/stores tokens and how http-client injects them.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Layers
    subgraph "UI Layer" 
        direction TB
        ReactApp["React App Entry Point\n(src/main.tsx)"]:::ui
        AppComponent["Root App Component\n(src/App.tsx)"]:::ui
        Navigation["Navigation Component"]:::ui
        ProgressBar["Progress Bar Component"]:::ui
        subgraph "Form Feature Components"
            direction TB
            FormEntry["Form Module Entry\n(src/features/form/index.tsx)"]:::ui
            BudgetSelection["Budget Selection Step"]:::ui
            ContactInfo["Contact Info Step"]:::ui
            ServiceSelection["Service Selection Step"]:::ui
            SubmitRequest["Submit Request Step"]:::ui
            SuccessConfirmation["Success Confirmation Step"]:::ui
        end
        subgraph "Tracking Feature Components"
            direction TB
            TrackingDashboard["Tracking Dashboard Entry\n(src/features/tracking/tracking-dashboard/index.tsx)"]:::ui
            TrackingLogin["Tracking Login Entry\n(src/features/tracking/tracking-login/index.tsx)"]:::ui
        end
    end

    subgraph "Business Logic / Hooks" 
        direction TB
        MultiStepHook["useMultiStepForm Hook"]:::hooks
        TrackingHook["useTracking Hook"]:::hooks
        ClipboardHook["useCopy Hook"]:::hooks
    end

    subgraph "API Layer" 
        direction TB
        HTTPClient["HTTP Client"]:::api
        AuthManager["Auth Manager"]:::api
        APIConstants["API Constants"]:::api
        APITypes["API Types"]:::api
        APIIndex["API Barrel Export"]:::api
    end

    subgraph "Persistence Layer" 
        direction TB
        StorageUtil["Local Storage Utility"]:::persistence
        DateUtil["Date Formatting Utility"]:::persistence
        SleepUtil["Sleep Utility"]:::persistence
    end

    subgraph "External Services" 
        direction TB
        BackendAPI["Backend REST API"]:::external
    end

    subgraph "Build & Deployment" 
        direction TB
        ViteConfig["Vite Config"]:::build
        VercelConfig["Vercel Deployment Config"]:::build
        TailwindConfig["Tailwind CSS Config"]:::build
        ESLintConfig["ESLint Config"]:::build
        TSAppConfig["TS App Config"]:::build
        TSNodeConfig["TS Node Config"]:::build
        HTMLTemplate["Root HTML Template"]:::build
    end

    %% Connections
    ReactApp --> AppComponent
    AppComponent --> Navigation
    AppComponent --> ProgressBar
    AppComponent --> FormEntry
    AppComponent --> TrackingDashboard
    AppComponent --> TrackingLogin

    FormEntry --> BudgetSelection
    FormEntry --> ContactInfo
    FormEntry --> ServiceSelection
    FormEntry --> SubmitRequest
    FormEntry --> SuccessConfirmation

    BudgetSelection --> MultiStepHook
    ContactInfo --> MultiStepHook
    ServiceSelection --> MultiStepHook
    SubmitRequest --> MultiStepHook
    SuccessConfirmation --> MultiStepHook

    TrackingDashboard --> TrackingHook
    TrackingLogin --> TrackingHook

    Navigation --> ClipboardHook

    MultiStepHook --> HTTPClient
    TrackingHook --> HTTPClient
    ClipboardHook --> StorageUtil

    HTTPClient --> AuthManager
    HTTPClient --> APIConstants
    HTTPClient --> APITypes
    HTTPClient --> StorageUtil

    AuthManager --> StorageUtil

    HTTPClient --> BackendAPI

    StorageUtil -->|reads/writes| BackendAPI

    ViteConfig --> ReactApp
    HTMLTemplate --> ReactApp
    TailwindConfig --> ReactApp
    ESLintConfig --> ReactApp
    TSAppConfig --> ReactApp
    TSNodeConfig --> ReactApp
    VercelConfig --> ReactApp

    %% Click Events
    click ReactApp "https://github.com/interview-repo/vitasystems/blob/main/src/main.tsx"
    click AppComponent "https://github.com/interview-repo/vitasystems/blob/main/src/App.tsx"
    click HTTPClient "https://github.com/interview-repo/vitasystems/blob/main/src/api/http-client.ts"
    click AuthManager "https://github.com/interview-repo/vitasystems/blob/main/src/api/auth-manager.ts"
    click APIConstants "https://github.com/interview-repo/vitasystems/blob/main/src/api/constants.ts"
    click APITypes "https://github.com/interview-repo/vitasystems/blob/main/src/api/types.ts"
    click APIIndex "https://github.com/interview-repo/vitasystems/blob/main/src/api/index.ts"
    click StorageUtil "https://github.com/interview-repo/vitasystems/blob/main/src/common/utils/storage.ts"
    click DateUtil "https://github.com/interview-repo/vitasystems/blob/main/src/common/utils/formatDate.ts"
    click SleepUtil "https://github.com/interview-repo/vitasystems/blob/main/src/common/utils/sleep.ts"
    click Navigation "https://github.com/interview-repo/vitasystems/blob/main/src/components/navigation.tsx"
    click ProgressBar "https://github.com/interview-repo/vitasystems/blob/main/src/components/progress-bar.tsx"
    click MultiStepHook "https://github.com/interview-repo/vitasystems/blob/main/src/hooks/useMultiStepForm.ts"
    click TrackingHook "https://github.com/interview-repo/vitasystems/blob/main/src/hooks/useTracking.ts"
    click ClipboardHook "https://github.com/interview-repo/vitasystems/blob/main/src/hooks/useCopy.ts"
    click FormEntry "https://github.com/interview-repo/vitasystems/blob/main/src/features/form/index.tsx"
    click TrackingDashboard "https://github.com/interview-repo/vitasystems/blob/main/src/features/tracking/tracking-dashboard/index.tsx"
    click TrackingLogin "https://github.com/interview-repo/vitasystems/blob/main/src/features/tracking/tracking-login/index.tsx"

    click BudgetSelection "https://github.com/interview-repo/vitasystems/blob/main/src/features/form/steps/budget-selection/index.tsx"
    click BudgetSelection "https://github.com/interview-repo/vitasystems/blob/main/src/features/form/steps/budget-selection/radio-group.tsx"
    click BudgetSelection "https://github.com/interview-repo/vitasystems/blob/main/src/features/form/steps/budget-selection/radio-indicator.tsx"
    click BudgetSelection "https://github.com/interview-repo/vitasystems/blob/main/src/features/form/steps/budget-selection/section.tsx"
    click BudgetSelection "https://github.com/interview-repo/vitasystems/blob/main/src/features/form/steps/budget-selection/types.ts"

    click ContactInfo "https://github.com/interview-repo/vitasystems/blob/main/src/features/form/steps/contact-info/index.tsx"
    click ContactInfo "https://github.com/interview-repo/vitasystems/blob/main/src/features/form/steps/contact-info/form-field.tsx"
    click ContactInfo "https://github.com/interview-repo/vitasystems/blob/main/src/features/form/steps/contact-info/form-input.tsx"
    click ContactInfo "https://github.com/interview-repo/vitasystems/blob/main/src/features/form/steps/contact-info/form-section.tsx"
    click ContactInfo "https://github.com/interview-repo/vitasystems/blob/main/src/features/form/steps/contact-info/icons.tsx"

    click ServiceSelection "https://github.com/interview-repo/vitasystems/blob/main/src/features/form/steps/service-selection/index.tsx"
    click ServiceSelection "https://github.com/interview-repo/vitasystems/blob/main/src/features/form/steps/service-selection/service-option.tsx"
    click ServiceSelection "https://github.com/interview-repo/vitasystems/blob/main/src/features/form/steps/service-selection/icons.tsx"

    click SubmitRequest "https://github.com/interview-repo/vitasystems/blob/main/src/features/form/steps/submit-request/index.tsx"
    click SubmitRequest "https://github.com/interview-repo/vitasystems/blob/main/src/features/form/steps/submit-request/button.tsx"
    click SubmitRequest "https://github.com/interview-repo/vitasystems/blob/main/src/features/form/steps/submit-request/badge.tsx"
    click SubmitRequest "https://github.com/interview-repo/vitasystems/blob/main/src/features/form/steps/submit-request/icons.tsx"

    click SuccessConfirmation "https://github.com/interview-repo/vitasystems/blob/main/src/features/form/steps/success-confirmation/index.tsx"
    click SuccessConfirmation "https://github.com/interview-repo/vitasystems/blob/main/src/features/form/steps/success-confirmation/icons.tsx"

    click ViteConfig "https://github.com/interview-repo/vitasystems/blob/main/vite.config.ts"
    click VercelConfig "https://github.com/interview-repo/vitasystems/blob/main/vercel.json"
    click TailwindConfig "https://github.com/interview-repo/vitasystems/blob/main/tailwind.config.js"
    click ESLintConfig "https://github.com/interview-repo/vitasystems/blob/main/eslint.config.js"
    click TSAppConfig "https://github.com/interview-repo/vitasystems/blob/main/tsconfig.app.json"
    click TSNodeConfig "https://github.com/interview-repo/vitasystems/blob/main/tsconfig.node.json"
    click HTMLTemplate "https://github.com/interview-repo/vitasystems/blob/main/index.html"

    %% Styles
    classDef ui fill:#D0E8FF,stroke:#0366d6,color:#0366d6
    classDef hooks fill:#DFFFD0,stroke:#6bb700,color:#6bb700
    classDef api fill:#FFE8D0,stroke:#d66300,color:#d66300
    classDef persistence fill:#F0D0FF,stroke:#a000a0,color:#a000a0
    classDef external fill:#E0E0E0,stroke:#666666,color:#333333
    classDef build fill:#FFF4D0,stroke:#c9a800,color:#c9a800
```
