# vladman-25/mycircle architecture

> Architecture diagram of the GitHub repository vladman-25/mycircle, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vladman-25/mycircle
- Repository: https://github.com/vladman-25/mycircle

## Overview

##### Main Components Overview

a) Client Layer (Frontend)
- React Application (Port 3001)
- Component structure showing main features:
- Authentication (Login/Register)
- Feed System
- Chat System
- Page Management
- Post Management
- User Management

b) Server Layer (Backend - Port 5000)
- Node.js Application
- Express Server
- API Routes
- Controllers
- Models

c) Database Layer
- MongoDB

d) Infrastructure Layer
- Nginx (Port 80/443)
- PM2 Process Manager
- SSL/TLS (Certbot)

##### Component Relationships

a) External Traffic Flow:
- HTTPS Traffic → Nginx (Port 80/443)
- Nginx → Frontend (Port 3001)
- Nginx → Backend API (Port 5000)

b) Internal Communications:
- Frontend → Backend API Routes
- Backend Controllers → MongoDB
- WebSocket Connections for Chat Features

##### Specific Component Details

Frontend Section:
- Auth Module
- Feed Component
- Chat System
- User Management
- Page Management
- Post/Comment System
- Search Functionality

Backend Section:
- Controllers by functionality:
- Authentication
- User Management
- Content Management (Posts/Pages)
- Real-time Features (Chat/Messages)
- Social Features (Friends/Likes)

##### Notes Section

Notes about:
- Deployment workflow
- Environment-specific configurations
- Security measures
- Scaling considerations

This system design should clearly show how the application handles both synchronous (REST API) and asynchronous (WebSocket) communications, as well as the file storage system for media uploads.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph External
        Client(("Client Browser")):::client
    end

    subgraph Infrastructure
        Nginx["Nginx Reverse Proxy<br/>(Port 80/443)"]:::infra
        PM2["PM2 Process Manager"]:::infra
        SSL["SSL/TLS (Certbot)"]:::security
    end

    subgraph Frontend["Frontend Layer (Port 3001)"]
        Auth["Authentication Module"]:::frontend
        Feed["Feed System"]:::frontend
        Chat["Chat System"]:::frontend
        PageMgmt["Page Management"]:::frontend
        PostMgmt["Post Management"]:::frontend
        UserMgmt["User Management"]:::frontend
        Search["Search Functionality"]:::frontend
        MiniChat["Mini Chat"]:::frontend
    end

    subgraph Backend["Backend Layer (Port 5000)"]
        direction TB
        ExpressServer["Express Server"]:::backend
        
        subgraph Controllers
            AuthC["Auth Controller"]:::controller
            ChatC["Chat Controller"]:::controller
            PostC["Post Controller"]:::controller
            UserC["User Controller"]:::controller
            PageC["Page Controller"]:::controller
            SearchC["Search Controller"]:::controller
            FriendsC["Friends Controller"]:::controller
        end

        subgraph Routes
            AuthR["Auth Routes"]:::route
            ChatR["Chat Routes"]:::route
            PostR["Post Routes"]:::route
            UserR["User Routes"]:::route
            PageR["Page Routes"]:::route
            SearchR["Search Routes"]:::route
            FriendsR["Friends Routes"]:::route
        end

        subgraph Models
            UserM["User Model"]:::model
            PostM["Post Model"]:::model
            PageM["Page Model"]:::model
            MessageM["Message Model"]:::model
            RoomM["Room Model"]:::model
        end
    end

    subgraph Database
        MongoDB[(MongoDB)]:::database
    end

    %% Connections
    Client --> Nginx
    Nginx --> Frontend
    Nginx --> ExpressServer

    %% Frontend Internal Connections
    Auth --> ExpressServer
    Feed --> ExpressServer
    Chat --> ExpressServer
    PageMgmt --> ExpressServer
    PostMgmt --> ExpressServer
    UserMgmt --> ExpressServer
    Search --> ExpressServer
    Chat --> MiniChat

    %% Backend Route to Controller Connections
    AuthR --> AuthC
    ChatR --> ChatC
    PostR --> PostC
    UserR --> UserC
    PageR --> PageC
    SearchR --> SearchC
    FriendsR --> FriendsC

    %% Controller to Model Connections
    AuthC --> UserM
    ChatC --> MessageM
    ChatC --> RoomM
    PostC --> PostM
    UserC --> UserM
    PageC --> PageM
    
    %% Database Connections
    UserM --> MongoDB
    PostM --> MongoDB
    PageM --> MongoDB
    MessageM --> MongoDB
    RoomM --> MongoDB

    %% Infrastructure Connections
    SSL --> Nginx
    PM2 --> ExpressServer

    %% Click Events
    click Auth "https://github.com/vladman-25/MyCircle/blob/master/frontend/src/modules/Auth.js"
    click Feed "https://github.com/vladman-25/MyCircle/blob/master/frontend/src/components/Feed/Feed.jsx"
    click Chat "https://github.com/vladman-25/MyCircle/blob/master/frontend/src/components/Chat/Chat.jsx"
    click MiniChat "https://github.com/vladman-25/MyCircle/blob/master/frontend/src/components/Feed/Minichat/Minichat.jsx"
    click PageMgmt "https://github.com/vladman-25/MyCircle/blob/master/frontend/src/components/Page/Page.jsx"
    click PostMgmt "https://github.com/vladman-25/MyCircle/blob/master/frontend/src/components/Post/Post.jsx"
    click UserMgmt "https://github.com/vladman-25/MyCircle/blob/master/frontend/src/components/User/User.jsx"
    click Search "https://github.com/vladman-25/MyCircle/blob/master/frontend/src/components/Searchbar/Searchbar.jsx"
    click AuthC "https://github.com/vladman-25/MyCircle/blob/master/backend/controllers/auth.js"
    click ChatC "https://github.com/vladman-25/MyCircle/blob/master/backend/controllers/chat.js"
    click PostC "https://github.com/vladman-25/MyCircle/blob/master/backend/controllers/post.js"
    click UserC "https://github.com/vladman-25/MyCircle/blob/master/backend/controllers/user.js"
    click PageC "https://github.com/vladman-25/MyCircle/blob/master/backend/controllers/page.js"
    click SearchC "https://github.com/vladman-25/MyCircle/blob/master/backend/controllers/search.js"
    click FriendsC "https://github.com/vladman-25/MyCircle/blob/master/backend/controllers/friends.js"
    click AuthR "https://github.com/vladman-25/MyCircle/blob/master/backend/routes/auth.routes.js"
    click ChatR "https://github.com/vladman-25/MyCircle/blob/master/backend/routes/chat.routes.js"
    click PostR "https://github.com/vladman-25/MyCircle/blob/master/backend/routes/post.routes.js"
    click UserR "https://github.com/vladman-25/MyCircle/blob/master/backend/routes/user.routes.js"
    click PageR "https://github.com/vladman-25/MyCircle/blob/master/backend/routes/page.routes.js"
    click SearchR "https://github.com/vladman-25/MyCircle/blob/master/backend/routes/search.routes.js"
    click FriendsR "https://github.com/vladman-25/MyCircle/blob/master/backend/routes/friends.routes.js"
    click UserM "https://github.com/vladman-25/MyCircle/blob/master/backend/models/user.model.js"
    click PostM "https://github.com/vladman-25/MyCircle/blob/master/backend/models/post.model.js"
    click PageM "https://github.com/vladman-25/MyCircle/blob/master/backend/models/page.model.js"
    click MessageM "https://github.com/vladman-25/MyCircle/blob/master/backend/models/message.model.js"
    click RoomM "https://github.com/vladman-25/MyCircle/blob/master/backend/models/room.model.js"

    %% Styling
    classDef client fill:#f9f,stroke:#333,stroke-width:2px
    classDef frontend fill:#a8d1ff,stroke:#333
    classDef backend fill:#aaffb0,stroke:#333
    classDef database fill:#ffdb99,stroke:#333
    classDef infra fill:#e6e6e6,stroke:#333
    classDef security fill:#ff9999,stroke:#333
    classDef controller fill:#90EE90,stroke:#333
    classDef route fill:#98FB98,stroke:#333
    classDef model fill:#3CB371,stroke:#333
```
