# vutrn/etutor-enterprise architecture

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

- Interactive diagram: https://gitdiagram.com/vutrn/etutor-enterprise
- Repository: https://github.com/vutrn/etutor-enterprise

## Overview

##### Main Components
- Frontend Application:
- Built with TypeScript and gluestack‑ui. Contains screens for authentication, blogs, courses/classes, document sharing, meetings, messages, and dashboards for different roles (admin, student, tutor).
- Organized into components, screens, navigation (with distinct navigators for auth, blog, admin, student, tutor).
- Backend Service:
- A Node.js backend that follows a modular MVC-like structure with controllers (e.g., authController, blogController, meetingController) and models (Blog, Document, Meeting, Message, OnlineMeet, PersonalClass, User).
- Routes and controllers handling REST API endpoints.
- Libraries for external integrations such as cloudinary.js (for file/media storage), emailService.js (for notifications), and socket.js (for real-time communication).
- External Services & Integrations:
- Cloudinary (for media storage).
- Email services (for sending notifications).
- WebSocket mechanism for real-time interactions.
- (Implied) Database:
- While the file tree does not explicitly list a database configuration file, the models indicate persistent storage (likely MongoDB or similar). Mark it as a key element in your architecture.

##### Relationships and Interactions
- Communication Flow:
- Frontend interacts with the backend via REST API endpoints defined in the backend/routes directory.
- The backend controllers process requests from the frontend (authentication, blog posts, meeting scheduling, etc.)
- Controllers use models for CRUD operations and business logic.
- The backend uses libraries (socket.js, emailService.js, cloudinary.js) to interact with external services, e.g., sending emails, uploading files, or handling real-time messaging.
- Data Flow:
- Requests flow from the frontend to backend endpoints.
- Responses flow back to update UI components in the frontend.
- Real-time data, for instance for messaging or live meetings, flows through WebSocket connections managed by socket.js.

##### Architectural Patterns and Design Principles
- Separation of Concerns:
- Clear division between the frontend and backend responsibilities.
- In the backend, MVC-like separation where controllers, models, and routes are isolated for maintainability.
- Modularity:
- Each feature (e.g., blog, meeting, document handling) has its own controller, routes, and models.
- The frontend further partitions screens and components according to user roles (admin, student, tutor) and functional areas.
- Integration of Third-Party Services:
- Use of external libraries for cloud storage, emailing, and sockets demonstrates integration without sacrificing internal cohesion.

##### Inclusion Details
- Frontend: Authentication screens, Dashboards (admin/student/tutor), Blog, Document, Meeting, and Message features.
- Backend: Modules like Auth, Blog, Dashboard, Document, Meeting, Message, Online Meeting, Personal Class.
- External Services: Cloudinary, Email Service, WebSocket Service.
- Database (implied).
- To show the flow of HTTP requests/responses from Frontend to Backend, communication with external services, and real-time data flows.
- Apply Visual Distinction:
▪ User Interface Components (e.g., rounded rectangles)
▪ Backend API Services (e.g., rectangles)

##### Final Detailed Steps
- Drill down into each part:
- Frontend: Illustrate separate navigators and screens, and include state management modules (stores) and utilities.
- Backend: Group the controllers, routes, and models by functional domains. Indicate where the libraries (cloudinary, email, socket) are utilized.
- External Elements and Database: Position them clearly, linking them to the backend modules that interact with them.

## Diagram (Mermaid)

```mermaid
graph TD
    %% Frontend Layer
    subgraph "Frontend Application"
        AuthScreens["Auth Screens"]:::frontend
        AuthNavig["Auth Navigator"]:::frontend
        BlogComps["Blog Components"]:::frontend
        BlogNav["Blog Navigator"]:::frontend
        AdminDash["Admin Dashboard"]:::frontend
        AdminProf["Admin Profile"]:::frontend
        StudentDash["Student Dashboard"]:::frontend
        StudentProf["Student Profile"]:::frontend
        TutorDash["Tutor Dashboard"]:::frontend
        TutorProf["Tutor Profile"]:::frontend
        StudentCF["Student Class Features"]:::frontend
        TutorCF["Tutor Class Features"]:::frontend
        UIComponents["UI Components"]:::frontend
    end

    %% Backend Layer
    subgraph "Backend Service"
        Controllers["Controllers"]:::backend
        Models["Models"]:::backend
        Routes["Routes"]:::backend
        Libraries["Libraries"]:::backend
    end

    %% External Services & Database
    subgraph "External Services & Database"
        Cloudinary["Cloudinary"]:::external
        EmailService["Email Service"]:::external
        SocketService["Socket Service"]:::external
        Database["Database (MongoDB)"]:::db
    end

    %% Communication from Frontend to Backend Routes
    AuthNavig -->|"API_Request"| Routes
    BlogNav -->|"API_Request"| Routes
    AdminDash -->|"API_Request"| Routes
    StudentDash -->|"API_Request"| Routes
    TutorDash -->|"API_Request"| Routes
    UIComponents -->|"User_Interaction"| Routes

    %% Backend Internal Communication
    Routes -->|"Calls"| Controllers
    Controllers -->|"Executes_on"| Models
    Models -->|"Persists_in"| Database

    %% External Integrations from Backend
    Controllers -->|"Uses"| Libraries
    Libraries -->|"Integrates_with"| Cloudinary
    Libraries -->|"Integrates_with"| EmailService
    Libraries -->|"Integrates_with"| SocketService

    %% Click Events for Frontend Components
    click AuthScreens "https://github.com/vutrn/etutor-enterprise/tree/main/frontend/src/screens/auth"
    click AuthNavig "https://github.com/vutrn/etutor-enterprise/blob/main/frontend/src/navigation/auth.navigator.tsx"
    click BlogComps "https://github.com/vutrn/etutor-enterprise/tree/main/frontend/src/components/blog"
    click BlogNav "https://github.com/vutrn/etutor-enterprise/blob/main/frontend/src/navigation/blog.navigator.tsx"
    click AdminDash "https://github.com/vutrn/etutor-enterprise/tree/main/frontend/src/screens/@admin/dashboard"
    click AdminProf "https://github.com/vutrn/etutor-enterprise/blob/main/frontend/src/screens/@admin/admin.profile.tsx"
    click StudentDash "https://github.com/vutrn/etutor-enterprise/blob/main/frontend/src/screens/@student/student.dashboard.tsx"
    click StudentProf "https://github.com/vutrn/etutor-enterprise/blob/main/frontend/src/screens/@student/student.profile.tsx"
    click TutorDash "https://github.com/vutrn/etutor-enterprise/blob/main/frontend/src/screens/@tutor/tutor.dashboard.tsx"
    click TutorProf "https://github.com/vutrn/etutor-enterprise/blob/main/frontend/src/screens/@tutor/tutor.profile.tsx"
    click StudentCF "https://github.com/vutrn/etutor-enterprise/tree/main/frontend/src/screens/@student/class_features"
    click TutorCF "https://github.com/vutrn/etutor-enterprise/tree/main/frontend/src/screens/@tutor/class_features"
    click UIComponents "https://github.com/vutrn/etutor-enterprise/tree/main/frontend/components/ui"

    %% Click Events for Backend Components
    click Controllers "https://github.com/vutrn/etutor-enterprise/tree/main/backend/controllers"
    click Models "https://github.com/vutrn/etutor-enterprise/tree/main/backend/models"
    click Routes "https://github.com/vutrn/etutor-enterprise/tree/main/backend/routes"
    click Libraries "https://github.com/vutrn/etutor-enterprise/tree/main/backend/lib"

    %% Click Events for External Services
    click Cloudinary "https://github.com/vutrn/etutor-enterprise/blob/main/backend/lib/cloudinary.js"
    click EmailService "https://github.com/vutrn/etutor-enterprise/blob/main/backend/lib/emailService.js"
    click SocketService "https://github.com/vutrn/etutor-enterprise/blob/main/backend/lib/socket.js"

    %% Styles
    classDef frontend fill:#DDF4FF,stroke:#000,stroke-width:2px;
    classDef backend fill:#FFD9B3,stroke:#000,stroke-width:2px;
    classDef db fill:#C1E1C1,stroke:#000,stroke-width:2px;
    classDef external fill:#FFE0E0,stroke:#000,stroke-width:2px;
```
