# ksulakshana02/edwin-web architecture

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

- Interactive diagram: https://gitdiagram.com/ksulakshana02/edwin-web
- Repository: https://github.com/ksulakshana02/edwin-web

## Overview

##### Main System Components

a) Client Layer:
- Next.js Frontend Application
- Main route groups: (auth), portal, and public pages
- Real-time communication components (WebRTC/Socket.IO)

b) API/Service Layer:
- Authentication & Authorization services
- Core Services (identified in /src/services):
- Appointment Service
- Invoice Service
- Review Service
- Session Service
- User Service

c) Database Layer:
- MySQL Database (storing user data, courses, sessions, etc.)

d) External Services:
- Firebase (identified in firebase.js)
- File Storage (indicated by Upload components)

##### Component Relationships

a) Client-Side Flow:
**Components ↔ Hooks ↔ Services ↔ API Endpoints**

b) Authentication Flow:
**Auth Pages → Firebase Auth → Protected Routes**

c) Real-time Communications:
**Chat Components ↔ WebRTC/Socket.IO ↔ Backend Services**

##### Specific Implementation Details

a) Frontend Architecture:
- Next.js 13+ App Router structure (shown in src/app)
- Component organization (src/components)
- Custom hooks layer (src/hooks)
- Service abstraction layer (src/services)

b) Key Features:
- Real-time tutoring system
- Appointment scheduling
- Chat functionality
- Review and feedback system
- Payment processing

##### Important Architectural Patterns

Patterns:
- Service-oriented architecture (evident in services folder)
- Component-based architecture (React/Next.js)
- Hook-based state management
- Route grouping pattern (seen in app directory structure)

##### Additional Elements

Supporting elements:
- Security boundaries
- API endpoints grouping
- Service boundaries

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        FE[Next.js Frontend]
        
        subgraph Routes
            Auth["Authentication Routes"]
            Portal["Portal Dashboard"]
            Public["Public Pages"]
        end
        
        subgraph Components
            Chat["Chat System"]
            Session["Session Manager"]
            Review["Review Components"]
            Upload["File Upload"]
            Payment["Payment UI"]
        end
        
        subgraph Hooks
            SessionHook["Session Hooks"]
            ReviewHook["Review Hooks"]
            UserHook["User Hooks"]
            AppointmentHook["Appointment Hooks"]
        end
    end
    
    subgraph Services
        AuthService["Authentication Service"]
        AppointmentService["Appointment Service"]
        InvoiceService["Invoice Service"]
        ReviewService["Review Service"]
        SessionService["Session Service"]
        UserService["User Service"]
        RTCService["Real-time Communication"]
    end
    
    subgraph External
        Firebase["Firebase Auth"]
        Storage["File Storage"]
        WebRTC["WebRTC/Socket.IO"]
    end
    
    subgraph Database
        MySQL[(MySQL Database)]
    end
    
    %% Relationships
    FE --> Routes
    FE --> Components
    Components --> Hooks
    Hooks --> Services
    
    Auth --> Firebase
    Chat --> WebRTC
    Upload --> Storage
    
    Services --> MySQL
    
    %% Click Events
    click Auth "https://github.com/ksulakshana02/EDWin-web/tree/main/src/app/(auth)"
    click Portal "https://github.com/ksulakshana02/EDWin-web/tree/main/src/app/portal"
    click Chat "https://github.com/ksulakshana02/EDWin-web/blob/main/src/components/chat/ChatWindow.jsx"
    click Session "https://github.com/ksulakshana02/EDWin-web/blob/main/src/components/SessionManager.jsx"
    click Review "https://github.com/ksulakshana02/EDWin-web/blob/main/src/components/Reviews.jsx"
    click Upload "https://github.com/ksulakshana02/EDWin-web/blob/main/src/components/Upload.jsx"
    click SessionHook "https://github.com/ksulakshana02/EDWin-web/blob/main/src/hooks/useSessions.js"
    click ReviewHook "https://github.com/ksulakshana02/EDWin-web/blob/main/src/hooks/useReviews.js"
    click UserHook "https://github.com/ksulakshana02/EDWin-web/blob/main/src/hooks/useUsers.js"
    click AppointmentHook "https://github.com/ksulakshana02/EDWin-web/blob/main/src/hooks/useAppointments.js"
    click AppointmentService "https://github.com/ksulakshana02/EDWin-web/blob/main/src/services/appointmentService.js"
    click InvoiceService "https://github.com/ksulakshana02/EDWin-web/blob/main/src/services/invoiceService.js"
    click ReviewService "https://github.com/ksulakshana02/EDWin-web/blob/main/src/services/reviewService.js"
    click SessionService "https://github.com/ksulakshana02/EDWin-web/blob/main/src/services/sessionService.js"
    click UserService "https://github.com/ksulakshana02/EDWin-web/blob/main/src/services/userService.js"
    click Firebase "https://github.com/ksulakshana02/EDWin-web/blob/main/firebase.js"
    click Payment "https://github.com/ksulakshana02/EDWin-web/tree/main/src/app/portal/payments"
    
    %% Styling
    classDef frontend fill:#3498db,stroke:#2980b9,color:white
    classDef service fill:#2ecc71,stroke:#27ae60,color:white
    classDef external fill:#9b59b6,stroke:#8e44ad,color:white
    classDef database fill:#f1c40f,stroke:#f39c12,color:white
    
    class FE,Routes,Components,Hooks frontend
    class Services,AuthService,AppointmentService,InvoiceService,ReviewService,SessionService,UserService,RTCService service
    class Firebase,Storage,WebRTC external
    class MySQL database
```
