# satishpwebdev/social_media_app architecture

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

- Interactive diagram: https://gitdiagram.com/satishpwebdev/social_media_app
- Repository: https://github.com/satishpwebdev/social_media_app

## Overview

##### Project type and purpose
- This is a single‐page, full‐stack‐type social media application implemented entirely in React + TypeScript on the frontend, but using Firebase as a Backend-as-a-Service (BaaS) for authentication, real-time database, storage and hosting.
- Users can register/login, create posts, like, save, comment, and see real-time updates.

##### File structure
- Top level:
- index.html, main.tsx, App.tsx → entry point of the React SPA
- package.json, vite.config.ts, tsconfig*.json, eslint.config.js, tailwind.config.js → build & tooling
- src/components → reusable UI components (Navbar, Post, Comments, CreatePost, ProtectedRoute/PublicRoute, WelcomeScreen)
- src/pages → route‐level containers (Feed, MyPosts, SavedPosts, Login, Register)
- src/contexts/AuthContext.tsx → global auth state via React Context
- src/lib/firebase.ts → Firebase initialization & wrapper
- src/types → shared TypeScript types
- No separate backend repo – all business logic invokes Firebase APIs from the client.

##### README for additional insights
- Tech stack: React + Vite, TypeScript, Tailwind CSS on the client; Firebase Auth, Firestore, Storage, Hosting on the server side.
- Features: real-time updates, protected routes, responsive design.

- Labels: “Browser”, “Firebase Hosting”, “React App (index.html → main.tsx → App.tsx)”, “AuthContext”, “ProtectedRoute/PublicRoute”, “Pages (Feed, MyPosts, etc.)”, “Components (Post, Comments, CreatePost)”, “Firebase Auth”, “Firestore”, “Storage”.
- Notes on real-time update channels.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Entities
    Browser["Browser"]:::external
    DeveloperCI["Developer/CI"]:::tools
    FirebaseHosting["Firebase Hosting"]:::service

    %% Frontend SPA
    subgraph "Frontend SPA" 
        direction TB
        Entry["index.html"]:::client
        click Entry "https://github.com/satishpwebdev/social_media_app/blob/main/index.html"
        MainTS["main.tsx"]:::client
        click MainTS "https://github.com/satishpwebdev/social_media_app/blob/main/src/main.tsx"
        AppContainer["App.tsx"]:::client
        click AppContainer "https://github.com/satishpwebdev/social_media_app/blob/main/src/App.tsx"
        AuthContext["AuthContext"]:::client
        click AuthContext "https://github.com/satishpwebdev/social_media_app/blob/main/src/contexts/AuthContext.tsx"
        FirebaseInit["Firebase Init"]:::client
        click FirebaseInit "https://github.com/satishpwebdev/social_media_app/blob/main/src/lib/firebase.ts"
    end

    %% Routing Layer
    subgraph "Routing & Protection" 
        direction TB
        ProtectedRoute["ProtectedRoute"]:::client
        click ProtectedRoute "https://github.com/satishpwebdev/social_media_app/blob/main/src/components/ProtectedRoute.tsx"
        PublicRoute["PublicRoute"]:::client
        click PublicRoute "https://github.com/satishpwebdev/social_media_app/blob/main/src/components/PublicRoute.tsx"
    end

    %% UI Components
    subgraph "UI Components" 
        direction TB
        Navbar["Navbar"]:::ui
        click Navbar "https://github.com/satishpwebdev/social_media_app/blob/main/src/components/Navbar.tsx"
        PostComp["Post"]:::ui
        click PostComp "https://github.com/satishpwebdev/social_media_app/blob/main/src/components/Post.tsx"
        CommentsComp["Comments"]:::ui
        click CommentsComp "https://github.com/satishpwebdev/social_media_app/blob/main/src/components/Comments.tsx"
        CreatePost["CreatePost"]:::ui
        click CreatePost "https://github.com/satishpwebdev/social_media_app/blob/main/src/components/CreatePost.tsx"
        WelcomeScreen["WelcomeScreen"]:::ui
        click WelcomeScreen "https://github.com/satishpwebdev/social_media_app/blob/main/src/components/WelcomeScreen.tsx"
    end

    %% Pages
    subgraph "Pages" 
        direction TB
        FeedPage["Feed"]:::page
        click FeedPage "https://github.com/satishpwebdev/social_media_app/blob/main/src/pages/Feed.tsx"
        MyPostsPage["MyPosts"]:::page
        click MyPostsPage "https://github.com/satishpwebdev/social_media_app/blob/main/src/pages/MyPosts.tsx"
        SavedPostsPage["SavedPosts"]:::page
        click SavedPostsPage "https://github.com/satishpwebdev/social_media_app/blob/main/src/pages/SavedPosts.tsx"
        LoginPage["Login"]:::page
        click LoginPage "https://github.com/satishpwebdev/social_media_app/blob/main/src/pages/Login.tsx"
        RegisterPage["Register"]:::page
        click RegisterPage "https://github.com/satishpwebdev/social_media_app/blob/main/src/pages/Register.tsx"
    end

    %% Types & Config
    Types["Types"]:::code
    click Types "https://github.com/satishpwebdev/social_media_app/blob/main/src/types/index.ts"
    ViteConfig["vite.config.ts"]:::tools
    click ViteConfig "https://github.com/satishpwebdev/social_media_app/blob/main/vite.config.ts"
    TailwindConfig["tailwind.config.js"]:::tools
    click TailwindConfig "https://github.com/satishpwebdev/social_media_app/blob/main/tailwind.config.js"
    ESLintConfig["eslint.config.js"]:::tools
    click ESLintConfig "https://github.com/satishpwebdev/social_media_app/blob/main/eslint.config.js"

    %% Firebase Services
    subgraph "Firebase Services" 
        direction TB
        AuthService["Firebase Auth"]:::service
        Firestore["Firestore"]:::service
        Storage["Storage"]:::service
    end

    %% Data Flows
    Browser -->|requests SPA| FirebaseHosting -->|serves static files| Browser
    Browser -->|loads| Entry --> MainTS --> AppContainer --> AuthContext
    AppContainer --> ProtectedRoute
    AppContainer --> PublicRoute
    AppContainer -->|renders| Navbar
    AppContainer -->|routes to| FeedPage
    AppContainer -->|routes to| MyPostsPage
    AppContainer -->|routes to| SavedPostsPage
    AppContainer -->|routes to| LoginPage
    AppContainer -->|routes to| RegisterPage

    FeedPage -->|uses| PostComp
    FeedPage -->|uses| CommentsComp
    FeedPage -->|uses| CreatePost
    FeedPage -->|uses| WelcomeScreen

    AuthContext -->|init via| FirebaseInit
    FirebaseInit -->|calls| AuthService
    FirebaseInit -->|calls| Firestore
    FirebaseInit -->|calls| Storage

    FeedPage -->|CRUD| Firestore
    FeedPage -->|upload/download| Storage
    FeedPage <-->|real-time updates| Firestore

    LoginPage -->|login/register| AuthService
    RegisterPage -->|login/register| AuthService

    DeveloperCI -->|build & deploy| FirebaseHosting
    DeveloperCI -->|build via| ViteConfig
    DeveloperCI -->|lint via| ESLintConfig
    DeveloperCI -->|styles via| TailwindConfig

    %% Legend
    subgraph Legend
        direction TB
        client["Client Code"]:::client
        ui["UI Components"]:::ui
        page["Pages"]:::page
        service["External Services"]:::service
        tools["Build/Deploy Tools"]:::tools
        code["Shared Code"]:::code
    end

    %% Styles
    classDef client fill:#D0E8FF,stroke:#0366D6
    classDef ui fill:#FFE5D0,stroke:#D97706
    classDef page fill:#E8FFD0,stroke:#15803D
    classDef service fill:#D0FFD6,stroke:#059669
    classDef tools fill:#F0F0F0,stroke:#6B7280,stroke-dasharray: 5 5
    classDef code fill:#FCE8FF,stroke:#8B5CF6
```
