# ruboma/social-network-git architecture

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

- Interactive diagram: https://gitdiagram.com/ruboma/social-network-git
- Repository: https://github.com/ruboma/social-network-git

## Overview

##### Project type and purpose
- This is a full-stack social networking application.
- Frontend: Next.js app providing pages for feed, profiles, groups, chats, etc.
- Backend: Go-based REST + WebSocket API server handling authentication, feed generation, posts, comments, chat, groups, notifications, and sessions.
- Database: Relational store (migrations present) for users, posts, comments, groups, followers, sessions, notifications, messages.
- File storage: Local “uploads” folders for images (profile, post, comment).
- Orchestrated via Docker Compose with separate containers for frontend, backend, and (implied) database.

##### File structure
- Top-level directories “frontend” and “backend” encapsulate the two main components.
- backend/app contains HTTP handlers grouped by feature (chat, feed, posts, users, etc.).
- backend/server implements server bootstrapping and WebSocket entry point.
- backend/database holds DB connection, CRUD logic, and SQL migrations.
- frontend/app follows Next.js 13 “app” directory with page.js routes and component structure under components, context, group, etc.
- docker-compose.yml and start.sh orchestrate services.

##### README for additional insights
- Frontend: Next.js, tailwind, uses create-next-app blueprint, listens on port 3000.
- Backend: Simple “go run .” startup; implicitly listens on a port (e.g., 8080).
- No mention of external third-party services—purely local Docker network.

##### Elements
- Green for UI components (Browser & Next.js)
- Blue for API/backend (Go service)
- Orange for data/storage (DB & file system)
- Inside DB, annotate tables or migration sets (Users, Posts, Comments, Followers, Groups, Requests, Notifications, Sessions, Messages)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% UI Layer
    subgraph "UI Layer" 
        Browser["Browser (React UI)"]:::ui
    end

    %% Frontend Layer
    subgraph "Next.js Frontend Service (Node.js Container)" 
        direction TB
        FN_Dockerfile["Dockerfile"]:::frontend
        FN_nextconf["next.config.mjs"]:::frontend
        FN_middleware["middleware.js"]:::frontend
        FN_jsconfig["jsconfig.json"]:::frontend
        FN_package["package.json"]:::frontend
    end

    %% Backend Layer
    subgraph "Go API Service (REST + WebSocket)" 
        direction TB
        GO_main["main.go"]:::backend
        GO_Dockerfile["Dockerfile"]:::backend
        GO_server["server.go"]:::backend
        GO_ws["websocket.go"]:::backend
        GO_api["APIHandler.go"]:::backend
        GO_utils["utils.go"]:::backend

        subgraph "Auth & Sessions"
            auth["auth.go"]:::backend
            session["session.go"]:::backend
            users["users.go"]:::backend
        end

        subgraph "Feed & Posts"
            feed["feed.go"]:::backend
            posts["posts.go"]:::backend
            images["images.go"]:::backend
        end

        subgraph "Comments"
            comments_img["images.go"]:::backend
        end

        subgraph "Chat Manager"
            chat_handler["handler.go"]:::backend
            chat_manager["manager.go"]:::backend
        end

        subgraph "Notifications"
            notifications["notifications.go"]:::backend
        end

        subgraph "Profile & Search"
            profile["profile.go"]:::backend
            search["search.go"]:::backend
        end

        subgraph "Groups & Membership"
            groups["groups.go"]:::backend
            requests["requests.go"]:::backend
            followers["followers.go"]:::backend
        end

        WebSocketHub["WebSocket Hub"]:::backend
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        Database["Relational Database"]:::storage
        FileStorage["File Storage (uploads)"]:::storage
    end

    %% Orchestration
    subgraph "Orchestration"
        docker_compose["docker-compose.yml"]:::container
        start_sh["start.sh"]:::container
    end

    %% Connections
    Browser -->|HTTP/HTTPS| BrowserToNext["Next.js App Router"]:::frontend
    BrowserToNext -->|HTTP/HTTPS| NextJSService["Next.js Frontend Service"]:::frontend
    NextJSService -->|HTTP/HTTPS| GO_main
    Browser -->|WebSocket| WebSocketHub
    GO_main -->|SQL| Database
    GO_main -->|File I/O| FileStorage

    %% File group arrows
    NextJSService --> FN_Dockerfile
    NextJSService --> FN_nextconf
    NextJSService --> FN_middleware
    NextJSService --> FN_jsconfig
    NextJSService --> FN_package

    GO_main --> GO_Dockerfile
    GO_main --> GO_server
    GO_main --> GO_ws
    GO_main --> GO_api
    GO_main --> GO_utils

    %% Docker orchestration
    docker_compose --> NextJSService
    docker_compose --> GO_main
    docker_compose --> Database

    start_sh --> docker_compose

    %% Click Events
    click Browser "https://github.com/ruboma/social-network-git/tree/main/frontend/app"
    click FN_Dockerfile "https://github.com/ruboma/social-network-git/tree/main/frontend/Dockerfile"
    click FN_nextconf "https://github.com/ruboma/social-network-git/blob/main/frontend/next.config.mjs"
    click FN_middleware "https://github.com/ruboma/social-network-git/blob/main/frontend/middleware.js"
    click FN_jsconfig "https://github.com/ruboma/social-network-git/blob/main/frontend/jsconfig.json"
    click FN_package "https://github.com/ruboma/social-network-git/blob/main/frontend/package.json"
    click GO_main "https://github.com/ruboma/social-network-git/blob/main/backend/main.go"
    click GO_Dockerfile "https://github.com/ruboma/social-network-git/tree/main/backend/Dockerfile"
    click GO_server "https://github.com/ruboma/social-network-git/blob/main/backend/server/server.go"
    click GO_ws "https://github.com/ruboma/social-network-git/blob/main/backend/server/websocket.go"
    click GO_api "https://github.com/ruboma/social-network-git/blob/main/backend/app/APIHandler.go"
    click GO_utils "https://github.com/ruboma/social-network-git/blob/main/backend/app/utils.go"
    click auth "https://github.com/ruboma/social-network-git/blob/main/backend/app/auth.go"
    click session "https://github.com/ruboma/social-network-git/blob/main/backend/app/session.go"
    click users "https://github.com/ruboma/social-network-git/blob/main/backend/app/users.go"
    click feed "https://github.com/ruboma/social-network-git/blob/main/backend/app/feed.go"
    click posts "https://github.com/ruboma/social-network-git/blob/main/backend/app/posts.go"
    click images "https://github.com/ruboma/social-network-git/blob/main/backend/app/images.go"
    click chat_handler "https://github.com/ruboma/social-network-git/blob/main/backend/app/chat/handler.go"
    click chat_manager "https://github.com/ruboma/social-network-git/blob/main/backend/app/chat/manager.go"
    click notifications "https://github.com/ruboma/social-network-git/blob/main/backend/app/notifications.go"
    click profile "https://github.com/ruboma/social-network-git/blob/main/backend/app/profile.go"
    click search "https://github.com/ruboma/social-network-git/blob/main/backend/app/search.go"
    click groups "https://github.com/ruboma/social-network-git/blob/main/backend/app/groups.go"
    click requests "https://github.com/ruboma/social-network-git/blob/main/backend/app/requests.go"
    click followers "https://github.com/ruboma/social-network-git/blob/main/backend/app/followers.go"
    click docker_compose "https://github.com/ruboma/social-network-git/blob/main/docker-compose.yml"
    click start_sh "https://github.com/ruboma/social-network-git/blob/main/start.sh"

    %% Styles
    classDef ui fill:#e0f7fa,stroke:#000
    classDef frontend fill:#c8e6c9,stroke:#000
    classDef backend fill:#bbdefb,stroke:#000
    classDef storage fill:#ffe0b2,stroke:#000
    classDef container fill:#f0f4c3,stroke:#000
```
