# karankumar-97/gigverse architecture

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

- Interactive diagram: https://gitdiagram.com/karankumar-97/gigverse
- Repository: https://github.com/karankumar-97/gigverse

## Overview

##### Main Components
- Frontend Client: This is the React application residing in the "frontend" directory. It is responsible for handling the UI, user interactions (such as gig browsing, messaging, order management, and payment flows) and state management (using libraries like React Query and Zustand).
- Backend Server: Located in the "backend" folder, this uses Node.js and Express. It is structured with controllers, models, routes, and middleware (like JWT for authentication). Each controller (auth, conversation, gig, message, order, payment, review, user) handles a specific domain of functionality.
- Database: Although not seen in the file tree, the README mentions MongoDB. This database stores data for users, gigs, orders, reviews, etc.
- External Services: Consider external services such as a payment gateway (as evident from the "payment.controller.js" and "payment.model.js") and possibly image storage or third-party API endpoints (such as file uploads).

##### Relationships and Interactions
- User authentication flow (login, registration) to emphasize the secure handling of user sessions using JWT tokens.

##### Architectural Patterns and Design Elements
- RESTful API Architecture: Different routes (auth, gig, message, etc.) each map to corresponding controllers.
- MVC (Model-View-Controller) Pattern in the Backend:
- Models (in “backend/models”) define the data structure.
- Controllers (in “backend/controllers”) handle the business logic.
- Routes (in “backend/routes”) define the API endpoints.
- Frontend’s component-based structure: Segregate pages and reusable components (e.g., Navbar, Footer, GigCard) which interact with the backend.

##### Relevant Technologies, Frameworks, and Libraries
- Frontend: React (with pages and components), Tailwind CSS, Vite for bundling, React Query for data fetching, Zustand for state management.
- Backend: Express.js for API building, JWT for authentication, bcrypt for security, and Node.js for runtime.
- Database: MongoDB (implied via the MERN stack).
- Additional Deployment: Vercel configuration files (for both frontend and backend).

##### Putting It All Together
- Middleware (such as "JWT Authentication") as an overlapped layer in the backend flow.
- Respective controllers/models to a "MongoDB Database" block that stores relevant data.
- Optionally, add an "External Payment Service" block linked to the "Payment Controller" to indicate third-party integrations.
- Interactions (e.g., Gig creation, order processing, messaging, filtering/searching gigs) are represented to capture the full scope of the platform’s functionalities.

## Diagram (Mermaid)

```mermaid
graph TD
    U["User"]:::external
    FE["Frontend (React App)"]:::frontend
    BA["Backend API Gateway (Express Server)"]:::backend
    DB["MongoDB Database"]:::database
    extP["External Payment Service"]:::external

    %% User interacts with Frontend
    U -->|"uses"| FE
    %% Frontend makes API calls to Backend
    FE -->|"calls API"| BA

    %% Authentication Module
    BA --> authR["Auth Route"]:::route
    authR --> jwtM["JWT Middleware"]:::middleware
    jwtM --> authC["Auth Controller"]:::controller
    authC -->|"stores/fetches"| DB

    %% Gig Management Module
    BA --> gigR["Gig Route"]:::route
    gigR --> gigC["Gig Controller"]:::controller
    gigC --> gigM["Gig Model"]:::model
    gigM -->|"persists"| DB

    %% Conversation Module (Messaging)
    BA --> convR["Conversation Route"]:::route
    convR --> convC["Conversation Controller"]:::controller
    convC --> convM["Conversation Model"]:::model
    convM -->|"persists"| DB

    %% Message Module (Messaging)
    BA --> msgR["Message Route"]:::route
    msgR --> msgC["Message Controller"]:::controller
    msgC --> msgM["Message Model"]:::model
    msgM -->|"persists"| DB
    %% Link between Conversation and Message controllers
    convC -->|"triggers"| msgC

    %% Order Processing Module
    BA --> orderR["Order Route"]:::route
    orderR --> orderC["Order Controller"]:::controller
    orderC --> orderM["Order Model"]:::model
    orderM -->|"persists"| DB

    %% Payment Processing Module
    BA --> payR["Payment Route"]:::route
    payR --> payC["Payment Controller"]:::controller
    payC --> payM["Payment Model"]:::model
    payM -->|"persists"| DB
    payC -->|"calls"| extP

    %% Reviews Handling Module
    BA --> revR["Review Route"]:::route
    revR --> revC["Review Controller"]:::controller
    revC --> revM["Review Model"]:::model
    revM -->|"persists"| DB

    %% User Profile Management Module
    BA --> userR["User Route"]:::route
    userR --> userC["User Controller"]:::controller
    userC --> userM["User Model"]:::model
    userM -->|"persists"| DB

    %% Click Events
    click FE "https://github.com/karankumar-97/gigverse/tree/main/frontend/"
    click BA "https://github.com/karankumar-97/gigverse/tree/main/backend/"
    click authC "https://github.com/karankumar-97/gigverse/blob/main/backend/controllers/auth.controller.js"
    click jwtM "https://github.com/karankumar-97/gigverse/blob/main/backend/middleware/jwt.js"
    click authR "https://github.com/karankumar-97/gigverse/blob/main/backend/routes/auth.route.js"
    click gigC "https://github.com/karankumar-97/gigverse/blob/main/backend/controllers/gig.controller.js"
    click gigM "https://github.com/karankumar-97/gigverse/blob/main/backend/models/gig.model.js"
    click gigR "https://github.com/karankumar-97/gigverse/blob/main/backend/routes/gig.route.js"
    click convC "https://github.com/karankumar-97/gigverse/blob/main/backend/controllers/conversation.controller.js"
    click convM "https://github.com/karankumar-97/gigverse/blob/main/backend/models/conversation.model.js"
    click convR "https://github.com/karankumar-97/gigverse/blob/main/backend/routes/conversation.route.js"
    click msgC "https://github.com/karankumar-97/gigverse/blob/main/backend/controllers/message.controller.js"
    click msgM "https://github.com/karankumar-97/gigverse/blob/main/backend/models/message.model.js"
    click msgR "https://github.com/karankumar-97/gigverse/blob/main/backend/routes/message.route.js"
    click orderC "https://github.com/karankumar-97/gigverse/blob/main/backend/controllers/order.controller.js"
    click orderM "https://github.com/karankumar-97/gigverse/blob/main/backend/models/order.model.js"
    click orderR "https://github.com/karankumar-97/gigverse/blob/main/backend/routes/order.route.js"
    click payC "https://github.com/karankumar-97/gigverse/blob/main/backend/controllers/payment.controller.js"
    click payM "https://github.com/karankumar-97/gigverse/blob/main/backend/models/payment.model.js"
    click payR "https://github.com/karankumar-97/gigverse/blob/main/backend/routes/payment.route.js"
    click revC "https://github.com/karankumar-97/gigverse/blob/main/backend/controllers/review.controller.js"
    click revM "https://github.com/karankumar-97/gigverse/blob/main/backend/models/review.model.js"
    click revR "https://github.com/karankumar-97/gigverse/blob/main/backend/routes/review.route.js"
    click userC "https://github.com/karankumar-97/gigverse/blob/main/backend/controllers/user.controller.js"
    click userM "https://github.com/karankumar-97/gigverse/blob/main/backend/models/user.model.js"
    click userR "https://github.com/karankumar-97/gigverse/blob/main/backend/routes/user.route.js"

    %% Styles
    classDef frontend fill:#C8E6C9,stroke:#2E7D32,stroke-width:2px;
    classDef backend fill:#BBDEFB,stroke:#1565C0,stroke-width:2px;
    classDef route fill:#FFECB3,stroke:#FF8F00,stroke-width:2px;
    classDef controller fill:#D1C4E9,stroke:#6A1B9A,stroke-width:2px;
    classDef middleware fill:#F8BBD0,stroke:#AD1457,stroke-width:2px;
    classDef model fill:#FFF9C4,stroke:#F9A825,stroke-width:2px;
    classDef database fill:#FFE0B2,stroke:#E64A19,stroke-width:2px;
    classDef external fill:#B2EBF2,stroke:#00838F,stroke-width:2px;
```
