# codinsonn/green-stack-demo architecture

> Architecture diagram of the GitHub repository codinsonn/green-stack-demo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-03-28). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/codinsonn/green-stack-demo
- Repository: https://github.com/codinsonn/green-stack-demo

## Overview

##### Project Context and Purpose
- The project is a full-stack, cross-platform application starter template built using React/React Native with a monorepo structure.
- It leverages the GREEN stack by combining GraphQL, React (and React-Native), Evergreen components, Expo (for mobile) and Next.js (for web). Its emphasis is “write once, run anywhere” across mobile, web, and PWA.
- The README reinforces its primary value: a universal development approach through shared code, automated Storybook documentation and optimized deployment for web and mobile.

##### Main Components Identification
- Apps Layer:
- /apps/next: Contains Next.js configuration and file-based routing for web, SSR support, API routes (GraphQL, health, docs etc) and static assets.
- /apps/expo: Contains Expo configuration and bundler settings (Metro, Babel, Expo Router) to support mobile app (iOS/Android/PWA) development.
- Features Layer:
- Packages or Libraries:
- /packages: Contains the core libraries of Aetherspace (primitives, forms, context, navigation, schemas, utils, etc.) which provide reusable components and business logic that are consumed both by the apps and features.
- Configuration and Build Tools:
- Turborepo configuration (turbo.json, turbo folder) and yarn workspaces support establishing clear dependency boundaries, caching, and build pipelines.
- Documentation & Storybook:
- .storybook directory where Storybook is configured to auto-generate documentation for components and libraries.

##### Relationships and Interactions
- The Apps entries (Expo and Next) are the entry points for building the respective mobile and web builds.
- Both apps rely on the shared code from the “features” (notably app-core) to render consistent UI and routing across platforms.
- The “packages” provide utility functions, components, hooks, navigation, schema, and core Aetherspace libraries that support both app code and feature code.
- The monorepo structure (with yarn workspaces and Turborepo) orchestrates building and dependency linkage between /apps, /features, and /packages.
- External services: GraphQL endpoints and possibly REST API routes which are implemented within the apps and shared by features.
- Storybook integration is used to document and visually test core reusable components.

##### Architectural Patterns and Design Principles
- Monorepo Architecture: Separate workspaces (apps, features, packages) are used for clear separation of concerns.
- Shared Code and “Write Once” Principles: The common libraries (in packages) and core features (in app-core) demonstrate the DRY (Don’t Repeat Yourself) pattern.
- File-based Routing: Both Expo (mobile) and Next (web) use file-based routing systems with generated routes, making the structure modular and extensible.
- Configurability: Usage of YAML and JSON config files across directories (babel.config.js, tsconfig.json, next.config.js, app.json) ensures that each platform’s build settings are isolated yet coordinated.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Apps Layer
    subgraph "Apps Layer"
        nextApp["Next.js App (Web)"]
        expoApp["Expo Mobile App (Mobile)"]
    end

    %% Shared Features Layer
    subgraph "Shared Features"
        sharedFeatures["Shared Features (App Core)"]
    end

    %% Aetherspace Packages Layer
    subgraph "Aetherspace Packages"
        packagesNode["Aetherspace Packages (Libraries & Reusable Components)"]
    end

    %% Build & Deployment Configuration
    subgraph "Build & Deployment"
        turboFile["Turbo Config (File)"]
        turboFolder["Turbo Directory"]
    end

    %% Documentation & External Tools
    subgraph "Documentation & External"
        storybook["Storybook Documentation & Configuration"]
    end

    %% Relationships
    nextApp -->|"uses"| sharedFeatures
    expoApp -->|"uses"| sharedFeatures
    sharedFeatures -->|"utilizes"| packagesNode
    packagesNode -->|"integrates with"| turboFile
    packagesNode -->|"integrates with"| turboFolder
    packagesNode -->|"documented by"| storybook

    %% Click Events for Component Mapping
    click nextApp "https://github.com/codinsonn/green-stack-demo/tree/main/apps/next"
    click expoApp "https://github.com/codinsonn/green-stack-demo/tree/main/apps/expo"
    click sharedFeatures "https://github.com/codinsonn/green-stack-demo/tree/main/features/app-core"
    click packagesNode "https://github.com/codinsonn/green-stack-demo/tree/main/packages/@aetherspace"
    click turboFile "https://github.com/codinsonn/green-stack-demo/blob/main/turbo.json"
    click turboFolder "https://github.com/codinsonn/green-stack-demo/tree/main/turbo"
    click storybook "https://github.com/codinsonn/green-stack-demo/blob/main/.storybook"

    %% Styles
    classDef apps fill:#ADD8E6,stroke:#000,stroke-width:1px;
    classDef features fill:#90EE90,stroke:#000,stroke-width:1px;
    classDef packages fill:#D8BFD8,stroke:#000,stroke-width:1px;
    classDef config fill:#FFD700,stroke:#000,stroke-width:1px;
    classDef docs fill:#AFEEEE,stroke:#000,stroke-width:1px;
    
    class nextApp,expoApp apps;
    class sharedFeatures features;
    class packagesNode packages;
    class turboFile,turboFolder config;
    class storybook docs;
```
