# abnet32/evangadi-forum architecture

> Architecture diagram of the GitHub repository abnet32/evangadi-forum, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/abnet32/evangadi-forum
- Repository: https://github.com/abnet32/evangadi-forum

## Overview

##### Project type and purpose
- This is a full-stack discussion/forum web application (“Evangadi Forum”) that integrates AI assistance.
- Frontend: React SPA (modular components, routing, axios).
- Backend: Node.js + Express REST API.
- Database: MySQL.
- External service: OpenAI GPT for AI‐generated answers.
- Auth: JWT + bcrypt.

##### File structure
- Top-level “client” folder is the React app, organized by Components and Pages.
- Api/axios.js sets up HTTP client.
- Components folder holds reusable UI pieces (Header, Footer, Chatbot, ProtectedRoute, etc.).
- Pages folder contains route views (Home, Question, Answer, Groups, etc.).
- Top-level “server” folder is the backend:
- app.js – Express app initialization with routes and middleware (CORS, dotenv, JWT auth).
- routes/ – maps URLs to controller functions.
- controller/ – business logic for auth, questions, answers, AI, groups, users, installation.
- middleware/ – e.g. authMiddleware.
- db/ – dbConfig (MySQL connection), table.sql schema.
- utils/ – sendEmail, other helpers.
- There’s an “API DOCUMENTATION – Evangadi Forum.md” indicating REST endpoint specs.

##### README for additional insights
- Confirms React + Express + MySQL + OpenAI + JWT.
- Features: Auth, Q&A, AI Assistant, responsive, copy, REST, bcrypt.

a. Main components:
1. Client (React SPA)
2. API Gateway / Backend (Express.js server)
3. Database (MySQL)
4. External AI Service (OpenAI API)
5. Authentication module (JWT, bcrypt)
b. Relationships & data flows:
- Client ↔ Backend via HTTPS/REST (axios).
- Backend ↔ Database via SQL queries (dbConfig).
- Backend ↔ OpenAI via HTTPS calls (aiController).
- Client obtains JWT on login/signup, sends token in Authorization header to protected endpoints.
c. Architectural patterns/design principles:
- Frontend: Component-based SPA, router-based navigation, context API for global state.
- Backend: MVC-style separation (routes → controllers → utils/db), middleware for cross-cutting concerns (CORS, auth).
- Layered architecture: Presentation (React), API layer (Express routes/controllers), Data access (MySQL).
- RESTful API design, stateless auth with JWT.
d. Key technologies/frameworks:
- React, Vite, Axios
- Express.js, Node.js, dotenv, CORS
- MySQL
- OpenAI GPT API
- bcrypt, jsonwebtoken, UUID

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend
    subgraph "Frontend (React SPA)"
        direction TB
        API["HTTP Client (Axios)"]:::frontend
        Chatbot["Chatbot Component"]:::frontend
        Protected["Protected Route Component"]:::frontend
        Public["Public Route Component"]:::frontend
        Context["Global State Context"]:::frontend
        Main["Main App Entry & Router"]:::frontend
        Pages["Page Views"]:::frontend
    end

    %% Backend
    subgraph "Backend (Express API Server)"
        direction TB
        App["Server Initialization (app.js)"]:::backend
        subgraph "Routes"
            direction TB
            RAuth["Authentication Route"]:::backend
            RQuestion["Questions Route"]:::backend
            RAnswer["Answers Route"]:::backend
            RAI["AI Assistant Route"]:::backend
            RGroup["Groups Route"]:::backend
            RUser["Users Route"]:::backend
            RInstall["Installation Route"]:::backend
        end
        subgraph "Controllers"
            direction TB
            CAuth["Auth Controller"]:::backend
            CQuestion["Question Controller"]:::backend
            CAnswer["Answer Controller"]:::backend
            CAI["AI Controller"]:::backend
            CGroup["Group Controller"]:::backend
            CUser["User Controller"]:::backend
            CInstall["Install Controller"]:::backend
        end
        Middleware["Authentication Middleware"]:::backend
        subgraph "Database Layer"
            direction TB
            DBConfig["DB Configuration"]:::backend
            DBSchema["DB Schema Definition"]:::backend
        end
        Utils["Utility Helpers"]:::backend
    end

    %% External and Database
    DB["MySQL Database"]:::db
    AI["OpenAI GPT Service"]:::external

    %% Connections
    Main -->|"REST calls via axios"| App
    API --> App
    Chatbot --> Main
    Protected --> Main
    Public --> Main
    Context --> Main
    Pages --> Main

    App -->|"uses routes"| RAuth
    App -->|"uses routes"| RQuestion
    App -->|"uses routes"| RAnswer
    App -->|"uses routes"| RAI
    App -->|"uses routes"| RGroup
    App -->|"uses routes"| RUser
    App -->|"uses routes"| RInstall

    RAuth -->|calls| CAuth
    RQuestion -->|calls| CQuestion
    RAnswer -->|calls| CAnswer
    RAI -->|calls| CAI
    RGroup -->|calls| CGroup
    RUser -->|calls| CUser
    RInstall -->|calls| CInstall

    App -->|uses| Middleware
    App -->|uses| Utils
    App -->|uses| DBConfig
    DBConfig -->|executes SQL| DB
    CAuth -.->|"issue/verify JWT"| Middleware
    CAI -->|"calls OpenAI API"| AI

    %% Click Events
    click API "https://github.com/abnet32/evangadi-forum/blob/main/client/src/Api/axios.js"
    click Chatbot "https://github.com/abnet32/evangadi-forum/blob/main/client/src/Components/Chatbot/Chatbot.jsx"
    click Protected "https://github.com/abnet32/evangadi-forum/blob/main/client/src/Components/Routes/ProtectedRoute.jsx"
    click Public "https://github.com/abnet32/evangadi-forum/blob/main/client/src/Components/Routes/PublicRoute.jsx"
    click Context "https://github.com/abnet32/evangadi-forum/blob/main/client/src/context/DataContext.jsx"
    click Main "https://github.com/abnet32/evangadi-forum/blob/main/client/src/main.jsx"
    click Main "https://github.com/abnet32/evangadi-forum/blob/main/client/src/App.jsx"
    click Main "https://github.com/abnet32/evangadi-forum/blob/main/client/src/Router.jsx"
    click Pages "https://github.com/abnet32/evangadi-forum/tree/main/client/src/Pages/"
    click App "https://github.com/abnet32/evangadi-forum/blob/main/server/app.js"
    click RAuth "https://github.com/abnet32/evangadi-forum/blob/main/server/routes/authRoute.js"
    click RQuestion "https://github.com/abnet32/evangadi-forum/blob/main/server/routes/questionRoute.js"
    click RAnswer "https://github.com/abnet32/evangadi-forum/blob/main/server/routes/answerRoute.js"
    click RAI "https://github.com/abnet32/evangadi-forum/blob/main/server/routes/aiRoute.js"
    click RGroup "https://github.com/abnet32/evangadi-forum/blob/main/server/routes/groupRoute.js"
    click RUser "https://github.com/abnet32/evangadi-forum/blob/main/server/routes/userRoute.js"
    click RInstall "https://github.com/abnet32/evangadi-forum/blob/main/server/routes/installRoute.js"
    click CAuth "https://github.com/abnet32/evangadi-forum/blob/main/server/controller/authController.js"
    click CQuestion "https://github.com/abnet32/evangadi-forum/blob/main/server/controller/questionController.js"
    click CAnswer "https://github.com/abnet32/evangadi-forum/blob/main/server/controller/answerController.js"
    click CAI "https://github.com/abnet32/evangadi-forum/blob/main/server/controller/aiController.js"
    click CGroup "https://github.com/abnet32/evangadi-forum/blob/main/server/controller/groupController.js"
    click CUser "https://github.com/abnet32/evangadi-forum/blob/main/server/controller/userController.js"
    click CInstall "https://github.com/abnet32/evangadi-forum/blob/main/server/controller/installController.js"
    click Middleware "https://github.com/abnet32/evangadi-forum/blob/main/server/middleware/authMiddleware.js"
    click DBConfig "https://github.com/abnet32/evangadi-forum/blob/main/server/db/dbConfig.js"
    click DBSchema "https://github.com/abnet32/evangadi-forum/blob/main/server/db/table.sql"
    click Utils "https://github.com/abnet32/evangadi-forum/blob/main/server/utils/sendEmail.js"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366d6,stroke-width:1px;
    classDef backend fill:#DFFFE0,stroke:#228B22,stroke-width:1px;
    classDef db fill:#FFE4B5,stroke:#FF8C00,stroke-width:1px;
    classDef external fill:#E8D0FF,stroke:#800080,stroke-width:1px;
```
