# lostcause/laravel-instagram-feed architecture

> Architecture diagram of the GitHub repository lostcause/laravel-instagram-feed, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/lostcause/laravel-instagram-feed
- Repository: https://github.com/lostcause/laravel-instagram-feed

## Overview

Laravel Instagram Feed manages authenticated Instagram profiles and exposes cached media feeds. The main workflow creates a profile, sends its user through OAuth, stores the resulting token, fetches and parses media, then serves cached feed data; scheduled commands refresh feeds and tokens. The graph also includes error notification and the HTTP client layer. Relationships are based on shown source references and README behavior; unsampled internals are represented only where documented, so some wiring is omitted.

Main entry points: [`src/Profile.php`](https://github.com/lostcause/laravel-instagram-feed/blob/master/src/Profile.php) (Profile model), [`src/Instagram.php`](https://github.com/lostcause/laravel-instagram-feed/blob/master/src/Instagram.php) (Instagram API client), [`src/InstagramFeedServiceProvider.php`](https://github.com/lostcause/laravel-instagram-feed/blob/master/src/InstagramFeedServiceProvider.php) (Laravel service provider), [`src/Commands/RefreshAuthorizedFeeds.php`](https://github.com/lostcause/laravel-instagram-feed/blob/master/src/Commands/RefreshAuthorizedFeeds.php) (Refresh feeds command)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_profiles["Profiles and auth"]
  node_profile_command["Create profile"]
  node_profile_model["Profile model<br/>[Profile.php]"]
  node_oauth_route["OAuth callback route<br/>[routes.php]"]
  node_oauth_controller["OAuth callback handler"]
  node_token_model["Access token<br/>[AccessToken.php]"]
  node_profile_store[("Profile and token store")]
end

subgraph group_feed["Feed retrieval"]
  node_instagram_client["Instagram API client<br/>[Instagram.php]"]
  node_http_client["HTTP client wrapper<br/>[SimpleClient.php]"]
  node_media_parser["Media parser<br/>[MediaParser.php]"]
  node_feed_cache[("Feed cache<br/>[Profile.php]")]
  node_exceptions["Request and token errors"]
end

subgraph group_operations["Scheduled operations"]
  node_feed_refresh["Refresh feeds command"]
  node_token_refresh["Refresh tokens command<br/>[RefreshTokens.php]"]
  node_failure_mail["Refresh failure email"]
end

subgraph group_integration["Laravel integration"]
  node_service_provider["Laravel service provider"]
end

node_site_user(("Site user"))
node_app_consumer(("Application consumer"))
node_instagram_api{{"Instagram API"}}

node_site_user -->|"creates profile"| node_profile_command
node_profile_command -->|"creates"| node_profile_model
node_app_consumer -->|"requests feed"| node_profile_model
node_site_user -->|"authorizes access"| node_instagram_api
node_profile_model -->|"builds auth URL"| node_instagram_client
node_oauth_route -->|"routes callback"| node_oauth_controller
node_oauth_controller -->|"loads and updates"| node_profile_model
node_profile_model -->|"requests tokens"| node_instagram_client
node_instagram_client -->|"sends API requests"| node_http_client
node_http_client -->|"calls API"| node_instagram_api
node_profile_model -->|"stores token"| node_token_model
node_profile_model -->|"persists profile"| node_profile_store
node_token_model -->|"persists token"| node_profile_store
node_profile_model -->|"fetches media"| node_instagram_client
node_instagram_client -->|"parses items"| node_media_parser
node_profile_model -->|"reads and writes"| node_feed_cache
node_feed_refresh -->|"refreshes feeds"| node_profile_model
node_feed_refresh -->|"sends on failure"| node_failure_mail
node_feed_refresh -->|"handles bad tokens"| node_exceptions
node_token_refresh -->|"refreshes tokens"| node_profile_model
node_profile_model -->|"renews token"| node_instagram_client
node_failure_mail -->|"checks authorization"| node_profile_model
node_service_provider -->|"registers command"| node_feed_refresh
node_service_provider -->|"registers command"| node_token_refresh
node_service_provider -->|"registers command"| node_profile_command
node_service_provider -->|"loads routes"| node_oauth_route
node_service_provider -->|"binds client"| node_instagram_client

click node_profile_command "https://github.com/lostcause/laravel-instagram-feed/blob/master/src/Commands/CreateBasicProfile.php"
click node_profile_model "https://github.com/lostcause/laravel-instagram-feed/blob/master/src/Profile.php"
click node_oauth_route "https://github.com/lostcause/laravel-instagram-feed/blob/master/src/routes.php"
click node_oauth_controller "https://github.com/lostcause/laravel-instagram-feed/blob/master/src/AccessTokenController.php"
click node_token_model "https://github.com/lostcause/laravel-instagram-feed/blob/master/src/AccessToken.php"
click node_instagram_client "https://github.com/lostcause/laravel-instagram-feed/blob/master/src/Instagram.php"
click node_http_client "https://github.com/lostcause/laravel-instagram-feed/blob/master/src/SimpleClient.php"
click node_media_parser "https://github.com/lostcause/laravel-instagram-feed/blob/master/src/MediaParser.php"
click node_feed_cache "https://github.com/lostcause/laravel-instagram-feed/blob/master/src/Profile.php"
click node_profile_store "https://github.com/lostcause/laravel-instagram-feed/tree/master/database/migrations"
click node_exceptions "https://github.com/lostcause/laravel-instagram-feed/tree/master/src/Exceptions"
click node_feed_refresh "https://github.com/lostcause/laravel-instagram-feed/blob/master/src/Commands/RefreshAuthorizedFeeds.php"
click node_token_refresh "https://github.com/lostcause/laravel-instagram-feed/blob/master/src/Commands/RefreshTokens.php"
click node_failure_mail "https://github.com/lostcause/laravel-instagram-feed/blob/master/src/Mail/FeedRefreshFailed.php"
click node_service_provider "https://github.com/lostcause/laravel-instagram-feed/blob/master/src/InstagramFeedServiceProvider.php"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_profile_command,node_profile_model,node_oauth_route,node_oauth_controller,node_token_model,node_profile_store,node_site_user toneBlue
class node_instagram_client,node_http_client,node_media_parser,node_feed_cache,node_exceptions toneAmber
class node_feed_refresh,node_token_refresh,node_failure_mail,node_instagram_api toneMint
class node_service_provider toneRose
class node_app_consumer toneIndigo
```

## Components

### Profiles and auth

- [Create profile](https://github.com/lostcause/laravel-instagram-feed/blob/master/src/Commands/CreateBasicProfile.php): `src/Commands/CreateBasicProfile.php`
- [Profile model](https://github.com/lostcause/laravel-instagram-feed/blob/master/src/Profile.php): `src/Profile.php`
- [OAuth callback route](https://github.com/lostcause/laravel-instagram-feed/blob/master/src/routes.php): `src/routes.php`
- [OAuth callback handler](https://github.com/lostcause/laravel-instagram-feed/blob/master/src/AccessTokenController.php): `src/AccessTokenController.php`
- [Access token](https://github.com/lostcause/laravel-instagram-feed/blob/master/src/AccessToken.php): `src/AccessToken.php`
- [Profile and token store](https://github.com/lostcause/laravel-instagram-feed/tree/master/database/migrations): `database/migrations`

### Feed retrieval

- [Instagram API client](https://github.com/lostcause/laravel-instagram-feed/blob/master/src/Instagram.php): `src/Instagram.php`
- [HTTP client wrapper](https://github.com/lostcause/laravel-instagram-feed/blob/master/src/SimpleClient.php): `src/SimpleClient.php`
- [Media parser](https://github.com/lostcause/laravel-instagram-feed/blob/master/src/MediaParser.php): `src/MediaParser.php`
- [Feed cache](https://github.com/lostcause/laravel-instagram-feed/blob/master/src/Profile.php): `src/Profile.php`
- [Request and token errors](https://github.com/lostcause/laravel-instagram-feed/tree/master/src/Exceptions): `src/Exceptions`

### Scheduled operations

- [Refresh feeds command](https://github.com/lostcause/laravel-instagram-feed/blob/master/src/Commands/RefreshAuthorizedFeeds.php): `src/Commands/RefreshAuthorizedFeeds.php`
- [Refresh tokens command](https://github.com/lostcause/laravel-instagram-feed/blob/master/src/Commands/RefreshTokens.php): `src/Commands/RefreshTokens.php`
- [Refresh failure email](https://github.com/lostcause/laravel-instagram-feed/blob/master/src/Mail/FeedRefreshFailed.php): `src/Mail/FeedRefreshFailed.php`

### Laravel integration

- [Laravel service provider](https://github.com/lostcause/laravel-instagram-feed/blob/master/src/InstagramFeedServiceProvider.php): `src/InstagramFeedServiceProvider.php`

### Other components

- **Site user**
- **Application consumer**
- **Instagram API**

## Connections

- Site user → Create profile: creates profile (evidence: `README.md`)
- Create profile → Profile model: creates (evidence: `src/Commands/CreateBasicProfile.php`)
- Application consumer → Profile model: requests feed (evidence: `README.md`)
- Site user → Instagram API: authorizes access (evidence: `README.md`)
- Profile model → Instagram API client: builds auth URL (evidence: `src/Profile.php`)
- OAuth callback route → OAuth callback handler: routes callback (evidence: `src/routes.php`)
- OAuth callback handler → Profile model: loads and updates (evidence: `src/AccessTokenController.php`)
- Profile model → Instagram API client: requests tokens (evidence: `src/Profile.php`)
- Instagram API client → HTTP client wrapper: sends API requests (evidence: `src/InstagramFeedServiceProvider.php`)
- HTTP client wrapper → Instagram API: calls API (evidence: `README.md`)
- Profile model → Access token: stores token (evidence: `src/Profile.php`)
- Profile model → Profile and token store: persists profile (evidence: `README.md`)
- Access token → Profile and token store: persists token (evidence: `src/AccessToken.php`)
- Profile model → Instagram API client: fetches media (evidence: `src/Profile.php`)
- Instagram API client → Media parser: parses items (evidence: `src/Instagram.php`)
- Profile model → Feed cache: reads and writes (evidence: `src/Profile.php`)
- Refresh feeds command → Profile model: refreshes feeds (evidence: `src/Commands/RefreshAuthorizedFeeds.php`)
- Refresh feeds command → Refresh failure email: sends on failure (evidence: `src/Commands/RefreshAuthorizedFeeds.php`)
- Refresh feeds command → Request and token errors: handles bad tokens (evidence: `src/Commands/RefreshAuthorizedFeeds.php`)
- Refresh tokens command → Profile model: refreshes tokens (evidence: `src/Commands/RefreshTokens.php`)
- Profile model → Instagram API client: renews token (evidence: `src/Profile.php`)
- Refresh failure email → Profile model: checks authorization (evidence: `src/Mail/FeedRefreshFailed.php`)
- Laravel service provider → Refresh feeds command: registers command (evidence: `src/InstagramFeedServiceProvider.php`)
- Laravel service provider → Refresh tokens command: registers command (evidence: `src/InstagramFeedServiceProvider.php`)
- Laravel service provider → Create profile: registers command (evidence: `src/InstagramFeedServiceProvider.php`)
- Laravel service provider → OAuth callback route: loads routes (evidence: `src/InstagramFeedServiceProvider.php`)
- Laravel service provider → Instagram API client: binds client (evidence: `src/InstagramFeedServiceProvider.php`)
