# sirilux191/lyfelynk architecture

> Architecture diagram of the GitHub repository sirilux191/lyfelynk, 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/sirilux191/lyfelynk
- Repository: https://github.com/sirilux191/lyfelynk

## Overview

##### Main Components
- Backend Canister(s): Represented by the Motoko code found under src/lyfelynkMVP_backend. These include the primary canister logic (main.mo, TokenTypes.mo, Types.mo) and utility functions (e.g., Hex.mo).
- Frontend Application: Found under src/lyfelynkMVP_frontend, this section is a React application built using Vite (with files like App.jsx, index.html, tailwind configuration) and includes several modules (pages, onboarding, components, and even specialized sections for Health-Professional, Health-Service, and Health-User).
- Local Development Environment & Deployment Tools: Represent components/tools like DFX commands, npm scripts (for generating candid interface or starting the development server), and associated configuration files (dfx.json, package.json, mops.toml).

##### Relationships and Interactions
- A connection between the frontend and the backend canister(s): Indicate that the frontend application interacts with the backend through API calls (likely using the generated candid interfaces).
- Role of DFX in managing deployment and canister updates, bridging the local development environment with the deployed canisters on the Internet Computer.

##### Architectural Patterns and Design Principles
- Full-stack separation: The clear division between the frontend (React, Vite, Tailwind) and backend (Motoko canisters) promotes modular deployment and scalability.
- Candid Interface Generation: Emphasize how changes to the backend can trigger new candid interface generation (using npm run generate) to ensure that frontend and backend remain synchronized.
- Use of Microservice-like canisters: Even though the project has a single canister for the backend now, the structure (separate modules, utilities) hints at a pattern where components can be extended or further deconstructed in a microservices-compliant design.

##### Relevant Technologies / Frameworks
- Backend: Motoko programming language, DFX (Internet Computer SDK), and canister configuration & deployment via dfx.json.
- Frontend: React, Vite, Tailwind CSS, JavaScript/JSX, and the integration with connect2ic styles and utilities.
- Interoperation: The candid interface used for connecting the front and back ends; also note that the project uses npm for dependency management and scripting.

##### Final Assembly
- Decompose the frontend into its submodules (Health-Professional, Health-Service, Health-User, Onboarding) and the backend into its core modules and utilities.
- How local development tools (dfx, npm, Vite) interact with these components.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Nodes
    User["User / Browser"]:::user

    subgraph "Frontend Application"
        FE1["React Frontend Application (App.jsx, Pages, Onboarding, Health-Professional, Health-Service, Health-User)"]:::frontend
    end

    subgraph "Backend Canister"
        BE1["Motoko Backend Canister (main.mo, TokenTypes.mo, Types.mo, Hex.mo)"]:::backend
    end

    subgraph "Internet Computer Infrastructure"
        IC_Config["IC Config (dfx.json, canister_ids.json)"]:::infrastructure
        IC_Candid["Candid Interfaces (vetkd_system_api.did, vetkd_system_api.wasm)"]:::infrastructure
        IC_Config -->|"flows_to"| IC_Candid
    end

    subgraph "Development Tools"
        DEV1["Local Dev & Deployment Tools (package.json, mops.toml, npm scripts)"]:::devTools
    end

    %% Connections
    User -->|"HTTP_Request"| FE1
    FE1 -->|"API_call_via_candid"| BE1
    BE1 -->|"Deployed_as_canister"| IC_Candid
    DEV1 -->|"Deploy_and_Config"| IC_Config
    DEV1 -->|"Update_and_Generate"| BE1

    %% Click Events
    click FE1 "https://github.com/sirilux191/lyfelynk/tree/main/src/lyfelynkMVP_frontend"
    click BE1 "https://github.com/sirilux191/lyfelynk/tree/main/src/lyfelynkMVP_backend"
    click IC_Config "https://github.com/sirilux191/lyfelynk/blob/main/dfx.json"
    click DEV1 "https://github.com/sirilux191/lyfelynk/blob/main/package.json"

    %% Styles
    classDef user fill:#FAD7A0,stroke:#E67E22,stroke-width:2px;
    classDef frontend fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef backend fill:#F9E79F,stroke:#B9770E,stroke-width:2px;
    classDef infrastructure fill:#A3E4D7,stroke:#1ABC9C,stroke-width:2px;
    classDef devTools fill:#F5CBA7,stroke:#D35400,stroke-width:2px;
```
