# web3edubrasil/web3edu-app architecture

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

- Interactive diagram: https://gitdiagram.com/web3edubrasil/web3edu-app
- Repository: https://github.com/web3edubrasil/web3edu-app

## Overview

##### Main Components

A. Frontend Layer:
- Next.js Application (Client-Side)
- Landing Page Components
- Learning Interface Components
- User Management Components
- Program Management Components
- KYC Components

B. API Layer (Next.js API Routes):
- User Management APIs
- Trail/Content Management APIs
- Program Management APIs
- KYC APIs
- AI Integration API

C. Authentication & Web3 Layer:
- Web3Auth Integration
- Firebase Authentication

D. External Services:
- Firebase (Backend as a Service)
- Web3 Services
- AI Services (indicated by the AI route)

**┌─────────────────────────────────────────────────────────┐**
- Client Layer (Browser)                  │
- ┘
- ↕
**┌─────────────────────────────────────────────────────────┐**
- Next.js Application Layer                 │
- ┬─────────────────┬────────────┬───────────┤
- Pages &    │     API         │   Auth     │  Static   │
- Components  │    Routes       │   Layer    │  Assets   │
- ┴─────────────────┴────────────┴───────────┘
- ↕
**┌─────────────────────────────────────────────────────────┐**
- External Services                      │
- ┬─────────────────┬────────────────────────┤
- Firebase   │    Web3Auth     │     AI Services        │
- ┴─────────────────┴────────────────────────┘

##### Detailed Component Breakdown

A. Frontend Components:
- Relationship between pages and their components
- Routing structure (/learn, /programPage, etc.)
- Component hierarchy

B. API Routes:
- Related endpoints (user, trail, program)
- Data flow between endpoints
- Error handling and validation layers

C. Authentication Flow:
- Detail the Web3Auth integration
- Firebase authentication process
- KYC flow

##### Important Elements to Emphasize

- The Next.js app router structure
- The separation between client and server components
- The integration points with Web3 services
- The content management system structure
- The user journey flow

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Layer (Browser)"]
        Browser["Web Browser"]:::client
    end

    subgraph NextApp["Next.js Application Layer"]
        subgraph Pages["Pages & Components"]
            Landing["Landing Page"]:::frontend
            click Landing "https://github.com/Web3EduBrasil/web3edu-app/tree/main/src/components/landingPage"
            Learn["Learning Interface"]:::frontend
            click Learn "https://github.com/Web3EduBrasil/web3edu-app/tree/main/src/components/learn"
            UserMgmt["User Management"]:::frontend
            click UserMgmt "https://github.com/Web3EduBrasil/web3edu-app/tree/main/src/components/UserPage"
            ProgramMgmt["Program Management"]:::frontend
            click ProgramMgmt "https://github.com/Web3EduBrasil/web3edu-app/tree/main/src/components/programPage"
            KYCComp["KYC Interface"]:::frontend
            click KYCComp "https://github.com/Web3EduBrasil/web3edu-app/tree/main/src/components/KYC"
            NavBar["Navigation"]:::frontend
            click NavBar "https://github.com/Web3EduBrasil/web3edu-app/tree/main/src/components/NavBar"
            Onboarding["Onboarding"]:::frontend
            click Onboarding "https://github.com/Web3EduBrasil/web3edu-app/tree/main/src/components/onboardingPage"
            UIComps["UI Components"]:::frontend
            click UIComps "https://github.com/Web3EduBrasil/web3edu-app/tree/main/src/components/ui"
            TaskComps["Task Components"]:::frontend
            click TaskComps "https://github.com/Web3EduBrasil/web3edu-app/tree/main/src/components/Task"
        end

        subgraph API["API Routes"]
            UserAPI["User API"]:::api
            click UserAPI "https://github.com/Web3EduBrasil/web3edu-app/tree/main/src/app/api/user"
            TrailAPI["Trail API"]:::api
            click TrailAPI "https://github.com/Web3EduBrasil/web3edu-app/tree/main/src/app/api/trail"
            ProgramAPI["Program API"]:::api
            click ProgramAPI "https://github.com/Web3EduBrasil/web3edu-app/tree/main/src/app/api/program"
            KYCAPI["KYC API"]:::api
            click KYCAPI "https://github.com/Web3EduBrasil/web3edu-app/tree/main/src/app/api/kyc"
            AIAPI["AI API"]:::api
            click AIAPI "https://github.com/Web3EduBrasil/web3edu-app/tree/main/src/app/api/ai"
        end

        subgraph Auth["Authentication Layer"]
            Web3AuthInt["Web3Auth Integration"]:::auth
            click Web3AuthInt "https://github.com/Web3EduBrasil/web3edu-app/tree/main/src/lib/web3auth"
            FirebaseAuth["Firebase Auth"]:::auth
            click FirebaseAuth "https://github.com/Web3EduBrasil/web3edu-app/blob/main/src/firebase/config.ts"
            AuthProvider["Auth Provider"]:::auth
            click AuthProvider "https://github.com/Web3EduBrasil/web3edu-app/blob/main/src/lib/web3auth/Web3AuthProvider.tsx"
        end

        subgraph Core["Core Services"]
            CMS["Content Management"]:::core
            click CMS "https://github.com/Web3EduBrasil/web3edu-app/blob/main/src/providers/content-context.tsx"
            Interfaces["Interface Definitions"]:::core
            click Interfaces "https://github.com/Web3EduBrasil/web3edu-app/blob/main/src/interfaces/interfaces.ts"
        end
    end

    subgraph External["External Services"]
        Firebase["Firebase"]:::external
        Web3Auth["Web3Auth"]:::external
        AI["AI Services"]:::external
    end

    %% Connections
    Browser --> Landing
    Browser --> Learn
    Browser --> UserMgmt
    Browser --> ProgramMgmt
    Browser --> KYCComp

    Landing --> UserAPI
    Learn --> TrailAPI
    UserMgmt --> UserAPI
    ProgramMgmt --> ProgramAPI
    KYCComp --> KYCAPI

    UserAPI --> FirebaseAuth
    TrailAPI --> CMS
    ProgramAPI --> CMS
    KYCAPI --> FirebaseAuth
    AIAPI --> AI

    Web3AuthInt --> Web3Auth
    FirebaseAuth --> Firebase
    AuthProvider --> Web3AuthInt

    %% Styles
    classDef client fill:#e1f5fe,stroke:#01579b
    classDef frontend fill:#bbdefb,stroke:#1976d2
    classDef api fill:#c8e6c9,stroke:#388e3c
    classDef auth fill:#ffe0b2,stroke:#f57c00
    classDef core fill:#e1bee7,stroke:#7b1fa2
    classDef external fill:#d1c4e9,stroke:#512da8

    %% Legend
    subgraph Legend
        Client_["Client"]:::client
        Frontend_["Frontend"]:::frontend
        API_["API"]:::api
        Auth_["Auth"]:::auth
        Core_["Core"]:::core
        External_["External"]:::external
    end
```
