# bluesky-social/statusphere-example-app architecture

> Architecture diagram of the GitHub repository bluesky-social/statusphere-example-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2024-12-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bluesky-social/statusphere-example-app
- Repository: https://github.com/bluesky-social/statusphere-example-app

## Overview

##### Main Components

a) Client-Side Components:
- Frontend UI Layer (src/pages)
- Authentication Module (src/auth)
- Lexicon Type System (src/lexicon)

b) External Services:
- AT Protocol/Bluesky Services
- OAuth Authentication Service

c) Data Flow Components:
- Ingester (src/ingester.ts)
- ID Resolver (src/id-resolver.ts)
- Database Interface (src/db.ts)

**[Client Layer]**

**[Application Layer]**

**[External Services Layer]**

##### Detailed Component Representation

a) Client Layer (Top):
- Auth Client module
- Use rounded rectangles for UI components

b) Application Layer (Middle):
- Create sections for:
- Lexicon System (showing type definitions)
- Data Ingestion Pipeline
- Database Interface

c) External Services (Bottom):
- AT Protocol Services
- OAuth Provider

##### Connection and Data Flow

- Authentication flow from Login → Auth Client → OAuth → AT Protocol
- Data flow from AT Protocol → Ingester → Database
- Profile and status data flow through the Lexicon system
- Client-side data requests through the view layer

##### Technical Details to Highlight

- OAuth Authentication Flow
- Custom Status Schema Implementation
- Profile Information Handling
- Network Firehose Integration

Remember to include notes about:
- Environment Configuration (.env)
- TypeScript Implementation (shown by tsconfig.json)
- Static Asset Handling (public folder)
- Lexicon Definitions (lexicons folder)

This will provide a comprehensive view of both the application's structure and its interaction with the AT Protocol ecosystem.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles and Classes
    classDef frontend fill:#a8d1f0,stroke:#333
    classDef application fill:#90EE90,stroke:#333
    classDef external fill:#D3D3D3,stroke:#333
    classDef database fill:#FFB6C1,stroke:#333
    classDef auth fill:#FFE4B5,stroke:#333
    classDef lexicon fill:#DDA0DD,stroke:#333

    %% Frontend Layer
    subgraph Frontend
        Home["Home Page"]:::frontend
        Login["Login Page"]:::frontend
        Shell["Shell Component"]:::frontend
        Styles["Styles"]:::frontend
    end

    %% Auth Layer
    subgraph Auth
        AuthClient["Auth Client"]:::auth
        AuthStorage["Auth Storage"]:::auth
    end

    %% Application Layer
    subgraph Core
        Ingester["Data Ingester"]:::application
        IDResolver["ID Resolver"]:::application
        DBInterface["Database Interface"]:::database
        ViewLib["View Library"]:::application
        EnvUtils["Environment Utils"]:::application
        MainEntry["Main Entry"]:::application
        Routes["Route Definitions"]:::application
    end

    %% Lexicon System
    subgraph LexiconSystem
        SchemaDefinitions["Schema Definitions"]:::lexicon
        TypeImplementations["Type Implementations"]:::lexicon
        subgraph Types
            BlueskyTypes["Bluesky Types"]:::lexicon
            ATProtoTypes["AT Protocol Types"]:::lexicon
            CustomStatusTypes["Custom Status Types"]:::lexicon
        end
        subgraph Schemas
            ProfileSchema["Profile Schema"]:::lexicon
            StatusSchema["Status Schema"]:::lexicon
            StrongRefSchema["Strong Ref Schema"]:::lexicon
            DefTypes["Definition Types"]:::lexicon
        end
    end

    %% External Services
    ATProtocol[("AT Protocol")]:::external
    OAuth[("OAuth Provider")]:::external

    %% Relationships
    Login --> AuthClient
    AuthClient --> OAuth
    OAuth --> ATProtocol
    ATProtocol --> Ingester
    Ingester --> DBInterface
    Home --> ViewLib
    Shell --> ViewLib
    AuthClient --> AuthStorage
    IDResolver --> ATProtocol
    MainEntry --> Routes
    Routes --> ViewLib
    LexiconSystem --> Ingester
    LexiconSystem --> IDResolver

    %% Click Events
    click Home "https://github.com/bluesky-social/statusphere-example-app/blob/main/src/pages/home.ts"
    click Login "https://github.com/bluesky-social/statusphere-example-app/blob/main/src/pages/login.ts"
    click Shell "https://github.com/bluesky-social/statusphere-example-app/blob/main/src/pages/shell.ts"
    click Styles "https://github.com/bluesky-social/statusphere-example-app/blob/main/src/pages/public/styles.css"
    click AuthClient "https://github.com/bluesky-social/statusphere-example-app/blob/main/src/auth/client.ts"
    click AuthStorage "https://github.com/bluesky-social/statusphere-example-app/blob/main/src/auth/storage.ts"
    click SchemaDefinitions "https://github.com/bluesky-social/statusphere-example-app/tree/main/lexicons/"
    click TypeImplementations "https://github.com/bluesky-social/statusphere-example-app/tree/main/src/lexicon/"
    click BlueskyTypes "https://github.com/bluesky-social/statusphere-example-app/tree/main/src/lexicon/types/app/bsky/"
    click ATProtoTypes "https://github.com/bluesky-social/statusphere-example-app/tree/main/src/lexicon/types/com/atproto/"
    click CustomStatusTypes "https://github.com/bluesky-social/statusphere-example-app/tree/main/src/lexicon/types/xyz/statusphere/"
    click Ingester "https://github.com/bluesky-social/statusphere-example-app/blob/main/src/ingester.ts"
    click IDResolver "https://github.com/bluesky-social/statusphere-example-app/blob/main/src/id-resolver.ts"
    click DBInterface "https://github.com/bluesky-social/statusphere-example-app/blob/main/src/db.ts"
    click ViewLib "https://github.com/bluesky-social/statusphere-example-app/blob/main/src/lib/view.ts"
    click EnvUtils "https://github.com/bluesky-social/statusphere-example-app/blob/main/src/lib/env.ts"
    click MainEntry "https://github.com/bluesky-social/statusphere-example-app/blob/main/src/index.ts"
    click Routes "https://github.com/bluesky-social/statusphere-example-app/blob/main/src/routes.ts"
    click ProfileSchema "https://github.com/bluesky-social/statusphere-example-app/blob/main/lexicons/profile.json"
    click StatusSchema "https://github.com/bluesky-social/statusphere-example-app/blob/main/lexicons/status.json"
    click StrongRefSchema "https://github.com/bluesky-social/statusphere-example-app/blob/main/lexicons/strongRef.json"
    click DefTypes "https://github.com/bluesky-social/statusphere-example-app/blob/main/lexicons/defs.json"
```
