# hking0o1/learnify-portfolio-mind architecture

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

- Interactive diagram: https://gitdiagram.com/hking0o1/learnify-portfolio-mind
- Repository: https://github.com/hking0o1/learnify-portfolio-mind

## Overview

##### Main Components & Layers
- Pages: Located in the src/pages directory (e.g., SignIn, Dashboard, CourseDetails).
- Components: Broken down into functional areas like auth, course, dashboard, layout, and a rich set in components/ui for reusable UI elements.
- Contexts and Hooks: These (in src/contexts and src/hooks) manage application state like authentication or themes and handle reusable logic.
- Service Layer: The src/services directory abstracts business logic such as AI modules, course recommendations, and API calls. These services serve as a mediator between the UI and external integrations.
- External Integrations: There’s a defined integration with Supabase both in src/integrations (client code) and in the supabase folder (serverless functions). These functions (e.g., generate-module, generate-roadmap, personalized-course, personalized-portfolio) encapsulate backend logic that performs operations like generating modules or personalized content.

##### Establish Relationships and Data Flow
- User Interaction Flow: Start with a user interacting with the UI (via pages and components). The interaction triggers events handled by React components.
- Context and Hooks: The components rely on contexts (e.g., AuthContext) and custom hooks (e.g., use-theme, use-search) to manage state and UI behavior.
- Service Calls: Components call functions in the services layer (like api.ts, ai-modules.ts), which then interact with the Supabase integration or other external endpoints.
- External Invocations: The service layer makes API calls to the Supabase functions that run on the backend. The data returned is passed back up through services to update component state and render updated views.
- Utility Modules: The lib/utils.ts file may be used across various layers for common utility functions.

##### Architectural Patterns and Design Principles
- Component-Based Design: The project leverages a modular, reusable UI component structure, following best practices in React development.
- Separation of Concerns: There’s a clear division between presentation (UI components), business logic (services and hooks), and data access (Supabase integrations).
- Service Abstraction: The services layer abstracts away API calls and external data interactions, ensuring that the UI can remain decoupled from backend details.
- Serverless Backend Integration: The Supabase directory indicates the usage of serverless functions to handle specific tasks, aligning with modern cloud-based, event-driven architectures.

##### Technologies & Frameworks to Highlight
- Vite — The build tool and development server for a fast development experience.
- React & TypeScript — Core of your front-end application.
- shadcn-ui & Tailwind CSS — For UI components and styling.
- Supabase — Providing backend functions and database integration.
- ESLint and PostCSS configurations — Representing coding standards and styling capabilities.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global entities
    User["User (Browser)"]:::user

    %% Frontend Interface
    subgraph "Frontend Interface"
        Pages["React Pages"]:::frontend
        UI["UI Components (shadcn-ui)"]:::frontend
        Auth["Auth Components"]:::frontend
        Course["Course Components"]:::frontend
        Dashboard["Dashboard Components"]:::frontend
        Layout["Layout Components"]:::frontend
        Theme["Theme Provider"]:::frontend
    end

    %% State Management & Reusable Logic
    subgraph "State Management & Logic"
        Contexts["AuthContext"]:::logic
        Hooks["Custom Hooks"]:::logic
    end

    %% Service Layer
    subgraph "Service Layer"
        Services["API Services & Business Logic"]:::service
    end

    %% Client-Side Integration
    subgraph "Client-Side Supabase Integration"
        SupabaseClient["Supabase Client Integration"]:::integration
    end

    %% Utility Functions
    subgraph "Utility Functions"
        Utils["Reusable Utilities"]:::utility
    end

    %% Serverless Backend Integration
    subgraph "Serverless Backend Integration"
        SupabaseFunc["Supabase Functions (Backend)"]:::backend
        ModuleFunc["generate-module"]:::backend
        RoadmapFunc["generate-roadmap"]:::backend
        PersonalizedCourse["personalized-course"]:::backend
        PersonalizedPortfolio["personalized-portfolio"]:::backend
    end

    %% Data Flow Connections
    User -->|"triggers"| Pages
    Pages -->|"renders"| UI
    Pages -->|"routes via"| Auth
    Pages -->|"invokes"| Course
    Pages -->|"displays"| Dashboard
    Pages -->|"includes"| Layout
    Pages -->|"applies"| Theme

    Pages -->|"accesses"| Contexts
    Pages -->|"uses"| Hooks

    Contexts -->|"drives"| Hooks

    Hooks -->|"calls"| Services
    UI -->|"triggers"| Services
    Auth -->|"secures"| Services
    Course -->|"requests"| Services
    Dashboard -->|"fetches"| Services
    Layout -->|"wraps"| Services
    Theme -->|"controls"| Services

    Services -->|"integrates"| SupabaseClient
    Services -->|"utilizes"| Utils

    SupabaseClient -->|"calls"| SupabaseFunc
    SupabaseFunc -->|"executes"| ModuleFunc
    SupabaseFunc -->|"executes"| RoadmapFunc
    SupabaseFunc -->|"executes"| PersonalizedCourse
    SupabaseFunc -->|"executes"| PersonalizedPortfolio

    %% Click Events for Component Mapping
    click Pages "https://github.com/hking0o1/learnify-portfolio-mind/tree/main/src/pages"
    click UI "https://github.com/hking0o1/learnify-portfolio-mind/tree/main/src/components/ui"
    click Auth "https://github.com/hking0o1/learnify-portfolio-mind/tree/main/src/components/auth"
    click Course "https://github.com/hking0o1/learnify-portfolio-mind/tree/main/src/components/course"
    click Dashboard "https://github.com/hking0o1/learnify-portfolio-mind/tree/main/src/components/dashboard"
    click Layout "https://github.com/hking0o1/learnify-portfolio-mind/tree/main/src/components/layout"
    click Theme "https://github.com/hking0o1/learnify-portfolio-mind/blob/main/src/components/theme-provider.tsx"
    click Contexts "https://github.com/hking0o1/learnify-portfolio-mind/tree/main/src/contexts"
    click Hooks "https://github.com/hking0o1/learnify-portfolio-mind/tree/main/src/hooks"
    click Services "https://github.com/hking0o1/learnify-portfolio-mind/tree/main/src/services"
    click SupabaseClient "https://github.com/hking0o1/learnify-portfolio-mind/tree/main/src/integrations/supabase"
    click Utils "https://github.com/hking0o1/learnify-portfolio-mind/blob/main/src/lib/utils.ts"
    click SupabaseFunc "https://github.com/hking0o1/learnify-portfolio-mind/tree/main/supabase/functions"
    click ModuleFunc "https://github.com/hking0o1/learnify-portfolio-mind/tree/main/supabase/functions/generate-module"
    click RoadmapFunc "https://github.com/hking0o1/learnify-portfolio-mind/tree/main/supabase/functions/generate-roadmap"
    click PersonalizedCourse "https://github.com/hking0o1/learnify-portfolio-mind/tree/main/supabase/functions/personalized-course"
    click PersonalizedPortfolio "https://github.com/hking0o1/learnify-portfolio-mind/tree/main/supabase/functions/personalized-portfolio"

    %% Styles
    classDef user fill:#ffe599,stroke:#000,stroke-width:2px
    classDef frontend fill:#cfe2f3,stroke:#1a1a1a,stroke-width:2px
    classDef logic fill:#d9ead3,stroke:#1a1a1a,stroke-width:2px
    classDef service fill:#fff2cc,stroke:#1a1a1a,stroke-width:2px
    classDef integration fill:#f4cccc,stroke:#1a1a1a,stroke-width:2px
    classDef utility fill:#ead1dc,stroke:#1a1a1a,stroke-width:2px
    classDef backend fill:#d0e0e3,stroke:#1a1a1a,stroke-width:2px
```
