# muratozte/unisocial architecture

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

- Interactive diagram: https://gitdiagram.com/muratozte/unisocial
- Repository: https://github.com/muratozte/unisocial

## Overview

##### Project Type and Purpose
- This is a full-stack, Next.js-based social/community platform.
- Frontend: React components under src/app for pages like feed, clubs, events, messages, profile, registration flows (student/teacher/community).
- Backend: Next.js API routes (serverless functions) under src/app/api that handle authentication, user profiles, posts, comments, events, communities, followers, messaging.
- Data layer: Prisma ORM (prisma/schema.prisma) connecting to a relational database (e.g. PostgreSQL).
- State management: Redux Toolkit slices in src/store and React hooks for data fetching.
- Styling: Tailwind CSS and global styles.

##### File Structure
- Top-level config: next.config.mjs, tailwind.config.js, jsconfig.json.
- prisma/schema.prisma: defines your data model.
- src/app: Next.js App Router directory.
- (site) subtree: UI pages and layout, page.jsx files for each route.
- api subtree: REST-style endpoints grouped by domain (auth, user, post, comment, event, community, news, following).
- src/components: UI component library organized by feature (Login, Nav, Profile, Register, Feed, Clubs, Events, Messages, Settings, common, etc.).
- src/hooks: custom React hooks for data fetching and local UI state.
- src/store: Redux Toolkit store and slices for global state (login, feed, events, ui, register).
- src/util: service modules (authService, feedService, timeService).
- Static assets: src/assets (images, logos), fonts, global CSS.

##### README for Additional Insights
- Confirms Next.js App Router, font optimization, Vercel deployment path.

a. Main Components
- Client Browser: React/Next.js pages, components, client-side routing & state store.
- Next.js Runtime (Vercel/Serverless):
– App Router rendering (SSR, SSG, ISR)
– API Routes (serverless functions)
- State Management: Redux store (slices), React Query-style hooks.
- Business Logic / Services: authService, feedService, timeService.
- ORM Layer: Prisma Client.
- Database: PostgreSQL (or equivalent).
- Static Assets & CDN: images, fonts, global CSS, Tailwind.
- Optional External Services: Email/SMS provider, third-party OAuth, analytics.

b. Relationships & Data Flow
1. User → Browser UI → Next.js Pages
2. Browser UI dispatches actions to Redux store and calls React hooks → calls API endpoints.
3. API Route receives HTTP request → invokes service module → uses Prisma Client → reads/writes Database.
4. Database response bubbled up → Prisma → service → API Route → JSON → UI.
5. SSR/SSG data fetching: Next.js page gets data server‐side via API/services/Prisma.
6. Static assets served from CDN or Vercel edge.

c. Architectural Patterns & Design Principles
- Separation of concerns:
- UI components vs. data hooks vs. services vs. database schema.
- Modular API: each domain has its own folder grouping related routes.
- State centralization: Redux Toolkit for global state slices.
- File‐based routing: Next.js App Router for pages and API.
- Serverless functions: stateless, auto-scaled endpoints.
- ORM-based data modeling and migrations with Prisma.
- Component Driven Development: reusable UI building blocks.

d. Key Technologies & Frameworks
- Next.js (App Router, serverless API routes)
- React (functional components, hooks)
- Redux Toolkit (store, slices)
- Prisma ORM (schema, migrations, client)
- PostgreSQL or MySQL
- Tailwind CSS, postcss
- Vercel (hosting, CDN)
- Node.js runtime

## Diagram (Mermaid)

```mermaid
graph TB
    %% Frontend Layer
    subgraph "Frontend (Browser UI)"
        direction TB
        subgraph "Pages" 
            direction TB
            FeedPage["Feed Page"]:::ui
            ClubsPage["Clubs Page"]:::ui
            EventsPage["Events Page"]:::ui
            MessagesPage["Messages Page"]:::ui
            ProfilePage["Profile Page"]:::ui
            LoginPage["Login Page"]:::ui
            RegCommPage["Register Community Page"]:::ui
            RegStudPage["Register Student Page"]:::ui
            RegTeachPage["Register Teacher Page"]:::ui
            UserProfilePage["User Profile Page"]:::ui
        end
        subgraph "State Management"
            direction TB
            Store["Redux Store"]:::service
            Provider["Redux Provider"]:::service
            LoginSlice["Login Slice"]:::service
            RegisterSlice["Register Slice"]:::service
            FeedSlice["Feed Slice"]:::service
            EventsSlice["Events Slice"]:::service
            UiSlice["UI Slice"]:::service
        end
        subgraph "Custom Hooks"
            direction TB
            FetchPosts["useFetchPosts"]:::service
            FetchEvents["useFetchEvents"]:::service
            FetchComms["useCommunities"]:::service
            UseProfile["useProfile"]:::service
        end
        subgraph "Static Assets & Styles"
            direction TB
            Globals["globals.css, tailwind.config.js"]:::cdn
            Fonts["Fonts"]:::cdn
            Images["Images & Logos"]:::cdn
        end
    end

    %% Backend Layer
    subgraph "Backend (Serverless API)"
        direction TB
        subgraph "API Routes"
            direction TB
            subgraph "Auth" 
                LoginAPI["Login API"]:::api
                RegCommAPI["Register Community API"]:::api
                RegStudAPI["Register Student API"]:::api
                RegTeachAPI["Register Teacher API"]:::api
                ValidationAPI["Validation API"]:::api
            end
            subgraph "User"
                GetAboutAPI["Get About API"]:::api
                UpdateAboutAPI["Update About API"]:::api
            end
            subgraph "Post"
                AddPostAPI["Add Post API"]:::api
                GetAllPostsAPI["Get All Posts API"]:::api
            end
        end
        subgraph "Services"
            AuthService["authService"]:::service
            FeedService["feedService"]:::service
            TimeService["timeService"]:::service
        end
        subgraph "ORM Layer"
            PrismaClient["Prisma Client"]:::db
        end
        DB["Database (PostgreSQL)"]:::db
    end

    %% External Services
    subgraph "External Services & CDN"
        direction TB
        CDN["CDN / Vercel Edge"]:::cdn
        ExtServices["Email/SMS/OAuth/Analytics"]:::cdn
    end

    %% Relationships
    FeedPage -->|"dispatch & hook calls"| FetchPosts
    ClubsPage -->|"dispatch & hook calls"| FetchComms
    EventsPage -->|"dispatch & hook calls"| FetchEvents
    ProfilePage -->|"dispatch & hook calls"| UseProfile
    *.Page -->|"renders via Next.js"| Store
    *.Page -->|"uses global styles & assets"| Globals
    Globals -->|served by| CDN

    Store -->|provides state to| Provider
    Provider -->|wraps UI| FeedPage

    FetchPosts -->|calls| AddPostAPI
    FetchEvents -->|calls| GetAllPostsAPI

    %% API to Services
    LoginAPI -->|uses| AuthService
    RegCommAPI -->|uses| AuthService
    AddPostAPI -->|uses| FeedService

    %% Services to ORM
    AuthService -->|queries| PrismaClient
    FeedService -->|queries| PrismaClient
    TimeService -->|utilized by| FeedService

    %% ORM to Database
    PrismaClient -->|reads/writes| DB

    %% SSR/SSG flow
    ProfilePage -->|SSR/SSG data| PrismaClient

    %% CDN
    Images -->|served by| CDN
    Fonts -->|served by| CDN

    %% Click Events
    click FeedPage "https://github.com/muratozte/unisocial/blob/main/src/app/(site)/feed/page.jsx"
    click ClubsPage "https://github.com/muratozte/unisocial/blob/main/src/app/(site)/clubs/page.jsx"
    click EventsPage "https://github.com/muratozte/unisocial/blob/main/src/app/(site)/events/page.jsx"
    click MessagesPage "https://github.com/muratozte/unisocial/blob/main/src/app/(site)/messages/page.jsx"
    click ProfilePage "https://github.com/muratozte/unisocial/blob/main/src/app/(site)/profile/page.jsx"
    click LoginPage "https://github.com/muratozte/unisocial/blob/main/src/app/(site)/login/page.jsx"
    click RegCommPage "https://github.com/muratozte/unisocial/blob/main/src/app/(site)/register/community/page.jsx"
    click RegStudPage "https://github.com/muratozte/unisocial/blob/main/src/app/(site)/register/student/page.jsx"
    click RegTeachPage "https://github.com/muratozte/unisocial/blob/main/src/app/(site)/register/teacher/page.jsx"
    click UserProfilePage "https://github.com/muratozte/unisocial/blob/main/src/app/(site)/user/[id]/page.jsx"

    click LoginAPI "https://github.com/muratozte/unisocial/blob/main/src/app/api/(auth)/login/route.js"
    click RegCommAPI "https://github.com/muratozte/unisocial/blob/main/src/app/api/(auth)/register/community/route.js"
    click RegStudAPI "https://github.com/muratozte/unisocial/blob/main/src/app/api/(auth)/register/student/route.js"
    click RegTeachAPI "https://github.com/muratozte/unisocial/blob/main/src/app/api/(auth)/register/teacher/route.js"
    click ValidationAPI "https://github.com/muratozte/unisocial/blob/main/src/app/api/(auth)/validation/route.js"

    click GetAboutAPI "https://github.com/muratozte/unisocial/blob/main/src/app/api/(user)/get-about/route.js"
    click UpdateAboutAPI "https://github.com/muratozte/unisocial/blob/main/src/app/api/(user)/update-about/route.js"

    click AddPostAPI "https://github.com/muratozte/unisocial/blob/main/src/app/api/(post)/add-post/route.js"
    click GetAllPostsAPI "https://github.com/muratozte/unisocial/blob/main/src/app/api/(post)/get-all-posts/route.js"

    click AuthService "https://github.com/muratozte/unisocial/blob/main/src/util/authService.js"
    click FeedService "https://github.com/muratozte/unisocial/blob/main/src/util/feedService.js"
    click TimeService "https://github.com/muratozte/unisocial/blob/main/src/util/timeService.js"

    click PrismaClient "https://github.com/muratozte/unisocial/blob/main/prisma/schema.prisma"

    click Store "https://github.com/muratozte/unisocial/blob/main/src/store/Store.js"
    click Provider "https://github.com/muratozte/unisocial/blob/main/src/store/Provider.jsx"
    click LoginSlice "https://github.com/muratozte/unisocial/blob/main/src/store/Slices/LoginSlice.js"
    click RegisterSlice "https://github.com/muratozte/unisocial/blob/main/src/store/Slices/RegisterSlice.js"
    click FeedSlice "https://github.com/muratozte/unisocial/blob/main/src/store/Slices/FeedSlice.js"
    click EventsSlice "https://github.com/muratozte/unisocial/blob/main/src/store/Slices/eventsSlice.js"
    click UiSlice "https://github.com/muratozte/unisocial/blob/main/src/store/Slices/uiSlice.js"

    click FetchPosts "https://github.com/muratozte/unisocial/blob/main/src/hooks/useFetchPosts.js"
    click FetchEvents "https://github.com/muratozte/unisocial/blob/main/src/hooks/useFetchEvents.js"
    click FetchComms "https://github.com/muratozte/unisocial/blob/main/src/hooks/useCommunities.js"
    click UseProfile "https://github.com/muratozte/unisocial/blob/main/src/hooks/useProfile.js"

    classDef ui fill:#D0E8FF,stroke:#0366D6,color:#0366D6
    classDef api fill:#E0F8E0,stroke:#2E8B57,color:#2E8B57
    classDef service fill:#FFF4E5,stroke:#FFA500,color:#FF8C00
    classDef db fill:#FFE4E1,stroke:#DC143C,color:#DC143C
    classDef cdn fill:#F0F0F0,stroke:#808080,color:#808080
```
