# karimbahri/streamvision architecture

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

- Interactive diagram: https://gitdiagram.com/karimbahri/streamvision
- Repository: https://github.com/karimbahri/streamvision

## Overview

##### Key Components
- Frontend (Client): This is located under the “client” directory. It uses React (with JSX and TypeScript), Vite as the build tool, Redux for state management, and Apollo Client to interact with the GraphQL API.
- Backend (Server): Found under the “server” directory, the backend uses Node.js (with Express, most likely), GraphQL for API endpoints, and TypeORM for database interactions.
- Database: A PostgreSQL database which holds the essential entities (such as shows, users, and verification codes). Also, Supabase is mentioned for authentication and additional data management.
- External Services: Docker is used for containerization (as described in the Docker Compose setup in the README). There is also integration with Supabase for authentication and possibly CDN configuration for serving assets.

##### Lay Out the Relationships and Data Flow
- The Backend processes GraphQL queries and mutations via its resolvers (organized in the “schema” directory, with separate folders for queries, mutations, typedefs, and entities).
- Additionally, there is a direct or configuration-level integration with Supabase (as indicated by the client’s supabase directory and environment variables). This can be shown as a separate external service or authentication/data storage component.
- Docker containers (for both client and server, plus the database) can be represented as an infrastructure layer that encapsulates these components.

##### Architectural Patterns and Design Principles
- Separation of Concerns: The project clearly separates frontend and backend responsibilities (e.g., React and Redux for UI/state and Node.js/GraphQL for business logic).
- Modular Design: Both directories have a structured, modular organization (e.g., client has components, apollo-client, redux, etc.; server has entities, schema, and database configurations).
- API-Centric Communication: Use of GraphQL for the API layer enables efficient data querying between the client and server.
- Containerization: The deployment using Docker Compose encapsulates and manages the environment consistently.

##### Relevant Technologies and Frameworks
- Frontend: React, Vite, Redux, Apollo Client, CSS/SCSS.
- Backend: Node.js, Express (or similar), GraphQL (with separate directories for queries, mutations, and typedefs), TypeORM.
- Database: PostgreSQL.
- External Tools: Supabase for authentication/data storage, Docker/Docker Compose for containerization.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Deployment Layer
    subgraph "Deployment"
        D("Docker Compose"):::infrastructure
    end

    %% Frontend (Client) Subgraph
    subgraph "Client (Frontend)"
        C1("React / Vite / TypeScript"):::frontend
        C2("Apollo Client"):::frontend
        C3("Redux"):::frontend
        C4("GraphQL Operations"):::frontend
    end

    %% Backend (Server) Subgraph
    subgraph "Server (Backend)"
        S1("Node.js / Express"):::backend
        S2("GraphQL Schema"):::backend
        S3("TypeORM DB Connection"):::backend
        S4("Database Entities"):::backend
    end

    %% Database and External Services
    DB("PostgreSQL"):::database
    E1("Supabase"):::external

    %% Connections from Deployment Layer
    D --> C1
    D --> S1
    D --> DB

    %% Frontend Internal Flows
    C1 --> C2
    C1 --> C3
    C1 --> C4

    %% Communication between Frontend and Backend
    C2 -->|"GraphQL_API"| S2

    %% Backend Database Flow
    S2 -->|"DB_Query"| S3
    S3 --> S4

    %% Integration with External Service (Supabase)
    C4 -->|"Supabase_Call"| E1
    S2 -->|"Auth_Storage"| E1

    %% Click Events for Components
    click C1 "https://github.com/karimbahri/streamvision/tree/master/client/"
    click C2 "https://github.com/karimbahri/streamvision/blob/master/client/src/apollo-client/index.ts"
    click C3 "https://github.com/karimbahri/streamvision/tree/master/client/src/redux/"
    click C4 "https://github.com/karimbahri/streamvision/tree/master/client/src/graphQl/"
    click S1 "https://github.com/karimbahri/streamvision/tree/master/server/"
    click S2 "https://github.com/karimbahri/streamvision/tree/master/server/src/schema/"
    click S3 "https://github.com/karimbahri/streamvision/blob/master/server/src/database/connection.ts"
    click S4 "https://github.com/karimbahri/streamvision/tree/master/server/src/entities/"
    click E1 "https://github.com/karimbahri/streamvision/blob/master/client/src/supabase/tus.ts"

    %% Styles
    classDef frontend fill:#a9d5ef,stroke:#1e90ff,stroke-width:2px;
    classDef backend fill:#c3f7b3,stroke:#2e8b57,stroke-width:2px;
    classDef database fill:#f9e79f,stroke:#f39c12,stroke-width:2px;
    classDef external fill:#f5b7b1,stroke:#e74c3c,stroke-width:2px;
    classDef infrastructure fill:#d7bde2,stroke:#8e44ad,stroke-width:2px;
```
