# fespinoza/youtube-sampleprojects architecture

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

- Interactive diagram: https://gitdiagram.com/fespinoza/youtube-sampleprojects
- Repository: https://github.com/fespinoza/youtube-sampleprojects

## Overview

##### Project type and purpose
- This is not a single full-stack service but a collection of iOS/SwiftUI sample applications, each showcasing a different feature set:
- ImageGallery – a basic SwiftUI image grid viewer
- LiveActivityDemo – demonstrates iOS Live Activities using WidgetKit & ActivityKit plus custom Swift packages
- MovieCatalog – a modular SwiftUI app backed by TheMovieDB API, organized into Clean-Architecture layers via Swift Packages

##### File structure
- Top-level directories:
- ImageGallery/
- LiveActivityDemo/
- MovieCatalog/
- README.md, .gitignore
- Each subfolder is an Xcode workspace containing: App entry points, Views, Models, Resources, Extensions, Tests, and in the case of MovieCatalog & LiveActivityDemo, multiple internal Swift Packages under names like Packages/1-Base, 2-Infrastructure, 3-Features.

##### README
- It simply states: “A collection of sample projects I use for my YouTube channel.”
- No further architecture guidance is provided, so you must infer the patterns from the file layout.

##### Main components & interactions (per project)

A. ImageGallery
- Components:
– App (ImageGalleryApp.swift)
– Views (MainView, ImageGrid)
– Models (data structs)
– Extensions (Array.swift)
– Resources (Assets.xcassets)
- Relationships & flow:
View → Model → Resources
- Pattern: Simple MV or MVVM-style separation; all in one module

B. LiveActivityDemo
- Components:
– Main App (LiveActivityDemoApp.swift, AppDelegate.swift)
– DemoWidgets extension (WidgetKit bundle + LiveActivity definitions)
– Packages:
1. JSONPayload – constructs push payloads
2. LiveActivityContent – defines ActivityKit Attributes & Content
3. LiveActivityUI – renders SwiftUI views for live activities
- Relationships & flow:
Main App uses JSONPayload to craft push payload → ActivityKit receives push → LiveActivityContent maps payload to ActivityState → LiveActivityUI renders UI in widget extension → System delivers updates
- Pattern: Modular Swift Packages + widget extension + ActivityKit

C. MovieCatalog
- Components:
– MovieCatalog App (MovieCatalogApp.swift)
– Screens (Home, MovieList, MovieDescription, ActorDetails, ReleaseCalendar, ImageGallery, etc.)
– Data layer: MovieDataClient.swift → calls external TheMovieDB API
– Domain models packaged under Packages/1-Base/MovieModels
– Infrastructure packages under Packages/2-Infrastructure (Components, MovieDBNetworking, Navigation)
– Feature packages under Packages/3-Features (MovieDetails, MovieSearch)
– Utilities, Config, Extensions, Snapshot testing kit
- Relationships & flow:
UI Screens → Navigation Router → Feature modules → DataClient → External API → Domain Models → back up to Feature modules and UI
- Pattern: Clean Architecture (Domain / Infrastructure / Features) implemented as Swift Packages; MVVM-like binding with SwiftUI

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Top-Level Monorepo Overview
    subgraph "Youtube-SampleProjects Monorepo"
        direction TB
        subgraph "ImageGallery"
            direction TB
            IGApp["ImageGalleryApp.swift"]:::app
            IGViews["Views"]:::ui
            IGModels["Models"]:::model
            IGExt["Extensions"]:::infra
            IGRes["Resources"]:::external

            IGApp -->|"launches"| IGViews
            IGViews -->|"binds to"| IGModels
            IGModels -->|"loads from"| IGRes

            click IGApp "https://github.com/fespinoza/youtube-sampleprojects/blob/main/ImageGallery/ImageGallery/App/ImageGalleryApp.swift"
            click IGViews "https://github.com/fespinoza/youtube-sampleprojects/tree/main/ImageGallery/ImageGallery/Views"
            click IGModels "https://github.com/fespinoza/youtube-sampleprojects/blob/main/ImageGallery/ImageGallery/Models/Models.swift"
            click IGExt "https://github.com/fespinoza/youtube-sampleprojects/blob/main/ImageGallery/ImageGallery/Extensions/Array.swift"
            click IGRes "https://github.com/fespinoza/youtube-sampleprojects/tree/main/ImageGallery/ImageGallery/Resources"
        end

        subgraph "LiveActivityDemo"
            direction TB
            LADApp["LiveActivityDemoApp.swift"]:::app
            LADDelegate["AppDelegate.swift"]:::app
            LADViews["ContentView.swift"]:::ui
            LADExt["Data-Extensions.swift"]:::infra
            LADRes["Resources"]:::external
            DW["DemoWidgets"]:::ui
            JPkg["JSONPayload Package"]:::infra
            LACPkg["LiveActivityContent Package"]:::model
            LAUPkg["LiveActivityUI Package"]:::ui
            AK["ActivityKit Framework"]:::external

            LADApp -->|"uses"| JPkg
            JPkg -->|"sends to"| AK
            AK -->|"maps to"| LACPkg
            LACPkg -->|"renders via"| LAUPkg
            LAUPkg -->|"integrated in"| DW
            LADApp -->|"launches"| LADViews
            LADViews -->|"uses extensions"| LADExt
            LADViews -->|"loads"| LADRes

            click LADApp "https://github.com/fespinoza/youtube-sampleprojects/blob/main/LiveActivityDemo/LiveActivityDemo/App/LiveActivityDemoApp.swift"
            click LADDelegate "https://github.com/fespinoza/youtube-sampleprojects/blob/main/LiveActivityDemo/LiveActivityDemo/App/AppDelegate.swift"
            click LADViews "https://github.com/fespinoza/youtube-sampleprojects/blob/main/LiveActivityDemo/LiveActivityDemo/Views/ContentView.swift"
            click LADExt "https://github.com/fespinoza/youtube-sampleprojects/blob/main/LiveActivityDemo/LiveActivityDemo/Extensions/Data-Extensions.swift"
            click LADRes "https://github.com/fespinoza/youtube-sampleprojects/tree/main/LiveActivityDemo/LiveActivityDemo/Resources"
            click DW "https://github.com/fespinoza/youtube-sampleprojects/tree/main/LiveActivityDemo/DemoWidgets"
            click JPkg "https://github.com/fespinoza/youtube-sampleprojects/tree/main/LiveActivityDemo/JSONPayload"
            click LACPkg "https://github.com/fespinoza/youtube-sampleprojects/tree/main/LiveActivityDemo/LiveActivityContent"
            click LAUPkg "https://github.com/fespinoza/youtube-sampleprojects/tree/main/LiveActivityDemo/LiveActivityUI"
        end

        subgraph "MovieCatalog"
            direction TB
            MCApp["MovieCatalogApp.swift"]:::app
            MCScreens["Screens"]:::ui
            MCComps["Components"]:::ui
            MCNav["Navigation"]:::app
            MCData["MovieDataClient.swift"]:::infra
            MCModelPkg["1-Base MovieModels"]:::model
            MCInfra["2-Infrastructure Packages"]:::infra
            MCFeatures["3-Features Packages"]:::infra
            TMDB["TheMovieDB API"]:::external

            MCApp -->|"navigates via"| MCScreens
            MCScreens -->|"uses"| MCComps
            MCScreens -->|"routes via"| MCNav
            MCNav -->|"calls"| MCFeatures
            MCFeatures -->|"requests via"| MCData
            MCData -->|"fetchMovies() from"| TMDB
            TMDB -->|"responds with JSON"| MCModelPkg
            MCModelPkg -->|"models fed to"| MCFeatures
            MCFeatures -->|"updates"| MCScreens

            click MCApp "https://github.com/fespinoza/youtube-sampleprojects/blob/main/MovieCatalog/MovieCatalog/App/MovieCatalogApp.swift"
            click MCScreens "https://github.com/fespinoza/youtube-sampleprojects/tree/main/MovieCatalog/MovieCatalog/Screens"
            click MCComps "https://github.com/fespinoza/youtube-sampleprojects/tree/main/MovieCatalog/MovieCatalog/Components"
            click MCNav "https://github.com/fespinoza/youtube-sampleprojects/tree/main/MovieCatalog/MovieCatalog/Navigation"
            click MCData "https://github.com/fespinoza/youtube-sampleprojects/blob/main/MovieCatalog/MovieCatalog/Data/MovieDataClient.swift"
            click MCModelPkg "https://github.com/fespinoza/youtube-sampleprojects/tree/main/MovieCatalog/Packages/1-Base/MovieModels"
            click MCInfra "https://github.com/fespinoza/youtube-sampleprojects/tree/main/MovieCatalog/Packages/2-Infrastructure"
            click MCFeatures "https://github.com/fespinoza/youtube-sampleprojects/tree/main/MovieCatalog/Packages/3-Features"
        end
    end

    %% Styles
    classDef app fill:#D7BDE2,stroke:#7D3C98,color:#000
    classDef ui fill:#F5CBA7,stroke:#E67E22,color:#000
    classDef model fill:#AED6F1,stroke:#2980B9,color:#000
    classDef infra fill:#A9DFBF,stroke:#27AE60,color:#000
    classDef external fill:#D5DBDB,stroke:#566573,color:#000
```
