# srperzibal/instagram-clone architecture

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

- Interactive diagram: https://gitdiagram.com/srperzibal/instagram-clone
- Repository: https://github.com/srperzibal/instagram-clone

## Overview

##### Project Type and Purpose
- This is a single-page front-end application built with React and Vite.
- It manages user authentication, displays feeds and stories, and interacts with a Supabase backend (database + auth).

##### File Structure Analysis
- Top Level:
- public & index.html – static assets and HTML entrypoint
- src – application source code
- .env, package.json, vite.config.js – build, dependency, and environment configurations
- Inside src:
- main.jsx – React app bootstrap
- App.jsx & router/AppRouter.jsx – top-level component and routing setup
- context/AuthContext.jsx – global auth state management
- supabaseClient.js – Supabase SDK initialization (external service integration)
- pages/ – route targets (Login.jsx, Sidebar.jsx)
- components/ – UI widgets (Feed, Perfil, PostCard, PostUploader, Stories, StoryModal, StoryUploader)
- Patterns observed:
- SPA with React Router for navigation
- Context API for cross-cutting concerns (authentication)
- Component-based UI hierarchy

##### Insights from README
- Confirms minimal React + Vite setup with ESLint & fast refresh.
- No built-in backend—external Supabase handles data & auth.

1. Browser (user agent)
2. Vite Dev/Build Server (serves bundle & assets)
3. React Application
– AppRouter (React Router)
– AuthContext Provider
– Page Components (Login, Sidebar)
– UI Components (Feed, PostCard, Stories, etc.)
4. Supabase Service
– Auth API
– Database API
b. Relationships & Data Flow
- Browser ↔ Vite Server: GET index.html, JS/CSS bundles, HMR WS
- Browser ↔ React App: user interactions, virtual DOM updates
- React App → SupabaseClient: REST/GraphQL calls for sign-in, CRUD operations
- Supabase → React App: JSON responses (auth tokens, records)
c. Architectural Patterns & Principles
- Single-Page Application (SPA)
- Component hierarchy & composition
- Context for global state (AuthContext)
- Separation of concerns: routing, state, UI, data access
d. Key Technologies & Frameworks
- Vite (dev server, bundler)
- React (UI library)
- React Router (routing)
- Context API (global state)
- Supabase JS SDK (backend as a service)
- ESLint (linting)

## Diagram (Mermaid)

```mermaid
graph TB
    %% Browser and Dev Server
    Browser["Browser (User Agent)"]:::external
    ViteServer["Vite Dev/Build Server"]:::server
    StaticDir["public/ & src/assets/"]:::static
    Configs["package.json<br>.env<br>vite.config.js"]:::config

    Browser -->|GET index.html, JS/CSS bundles| ViteServer
    ViteServer -->|serves static assets| StaticDir
    ViteServer -->|uses config| Configs
    ViteServer -->|HMR WebSocket| Browser

    %% React Application Bootstrap
    Main["src/main.jsx<br>React App Bootstrap"]:::state

    ViteServer --> Main

    %% React Application Subgraph
    subgraph "React Application"
        direction TB
        App["src/App.jsx<br>Top-Level App Component"]:::ui
        AuthContext["src/context/AuthContext.jsx<br>AuthContext Provider"]:::state
        Router["src/router/AppRouter.jsx<br>AppRouter (Routing)"]:::state

        App --> AuthContext
        AuthContext --> Router

        subgraph "Pages" 
            direction TB
            Login["src/pages/Login.jsx<br>Login Page"]:::ui
            Sidebar["src/pages/Sidebar.jsx<br>Sidebar Page"]:::ui
        end

        Router --> Login
        Router --> Sidebar

        subgraph "UI Components"
            direction TB
            Feed["src/components/Feed.jsx<br>Feed Component"]:::ui
            Perfil["src/components/Perfil.jsx<br>Perfil Component"]:::ui
            PostCard["src/components/PostCard.jsx<br>PostCard Component"]:::ui
            PostUploader["src/components/PostUploader.jsx<br>PostUploader Component"]:::ui
            Stories["src/components/Stories.jsx<br>Stories Component"]:::ui
            StoryModal["src/components/StoryModal.jsx<br>StoryModal Component"]:::ui
            StoryUploader["src/components/StoryUploader.jsx<br>StoryUploader Component"]:::ui
        end

        Login --> Feed
        Sidebar --> Perfil
        Feed --> PostCard
        Feed --> PostUploader
        Sidebar --> Stories
        Stories --> StoryModal
        Stories --> StoryUploader
    end

    Main --> App

    %% Supabase Integration
    SupabaseClient["src/supabaseClient.js<br>Supabase JS SDK"]:::service
    AuthAPI["Supabase Auth API"]:::service
    DBAPI["Supabase Database API"]:::service

    App -->|REST calls| SupabaseClient
    SupabaseClient --> AuthAPI
    SupabaseClient --> DBAPI
    AuthAPI -->|JSON responses| App
    DBAPI -->|JSON responses| App

    %% Stylesheets
    GlobalCSS["src/index.css<br>Global Stylesheet"]:::static
    AppCSS["src/App.css<br>App Stylesheet"]:::static

    Main --> GlobalCSS
    App --> AppCSS

    %% Click Events
    click ViteServer "https://github.com/srperzibal/instagram-clone/blob/main/vite.config.js"
    click Browser "https://github.com/srperzibal/instagram-clone/blob/main/index.html"
    click Main "https://github.com/srperzibal/instagram-clone/blob/main/src/main.jsx"
    click App "https://github.com/srperzibal/instagram-clone/blob/main/src/App.jsx"
    click Router "https://github.com/srperzibal/instagram-clone/blob/main/src/router/AppRouter.jsx"
    click AuthContext "https://github.com/srperzibal/instagram-clone/blob/main/src/context/AuthContext.jsx"
    click SupabaseClient "https://github.com/srperzibal/instagram-clone/blob/main/src/supabaseClient.js"
    click Login "https://github.com/srperzibal/instagram-clone/blob/main/src/pages/Login.jsx"
    click Sidebar "https://github.com/srperzibal/instagram-clone/blob/main/src/pages/Sidebar.jsx"
    click Feed "https://github.com/srperzibal/instagram-clone/blob/main/src/components/Feed.jsx"
    click Perfil "https://github.com/srperzibal/instagram-clone/blob/main/src/components/Perfil.jsx"
    click PostCard "https://github.com/srperzibal/instagram-clone/blob/main/src/components/PostCard.jsx"
    click PostUploader "https://github.com/srperzibal/instagram-clone/blob/main/src/components/PostUploader.jsx"
    click Stories "https://github.com/srperzibal/instagram-clone/blob/main/src/components/Stories.jsx"
    click StoryModal "https://github.com/srperzibal/instagram-clone/blob/main/src/components/StoryModal.jsx"
    click StoryUploader "https://github.com/srperzibal/instagram-clone/blob/main/src/components/StoryUploader.jsx"
    click StaticDir "https://github.com/srperzibal/instagram-clone/tree/main/public/"
    click StaticDir "https://github.com/srperzibal/instagram-clone/tree/main/src/assets/"
    click Configs "https://github.com/srperzibal/instagram-clone/blob/main/package.json"
    click Configs "https://github.com/srperzibal/instagram-clone/blob/main/.env"
    click Configs "https://github.com/srperzibal/instagram-clone/blob/main/vite.config.js"

    %% Styles
    classDef ui fill:#CFE2F3,stroke:#6FA8DC,color:#073763
    classDef state fill:#D9EAD3,stroke:#93C47D,color:#274E13
    classDef service fill:#F9CB9C,stroke:#E69138,color:#663C00
    classDef server fill:#FFE599,stroke:#D9B655,color:#7F6000
    classDef external fill:#EAD1DC,stroke:#C27BA0,color:#641E16
    classDef static fill:#D9D2E9,stroke:#B4A7D6,color:#3C115E
    classDef config fill:#F4CCCC,stroke:#E06666,color:#660000
```
