# krishna-gujjjar/social-clone architecture

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

- Interactive diagram: https://gitdiagram.com/krishna-gujjjar/social-clone
- Repository: https://github.com/krishna-gujjjar/social-clone

## Overview

##### Main Components

A. Client-Side (Mobile Application):
- Frontend Layer (React Native)
- Navigation Structure (Expo Router - evident from the /app directory structure)
- Local Storage Layer (MMKV)
- State Management Layer
- UI Components Layer

B. Backend Services (Firebase):
- Authentication Service
- Cloud Firestore (Database)
- Firebase Storage (Media)
- Cloud Functions (if applicable)

**┌─ Client Layer ─────────────────────┐**
- ┌─ Navigation ─┐ ┌─ Components ─┐  │
- Auth Flow  │ │ - UI         │  │
- Tab Flow   │ │ - Reels      │  │
- ┘ │ - MetaData    │  │
- ┘   │
- ┌─ State Management ──────────────┐│
- MMKV Storage + Store          ││
- ┘│
- ┘
- ↕ (API Calls)
**┌─ Firebase Services ───────────────┐**
- ┌─ Auth ─┐ ┌─ Firestore ─┐       │
- Login  │ │ - Users     │       │
- Register│ │ - Posts     │       │
- ┘ │ - MetaData  │       │
- ┘        │
- ┌─ Storage ─────────────────┐    │
- Media (Videos/Images)     │    │
- ┘      │
- ┘

##### Important Elements to Highlight

A. Application Flow:
- Auth Flow (/app/(auth))
- Main App Flow (/app/(app))
- Tab Navigation Flow (/app/(app)/(tabs))

B. Core Features:
- Reel System
- User Management
- Social Interactions (Follow/Unfollow)
- Media Management

C. Data Flow:
- User Authentication Flow
- Media Upload Flow
- Social Interaction Flow

##### Specific Implementation Details

- How authentication flows from client to Firebase Auth
- How media uploads flow from client to Firebase Storage
- How social interactions are stored in Firestore
- How local storage (MMKV) interacts with the app state

##### Component Relationships

Clear connections between:
- UI Components (/components/ui)
- Service Layer (/services)
- Hooks Layer (/hooks)
- Storage Layer (/services/storages)

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client
        direction TB
        
        Navigation["Navigation System"]
        AuthFlow["Authentication Flow"]
        TabFlow["Tab Navigation"]
        
        subgraph Components
            direction TB
            UI["UI Components"]
            Reels["Reel System"]
            DataValidation["Data Validation"]
        end
        
        subgraph StateManagement
            direction TB
            Store["Store Management"]
            MMKV["MMKV Storage"]
        end
        
        Navigation --> AuthFlow
        Navigation --> TabFlow
        AuthFlow --> Components
        TabFlow --> Components
    end
    
    subgraph FirebaseServices
        direction TB
        Auth["Authentication Service"]
        
        subgraph Database
            Firestore["Cloud Firestore"]
            Users["Users Collection"]
            Posts["Posts Collection"]
            MetaData["MetaData Collection"]
        end
        
        Storage["Firebase Storage"]
        
        Firestore --> Users
        Firestore --> Posts
        Firestore --> MetaData
    end
    
    Components --> FirebaseServices
    StateManagement --> FirebaseServices
    
    %% Click Events
    click Navigation "https://github.com/krishna-gujjjar/social-clone/blob/main//src/app/(app)/_layout.tsx"
    click AuthFlow "https://github.com/krishna-gujjjar/social-clone/tree/main//src/app/(auth)"
    click TabFlow "https://github.com/krishna-gujjjar/social-clone/blob/main//src/app/(app)/(tabs)/_layout.tsx"
    click UI "https://github.com/krishna-gujjjar/social-clone/tree/main//src/components/ui"
    click Reels "https://github.com/krishna-gujjjar/social-clone/blob/main//src/components/reel/reel.tsx"
    click DataValidation "https://github.com/krishna-gujjjar/social-clone/tree/main//src/services/schema"
    click Store "https://github.com/krishna-gujjjar/social-clone/blob/main//src/services/storages/store.ts"
    click MMKV "https://github.com/krishna-gujjjar/social-clone/blob/main//src/services/storages/mmkv.ts"
    click Auth "https://github.com/krishna-gujjjar/social-clone/blob/main//src/services/firebase/auth.ts"
    click Firestore "https://github.com/krishna-gujjjar/social-clone/blob/main//src/services/firebase/firebase.ts"
    click Storage "https://github.com/krishna-gujjjar/social-clone/blob/main//src/services/firebase/media.ts"
    click Users "https://github.com/krishna-gujjjar/social-clone/blob/main//src/services/firebase/user.ts"
    click Posts "https://github.com/krishna-gujjjar/social-clone/blob/main//src/services/firebase/post.ts"
    click MetaData "https://github.com/krishna-gujjjar/social-clone/blob/main//src/services/firebase/metaData.ts"
    
    %% Styling
    classDef client fill:#e1f5fe,stroke:#01579b
    classDef firebase fill:#ffebee,stroke:#b71c1c
    classDef storage fill:#e8f5e9,stroke:#1b5e20
    classDef component fill:#f3e5f5,stroke:#4a148c
    
    class Navigation,AuthFlow,TabFlow,Components,StateManagement client
    class Auth,Database,Storage,Firestore,Users,Posts,MetaData firebase
    class Store,MMKV storage
    class UI,Reels,DataValidation component
```
