# rk-41/evento architecture

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

- Interactive diagram: https://gitdiagram.com/rk-41/evento
- Repository: https://github.com/rk-41/evento

## Overview

##### Main Components
- Frontend Client:
- Built with React, utilizing TypeScript.
- Contains UI components (e.g., HomePage, Navbar, Auth, Event related components, Profile) that manage pages and interactions.
- Uses React Router for navigation and Axios for API calls.
- Integrates Socket.IO Client for real-time event updates.
- Communicates with the backend via REST API endpoints and WebSockets.

- Backend API Server:
- Built with Node.js, Express, and TypeScript.
- Contains configuration files (database setup with Mongoose, express config, and Socket.IO configuration).
- Handles authentication (JWT based) and authorization.
- Organizes routes into controllers and API endpoints (auth, events, users).
- Manages real-time events using Socket.IO (with event handlers).
- Implements middleware for authentication.

- Database:
- MongoDB is used via Mongoose, storing user and event data.

- External Services:
- Cloudinary is used for image uploads.
- Deployment platforms: Vercel for the frontend and Railway for the backend.

##### Relationships and Interactions
- Frontend, acting as the client, sending HTTP requests to the Backend’s REST API for authentication and CRUD operations related to events and users.
- The frontend’s Socket.IO Client connecting with the backend Socket.IO server to receive live updates and push real-time event notifications.
- Backend controllers interacting with the Database (MongoDB) via Mongoose models (for User and Event).
- The backend interacting with external services like Cloudinary for image management.

##### Architectural Patterns & Design Principles
- Separation of Concerns:
- The project is divided into clear frontend and backend modules.
- In the backend, configuration, routes, models, controllers, and middleware are separated into distinct directories.

- Real-Time Communication:
- The implementation of Socket.IO both on the client and server sides indicates a publish-subscribe model where events are emitted and listened to in real-time.

- API Layer and Authentication:
- RESTful API endpoints are clearly defined in the routes and controllers, with authentication handled via JWT tokens on secured endpoints.

##### Relevant Technologies, Frameworks, and Libraries
- Frontend: React, TypeScript, Vite, Axios, React Router, Socket.IO Client, Cloudinary, Framer Motion, and TailwindCSS.
- Backend: Node.js, Express, TypeScript, Mongoose (for MongoDB), Socket.IO Server, and JWT for secure authentication.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Frontend Client
    subgraph "Frontend Client (React)"
        reactApp("React App"):::frontend
        home("HomePage (UI)"):::frontend
        navbar("Navbar (UI)"):::frontend
        auth("Auth (UI)"):::frontend
        createEvent("CreateEvent (UI)"):::frontend
        eventCard("EventCard (UI)"):::frontend
        eventDetails("EventDetails (UI)"):::frontend
        events("Events (UI)"):::frontend
        profile("Profile (UI)"):::frontend
        socket("Socket.IO Client"):::frontend
        apiUtils("Axios API Utils"):::frontend
    end

    %% Backend API Server
    subgraph "Backend API Server"
        entry("Entry Point (index)"):::backend
        express("Express Server"):::backend
        config("Configuration (Database/Express/Socket)"):::backend
        controllers("Controllers (Auth,Events,Users)"):::backend
        middleware("Middleware (Auth)"):::backend
        routes("Routes (Auth,Events,Users)"):::backend
        socketHandler("Socket Event Handler"):::backend
    end

    %% Database Layer
    subgraph "Database"
        mongo("MongoDB (via Mongoose)"):::database
    end

    %% External Services & Deployment
    subgraph "External Services & Deployment"
        cloudinary("Cloudinary"):::external
        vercel("Vercel (Frontend Deployment)"):::external
        railway("Railway (Backend Deployment)"):::external
    end

    %% Frontend Internal Relationships
    reactApp -->|"renders"| home
    reactApp -->|"renders"| navbar
    reactApp -->|"renders"| auth
    reactApp -->|"renders"| createEvent
    reactApp -->|"renders"| eventCard
    reactApp -->|"renders"| eventDetails
    reactApp -->|"renders"| events
    reactApp -->|"renders"| profile
    reactApp -->|"utilizes"| socket
    reactApp -->|"utilizes"| apiUtils

    %% Frontend to Backend Communication
    reactApp -->|"REST_API"| express
    socket -->|"Socket_IO"| socketHandler

    %% Backend Internal Relationships
    entry --> express
    express --> config
    express --> routes
    express --> middleware
    express --> socketHandler
    routes --> controllers

    %% Backend to Database Communication
    controllers -->|"CRUD"| mongo

    %% Backend to External Services Communication
    controllers -->|"ImageUpload"| cloudinary

    %% Deployment Links
    reactApp -->|"Deployed_on"| vercel
    express -->|"Deployed_on"| railway

    %% Styles
    classDef frontend fill:#b3cde0,stroke:#03396c,stroke-width:2px;
    classDef backend fill:#f6b2b2,stroke:#d11149,stroke-width:2px;
    classDef database fill:#cdebb0,stroke:#4CAF50,stroke-width:2px;
    classDef external fill:#fefbd8,stroke:#f7d002,stroke-width:2px;

    %% Click Events for Frontend Components
    click reactApp "https://github.com/rk-41/evento/tree/main/frontend/src"
    click home "https://github.com/rk-41/evento/blob/main/frontend/src/components/HomePage.tsx"
    click navbar "https://github.com/rk-41/evento/blob/main/frontend/src/components/Navbar.tsx"
    click auth "https://github.com/rk-41/evento/blob/main/frontend/src/components/Auth.tsx"
    click createEvent "https://github.com/rk-41/evento/blob/main/frontend/src/components/CreateEvent.tsx"
    click eventCard "https://github.com/rk-41/evento/blob/main/frontend/src/components/EventCard.tsx"
    click eventDetails "https://github.com/rk-41/evento/blob/main/frontend/src/components/EventDetails.tsx"
    click events "https://github.com/rk-41/evento/blob/main/frontend/src/components/Events.tsx"
    click profile "https://github.com/rk-41/evento/blob/main/frontend/src/components/Profile.tsx"
    click socket "https://github.com/rk-41/evento/blob/main/frontend/src/context/SocketContext.tsx"
    click apiUtils "https://github.com/rk-41/evento/blob/main/frontend/src/utils/axios.ts"

    %% Click Events for Backend Components
    click entry "https://github.com/rk-41/evento/blob/main/backend/src/index.ts"
    click config "https://github.com/rk-41/evento/blob/main/backend/src/config/express.ts"
    click controllers "https://github.com/rk-41/evento/blob/main/backend/src/controllers/authController.ts"
    click middleware "https://github.com/rk-41/evento/blob/main/backend/src/middleware/auth.ts"
    click routes "https://github.com/rk-41/evento/blob/main/backend/src/routes/api/authRoutes.ts"
    click socketHandler "https://github.com/rk-41/evento/blob/main/backend/src/socket/eventHandlers.ts"

    %% Click Events for Database Models
    click mongo "https://github.com/rk-41/evento/blob/main/backend/src/models/User.ts"

    %% Click Event for Frontend Deployment
    click vercel "https://github.com/rk-41/evento/blob/main/frontend/vercel.json"
```
