# logan-larson/castify architecture

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

- Interactive diagram: https://gitdiagram.com/logan-larson/castify
- Repository: https://github.com/logan-larson/castify

## Overview

##### Main System Components

a) Client Layer:
- Mobile Applications (iOS/Android) built with Capacitor
- Web Application (SvelteKit)
- As separate but related frontend clients

b) API Layer:
- GraphQL API (shown by the /api directory with Apollo Server)
- Custom scalar definitions and resolvers

c) Database Layer:
- Neo4j Graph Database (evident from SQL files in /database)
- Main entities: Users, Podcasts, Episodes, and their relationships

d) Infrastructure Layer:
- Nginx reverse proxy
- Docker containers (shown by Dockerfiles and docker-compose.yml)

##### Component Relationships

a) Client-Server Communication:
- GraphQL queries/mutations flow between clients and API
- Main query types (podcasts.js and users.js resolvers)

b) Data Flow:
- Authentication flow (JWT tokens from utils/jwt.js)
- Podcast content delivery
- User interactions (follows, subscriptions, comments)

##### Detailed Component Breakdown

Frontend (app/):
- Components:
- Player components
- Authentication components
- Podcast/Episode components
- Stores management

Backend (api/):
- GraphQL schema and resolvers
- Database driver connection
- Authentication middleware

##### Key Features to Highlight

Specific flows for:
- Podcast playback system
- Social features (follows, comments)
- Authentication flow
- Content discovery
- Offline capabilities

##### Technical Stack Indicators

- SvelteKit
- GraphQL
- Neo4j
- Capacitor
- Docker
- Nginx

##### Deployment Architecture

Containerized structure:
- Docker containers relationship
- Nginx reverse proxy configuration
- Mobile build process

This architecture should reflect the project's current state while accommodating the roadmap items mentioned in the README, such as offline playback, enhanced player controls, and recommendation systems.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph CL["Client Layer"]
        direction TB
        WA["Web App (SvelteKit)"]:::frontend
        MA["Mobile Apps (iOS/Android)"]:::frontend
        
        subgraph FE["Frontend Components"]
            direction TB
            PC["Player Components"]:::frontend
            AC["Auth Components"]:::frontend
            POD["Podcast Components"]:::frontend
            SM["Store Management"]:::frontend
        end
        
        subgraph GQ["GraphQL Queries"]
            direction TB
            PQ["Podcast Queries"]:::query
            UQ["User Queries"]:::query
        end
    end

    subgraph AL["API Layer"]
        direction TB
        GQL["GraphQL API"]:::api
        CS["Custom Scalars"]:::api
        RES["Resolvers"]:::api
        AM["Auth Middleware"]:::api
    end

    subgraph DL["Database Layer"]
        direction TB
        NEO["Neo4j Graph DB"]:::database
        
        subgraph Relationships["Social Relationships"]
            direction TB
            FOL["Follows"]:::database
            COM["Comments"]:::database
            SUB["Subscriptions"]:::database
        end
    end

    subgraph IL["Infrastructure Layer"]
        direction TB
        NG["Nginx Proxy"]:::infra
        DC["Docker Containers"]:::infra
    end

    %% Connections
    WA --> GQ
    MA --> GQ
    GQ --> GQL
    GQL --> CS
    GQL --> RES
    RES --> NEO
    AM --> GQL
    NEO --> Relationships
    GQL --> NG
    DC --> NG

    %% Click Events
    click WA "https://github.com/logan-larson/Castify/tree/master/app/src/routes/"
    click MA "https://github.com/logan-larson/Castify/tree/master/app/android/"
    click PC "https://github.com/logan-larson/Castify/tree/master/app/src/lib/components/Player/"
    click AC "https://github.com/logan-larson/Castify/blob/master/app/src/lib/components/AuthModal.svelte"
    click POD "https://github.com/logan-larson/Castify/blob/master/app/src/lib/components/PodcastCard.svelte"
    click SM "https://github.com/logan-larson/Castify/tree/master/app/src/lib/stores/"
    click PQ "https://github.com/logan-larson/Castify/blob/master/app/src/lib/queries/podcastQueries.js"
    click UQ "https://github.com/logan-larson/Castify/blob/master/app/src/lib/queries/userQueries.js"
    click GQL "https://github.com/logan-larson/Castify/blob/master/api/graphql/typeDefs.gql"
    click RES "https://github.com/logan-larson/Castify/tree/master/api/graphql/resolvers/"
    click CS "https://github.com/logan-larson/Castify/blob/master/api/customScalar.js"
    click NEO "https://github.com/logan-larson/Castify/tree/master/database/"
    click FOL "https://github.com/logan-larson/Castify/blob/master/database/FOLLOWS.sql"
    click COM "https://github.com/logan-larson/Castify/blob/master/database/COMMENTS_ON.sql"
    click SUB "https://github.com/logan-larson/Castify/blob/master/database/SUBSCRIBES_TO.sql"
    click NG "https://github.com/logan-larson/Castify/blob/master/nginx/nginx.conf"
    click DC "https://github.com/logan-larson/Castify/blob/master/docker-compose.yml"

    %% Styles
    classDef frontend fill:#3498db,stroke:#2980b9,color:#fff
    classDef api fill:#2ecc71,stroke:#27ae60,color:#fff
    classDef database fill:#f1c40f,stroke:#f39c12,color:#000
    classDef infra fill:#e74c3c,stroke:#c0392b,color:#fff
    classDef query fill:#9b59b6,stroke:#8e44ad,color:#fff

    %% Legend
    subgraph Legend
        direction TB
        F["Frontend"]:::frontend
        A["API"]:::api
        D["Database"]:::database
        I["Infrastructure"]:::infra
        Q["Queries"]:::query
    end
```
