# esarmiem/b2c-landing architecture

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

- Interactive diagram: https://gitdiagram.com/esarmiem/b2c-landing
- Repository: https://github.com/esarmiem/b2c-landing

## Overview

##### Project Type & Purpose
- The project is a modern web application for travel insurance and assistance services. The README and file structure indicate that it is built as a full-stack frontend application using React with TypeScript, styled with Tailwind CSS.
- Key functionalities include travel assistance quotations, multi-language support, real-time currency conversion, secure payment processing via ePayco, and integration with multiple APIs (TravelKit, ISL, and ePayco).

##### High-Level Architectural Components
a. User Interface / Frontend:
- The core UI is implemented using React and is divided into multiple layers:
- TravelCore: Contains core features and shared layouts, context providers, hooks, utility functions, and API service integrations.
- TravelFeatures: Contains feature-specific components and pages (e.g., Home, Invoice, Traveler, TripQuote) that build on top of the core functionality.
- Shared components: Located in /components (e.g., base UI elements such as buttons, inputs, cards) that can be reused across features.
- Main routing is handled in the TravelCore/Routes directory.
- Internationalization is supported via i18next with translation files stored under public/locales (for both English and Spanish).

b. Service Integration & API Communication:
- The application separates API calls based on functionality:
- Services/API Integration: In the TravelCore/Services/Apis directory, there are dedicated folders for Authentication, ISL based authentication, Masters, Order, and Payment.
- These services encapsulate HTTP communications (using Axios as per the README) and provide data to React Context providers.
- External APIs include TravelKit APIs, ISL API for travel assistance, and the payment gateway via ePayco.

c. State Management:
- Managed using React Context through the files in TravelCore/ContextData.
- Custom hooks (in TravelCore/Hooks) help interact with specific pieces of state for data, orders, sessions, etc.

d. Configuration & Utilities:
- Configuration files for Tailwind (tailwind.config.js), Vite (vite.config.ts), and TypeScript (tsconfig.json) define the development and build environment.
- Utility functions and constants are in TravelCore/Utils for runtime behaviors (e.g., date formatting, HTTP methods, and validation rules).

##### Relationships and Interactions
- The UI components within the TravelFeatures and TravelCore directories interact with each other through well-defined context providers.
- API service modules (grouped by functionality) provide data to state management contexts.
- The shared UI components support consistency in the look and feel across different features.
- Internationalization is implemented at the UI level; translation files are loaded from the public folder and used across components.
- Styling is centralized in the TravelCore/Styles directory and through global styles (e.g., index.css, assets, and Tailwind CSS).

##### Architectural Patterns & Design Principles
- Separation of concerns: Clear separation between core functionalities (TravelCore) and feature-specific functionalities (TravelFeatures).
- Component reusability: Shared components and UI elements in /components.
- State management with React Context promotes modular design.
- API abstraction: The Services/Apis directories abstract external API interactions.
- Responsive design: Ensured using Tailwind CSS alongside media queries in custom style sheets.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interface Layer
    subgraph "User Interface Layer"
        A["React Application"]:::frontend
        subgraph "TravelCore"
            TC1["Core Components"]:::frontend
            Routes["Routes"]:::frontend
            Context["Context Providers"]:::frontend
            Hooks["Custom Hooks"]:::frontend
            Layout["Shared Layout & Styles"]:::frontend
        end
        subgraph "TravelFeatures"
            Home["Home Feature"]:::frontend
            Invoice["Invoice Feature"]:::frontend
            Traveler["Traveler Feature"]:::frontend
            TripQuote["TripQuote Feature"]:::frontend
        end
        UI["Shared UI Components"]:::frontend
    end

    %% API & Services Layer
    subgraph "API & Services Layer"
        Auth["Authentication Services"]:::service
        ISL["ISL Authentication"]:::service
        Masters["Masters & Related APIs"]:::service
        Order["Order API"]:::service
        Payment["Payment Service (ePayco)"]:::service
    end

    %% Utility & Configuration Layer
    subgraph "Utility & Configuration Layer"
        Utils["Utility Functions & Constants"]:::utility
        Tailwind["Tailwind Config"]:::utility
        Vite["Vite Config"]:::utility
        TS["TypeScript Config"]:::utility
    end

    %% Internationalization
    subgraph "Internationalization"
        Trans["Translation Files"]:::intl
        I18next["i18next Config"]:::intl
    end

    %% Connections in UI Layer
    A -->|"initializes"| Routes
    A -->|"initializes"| TC1
    A -->|"loads"| Trans
    A -->|"loads"| I18next

    Routes -->|"sets context"| Context
    Context -->|"leverages"| Hooks
    Layout -->|"uses styles"| Tailwind
    Layout -->|"uses config"| Vite
    Layout -->|"uses config"| TS

    %% Interaction between TravelFeatures and Shared UI Components
    Home -->|"renders"| UI
    Invoice -->|"renders"| UI
    Traveler -->|"renders"| UI
    TripQuote -->|"renders"| UI

    %% Interaction from TravelCore to API Services via Hooks
    Hooks -->|"calls"| Auth
    Hooks -->|"calls"| ISL
    Hooks -->|"calls"| Masters
    Hooks -->|"calls"| Order
    Hooks -->|"calls"| Payment

    %% Styling for connections between layers (optional additional arrows)
    TC1 -->|"orchestrates"| Context
    TC1 -->|"orchestrates"| Hooks

    %% Click Events
    click A "https://github.com/esarmiem/b2c-landing/blob/master/src/main.tsx"
    click TC1 "https://github.com/esarmiem/b2c-landing/tree/master/src/TravelCore"
    click Routes "https://github.com/esarmiem/b2c-landing/blob/master/src/TravelCore/Routes/index.tsx"
    click Context "https://github.com/esarmiem/b2c-landing/tree/master/src/TravelCore/ContextData"
    click Hooks "https://github.com/esarmiem/b2c-landing/tree/master/src/TravelCore/Hooks"
    click Layout "https://github.com/esarmiem/b2c-landing/tree/master/src/TravelCore/Styles"
    click Home "https://github.com/esarmiem/b2c-landing/tree/master/src/TravelFeatures/Home"
    click Invoice "https://github.com/esarmiem/b2c-landing/tree/master/src/TravelFeatures/Invoice"
    click Traveler "https://github.com/esarmiem/b2c-landing/tree/master/src/TravelFeatures/Traveler"
    click TripQuote "https://github.com/esarmiem/b2c-landing/tree/master/src/TravelFeatures/TripQuote"
    click UI "https://github.com/esarmiem/b2c-landing/tree/master/src/components/ui"
    click Auth "https://github.com/esarmiem/b2c-landing/tree/master/src/TravelCore/Services/Apis/Authentication"
    click ISL "https://github.com/esarmiem/b2c-landing/tree/master/src/TravelCore/Services/Apis/AuthenticationISL"
    click Masters "https://github.com/esarmiem/b2c-landing/tree/master/src/TravelCore/Services/Apis/Masters"
    click Order "https://github.com/esarmiem/b2c-landing/tree/master/src/TravelCore/Services/Apis/Order"
    click Payment "https://github.com/esarmiem/b2c-landing/tree/master/src/TravelCore/Services/Apis/Payment"
    click Utils "https://github.com/esarmiem/b2c-landing/tree/master/src/TravelCore/Utils"
    click Tailwind "https://github.com/esarmiem/b2c-landing/blob/master/tailwind.config.js"
    click Vite "https://github.com/esarmiem/b2c-landing/blob/master/vite.config.ts"
    click TS "https://github.com/esarmiem/b2c-landing/blob/master/tsconfig.json"
    click Trans "https://github.com/esarmiem/b2c-landing/tree/master/public/locales"
    click I18next "https://github.com/esarmiem/b2c-landing/blob/master/src/config/i18next.config.ts"

    %% Styles
    classDef frontend fill:#CDE6F5,stroke:#1A5A96,stroke-width:2px;
    classDef service fill:#DFF0D8,stroke:#3C763D,stroke-width:2px;
    classDef utility fill:#F9E79F,stroke:#D4AC0D,stroke-width:2px;
    classDef intl fill:#FADBD8,stroke:#C0392B,stroke-width:2px;
```
