# ghost-vedant/wondernot architecture

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

- Interactive diagram: https://gitdiagram.com/ghost-vedant/wondernot
- Repository: https://github.com/ghost-vedant/wondernot

## Overview

This project, WonderNot, is a full-stack community platform that enables users to connect, interact (via posts, chats, profiles, etc.), and engage with one another. The project is structured into three main sub-projects: the client (frontend), the server (backend API), and a separate socket module for real-time communication.

##### Main Components
- Frontend (client):
- Built using React with component-based architecture (organized into scenes, widgets, and styled components).
- Utilizes libraries and frameworks like React Router, Redux, and MUI alongside Tailwind CSS for styling.
- Contains major pages such as Login, Home, Chat, Profile, and a separate navigation layout.
- Backend (server):
- An Express.js server written in Node.js.
- Implements controllers (e.g., auth, chat, message, posts, users), models (like User, Post, Chat, Message, Appointments), and middleware (for authentication, file uploads, data URI handling).
- Exposes RESTful API endpoints using clearly separated routes.
- Interacts with a MongoDB database (as noted by the tech stack).
- Real-Time Communication (socket):
- A dedicated socket module (using Node) that facilitates real-time interactions (likely for chat functionalities).
- (Implicit) Database:
- While not directly represented by a dedicated directory, MongoDB is part of the tech stack. The backend’s models and data operations rely on a database.

##### Out the Relationships & Data Flow
- Frontend connecting to the Backend via HTTP/HTTPS REST API calls.
- Endpoints such as /auth, /chat, /message, /posts, /users.
- Use of Redux (state management) on the client which updates the UI based on data fetched from the backend.
- Communication between the backend and the database (MongoDB) for data persistence (CRUD operations on models like Users, Posts, Chats, etc.).
- Optionally, note any interaction between the socket module and the backend if they share authentication or data synchronization logic.

##### Architectural Patterns & Design Principles
- MVC Pattern on the Backend:
- Controllers: Handle incoming requests.
- Models: Define and interact with database entities.
- Routes: Define how different endpoints connect to controllers.
- Component-based Architecture on the Frontend:
- Separation into views (scenes: Chat, Home, Login, Profile, etc.) and reusable components (Widgets, Navbar, styled components).
- Separation of Concerns:
- Different directories for controllers, routes, middleware, models, and separate client and socket modules enhance maintainability and scalability.

##### Relevant Technologies
- Client Side: React, React Router, Redux, MUI, Tailwind CSS, and Vite as the build tool.
- Server Side: Node.js, Express.js, and MongoDB (coupled with Mongoose likely, given standard practice).
- Socket Communication: Node-based socket server to handle real-time data exchanges.
- Deployment: Vercel and Render are mentioned for hosting.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Client (Frontend)"
        A["Index HTML"]:::frontend
        B["Main Entry"]:::frontend
        C["Main App"]:::frontend
        D["Login Page"]:::frontend
        E["Login Form"]:::frontend
        F["Home Page"]:::frontend
        G["Chat Page"]:::frontend
        H["Profile Page"]:::frontend
        I["Navbar"]:::frontend
        J["Redux Store"]:::frontend
    end

    subgraph "Server (Backend)"
        K["Server Entry"]:::backend
        subgraph "Controllers"
            K1["Auth Controller"]:::backend
            K2["Chat Controller"]:::backend
            K3["Message Controller"]:::backend
            K4["Posts Controller"]:::backend
            K5["Users Controller"]:::backend
        end
        subgraph "Models"
            L1["User Model"]:::backend
            L2["Post Model"]:::backend
            L3["Chats Model"]:::backend
            L4["Message Model"]:::backend
            L5["Appointments Model"]:::backend
            L6["AcceptedAppointments Model"]:::backend
        end
        subgraph "Routes"
            M1["Auth Route"]:::backend
            M2["Chat Route"]:::backend
            M3["Message Route"]:::backend
            M4["Posts Route"]:::backend
            M5["Users Route"]:::backend
        end
        subgraph "Middleware"
            N1["Auth Middleware"]:::backend
            N2["DataUri Middleware"]:::backend
            N3["Multer Middleware"]:::backend
        end
        O["Data Operations"]:::backend
    end

    subgraph "Socket Module"
        P["Socket Server"]:::socket
    end

    Q["MongoDB Database"]:::database

    C -->|"APIcalls"| K
    D -->|"APIcalls"| K
    H -->|"APIcalls"| K
    G -->|"UsesSocket"| P
    J -->|"StateUpdate"| C
    K -->|"CRUD"| Q
    P <-->|"DataSync"| K

    click A "https://github.com/ghost-vedant/wondernot/blob/chatsystem/client/index.html"
    click B "https://github.com/ghost-vedant/wondernot/blob/chatsystem/client/src/main.jsx"
    click C "https://github.com/ghost-vedant/wondernot/blob/chatsystem/client/src/App.jsx"
    click D "https://github.com/ghost-vedant/wondernot/blob/chatsystem/client/src/scenes/login/LoginPage.jsx"
    click E "https://github.com/ghost-vedant/wondernot/blob/chatsystem/client/src/scenes/login/Form.jsx"
    click F "https://github.com/ghost-vedant/wondernot/blob/chatsystem/client/src/scenes/home/HomePage.jsx"
    click G "https://github.com/ghost-vedant/wondernot/blob/chatsystem/client/src/scenes/Chat/Chat.jsx"
    click H "https://github.com/ghost-vedant/wondernot/blob/chatsystem/client/src/scenes/profilePage/ProfilePage.jsx"
    click I "https://github.com/ghost-vedant/wondernot/blob/chatsystem/client/src/scenes/navbar/Navbar.jsx"
    click J "https://github.com/ghost-vedant/wondernot/blob/chatsystem/client/src/redux/index.js"

    click K "https://github.com/ghost-vedant/wondernot/blob/chatsystem/server/index.js"
    click K1 "https://github.com/ghost-vedant/wondernot/blob/chatsystem/server/controllers/auth.js"
    click K2 "https://github.com/ghost-vedant/wondernot/blob/chatsystem/server/controllers/chat.js"
    click K3 "https://github.com/ghost-vedant/wondernot/blob/chatsystem/server/controllers/message.js"
    click K4 "https://github.com/ghost-vedant/wondernot/blob/chatsystem/server/controllers/posts.js"
    click K5 "https://github.com/ghost-vedant/wondernot/blob/chatsystem/server/controllers/users.js"
    click L1 "https://github.com/ghost-vedant/wondernot/blob/chatsystem/server/models/User.js"
    click L2 "https://github.com/ghost-vedant/wondernot/blob/chatsystem/server/models/Post.js"
    click L3 "https://github.com/ghost-vedant/wondernot/blob/chatsystem/server/models/Chats.js"
    click L4 "https://github.com/ghost-vedant/wondernot/blob/chatsystem/server/models/Message.js"
    click L5 "https://github.com/ghost-vedant/wondernot/blob/chatsystem/server/models/Appointments.js"
    click L6 "https://github.com/ghost-vedant/wondernot/blob/chatsystem/server/models/AcceptedAppointments.js"
    click M1 "https://github.com/ghost-vedant/wondernot/blob/chatsystem/server/routes/auth.js"
    click M2 "https://github.com/ghost-vedant/wondernot/blob/chatsystem/server/routes/ChatRoute.js"
    click M3 "https://github.com/ghost-vedant/wondernot/blob/chatsystem/server/routes/message.js"
    click M4 "https://github.com/ghost-vedant/wondernot/blob/chatsystem/server/routes/posts.js"
    click M5 "https://github.com/ghost-vedant/wondernot/blob/chatsystem/server/routes/users.js"
    click N1 "https://github.com/ghost-vedant/wondernot/blob/chatsystem/server/middleware/auth.js"
    click N2 "https://github.com/ghost-vedant/wondernot/blob/chatsystem/server/middleware/dataUri.js"
    click N3 "https://github.com/ghost-vedant/wondernot/blob/chatsystem/server/middleware/multer.js"
    click O "https://github.com/ghost-vedant/wondernot/blob/chatsystem/server/data/data.js"

    click P "https://github.com/ghost-vedant/wondernot/blob/chatsystem/socket/index.js"

    classDef frontend fill:#add8e6,stroke:#333,stroke-width:2px;
    classDef backend fill:#ffcccb,stroke:#333,stroke-width:2px;
    classDef socket fill:#90ee90,stroke:#333,stroke-width:2px;
    classDef database fill:#ffffe0,stroke:#333,stroke-width:2px;
```
