# onearmy/community-platform architecture

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

- Interactive diagram: https://gitdiagram.com/onearmy/community-platform
- Repository: https://github.com/onearmy/community-platform

## Overview

##### Project type and purpose
- This is a full-stack, monorepo community platform (Remix/React front-end + Node/Remix server + multiple back-end components) whose goal is to provide forums, maps, libraries and collaboration tools to global communities. It uses Supabase as its primary database/auth/storage, Firebase Cloud Functions for background processing and real-time services, and a suite of custom services/integrations (Slack, Discord).

##### File structure
- Top-level “src” directory: contains the Remix front-end (React/TSX), server entry points, route handlers (api.*).
- “functions”: Firebase Cloud Functions (TypeScript) for scheduled tasks, email notifications, database exports, integrations, aggregations, alerting.
- “supabase”: a separate Supabase Functions folder (Deno) plus SQL migration scripts—they represent a second back-end microservice.
- “shared”: shared TypeScript models & utilities consumed by both front-end and back-ends.
- “packages”: design system (“components”), testing (“cypress”), documentation, themes, simulated-webhook-receiver.
- “containerization” & Dockerfiles/docker-compose: local dev and CI deployment artifacts.
- CI/CD config (.circleci, GitHub Actions, Fly.io toml) and various scripts for build, deploy, local-dev.

##### README
- Confirms the stack: Remix + React front-end, Node-based SSR back-end, Supabase (Postgres + Auth + Storage), Firebase (Auth emulator, Firestore, Realtime DB, Storage), cloud functions, GitPod/CircleCI/Fly.io deployment.
- Points to docs on “remix.md”, “supabase.md” and “firebase-emulator.md” describing local emulation and architecture.

## Diagram (Mermaid)

```mermaid
flowchart TD
  %% Front-end Layer
  subgraph "Front-end Layer"
    Browser["Web Browser"]:::ui
    CDN["CDN / Static Assets"]:::ui
    EntryClient["entry.client.tsx"]:::api
    EntryServerFE["entry.server.tsx"]:::api
    Root["root.tsx"]:::api
    RoutesFE["routes/"]:::api
    Pages["pages/"]:::api
    Common["common/"]:::api
    Styles["styles/"]:::api
    Assets["assets/"]:::api
  end

  %% Back-end Layer
  subgraph "Back-end Layer"
    RemixServer["Remix Server (SSR & API)"]:::server
    APIRoutes["src/routes/api.*"]:::server
    SharedServices["Domain Services (auth, comment, notification, etc.)"]:::server
    SupaFunctions["Supabase Deno Functions"]:::func
    FirebaseFuncs["Firebase Cloud Functions"]:::func
  end

  %% Data Stores
  subgraph "Data Stores"
    SupabaseDB["Supabase Postgres"]:::data
    SupabaseAuth["Supabase Auth & Storage"]:::data
    Firestore["Firestore"]:::data
    RTDB["Realtime DB"]:::data
    SupaStorage["Supabase Storage"]:::data
  end

  %% Dev & CI/CD
  subgraph "Dev & CI/CD"
    DockerCompose["Docker Compose"]:::dev
    CI["CircleCI / GitHub Actions"]:::dev
    FlyIO["Fly.io Deployment"]:::dev
  end

  %% Interactions
  Browser -->|HTTP/HTTPS| CDN
  Browser -->|SPA Navigation| EntryClient
  Browser -->|Auth & Uploads| SupabaseAuth
  Browser -->|Initial Request| RemixServer
  CDN -->|serves| EntryClient

  RemixServer -->|SSR & API Calls| APIRoutes
  RemixServer -->|uses| SharedServices
  SharedServices -->|reads/writes| SupabaseDB
  SharedServices -->|reads/writes| SupaStorage
  RemixServer -->|triggers| FirebaseFuncs
  FirebaseFuncs -->|events| Firestore
  FirebaseFuncs -->|events| RTDB
  SupaFunctions -->|email/magic links| SupabaseAuth

  CI -->|build images| DockerCompose
  CI -->|deploy| FlyIO
  DockerCompose -->|local emulation| FirebaseFuncs
  DockerCompose -->|local Postgres| SupabaseDB

  %% Click Events - Front-end
  click EntryClient "https://github.com/onearmy/community-platform/blob/master/src/entry.client.tsx"
  click EntryServerFE "https://github.com/onearmy/community-platform/blob/master/src/entry.server.tsx"
  click Root "https://github.com/onearmy/community-platform/blob/master/src/root.tsx"
  click RoutesFE "https://github.com/onearmy/community-platform/tree/master/src/routes/"
  click Pages "https://github.com/onearmy/community-platform/tree/master/src/pages/"
  click Common "https://github.com/onearmy/community-platform/tree/master/src/common/"
  click Styles "https://github.com/onearmy/community-platform/tree/master/src/styles/"
  click Assets "https://github.com/onearmy/community-platform/tree/master/src/assets/"

  %% Click Events - Remix Server & APIs
  click RemixServer "https://github.com/onearmy/community-platform/blob/master/server.js"
  click APIRoutes "https://github.com/onearmy/community-platform/blob/master/src/routes/api.*"
  
  %% Click Events - Supabase
  click SupabaseDB "https://github.com/onearmy/community-platform/tree/master/supabase/migrations/"
  click SupabaseDB "https://github.com/onearmy/community-platform/blob/master/supabase/seed.sql"
  click SupaFunctions "https://github.com/onearmy/community-platform/blob/master/supabase/functions/send-email/index.ts"
  
  %% Click Events - Firebase Cloud Functions
  click FirebaseFuncs "https://github.com/onearmy/community-platform/tree/master/functions/src/"
  click FirebaseFuncs "https://github.com/onearmy/community-platform/tree/master/functions/scripts/"

  %% Click Events - Shared Models & Utilities
  click SharedServices "https://github.com/onearmy/community-platform/tree/master/shared/models/"
  click SharedServices "https://github.com/onearmy/community-platform/tree/master/shared/utils/"
  click SharedServices "https://github.com/onearmy/community-platform/tree/master/shared/data/"
  click SharedServices "https://github.com/onearmy/community-platform/blob/master/shared/index.ts"

  %% Click Events - Integrations
  click FirebaseFuncs "https://github.com/onearmy/community-platform/blob/master/functions/src/Integrations/firebase-slack.ts"
  click FirebaseFuncs "https://github.com/onearmy/community-platform/blob/master/functions/src/Integrations/firebase-discord.ts"
  
  %% Click Events - Scheduled & Aggregation Tasks
  click FirebaseFuncs "https://github.com/onearmy/community-platform/blob/master/functions/src/scheduled/tasks.ts"
  click FirebaseFuncs "https://github.com/onearmy/community-platform/blob/master/functions/src/aggregations/userNotifications.aggregations.ts"
  click FirebaseFuncs "https://github.com/onearmy/community-platform/blob/master/functions/src/alerting/errorAlerting.ts"

  %% Click Events - Emulator & Testing Utilities
  click DockerCompose "https://github.com/onearmy/community-platform/tree/master/functions/src/emulator/"
  click DockerCompose "https://github.com/onearmy/community-platform/tree/master/functions/src/test/"
  click DockerCompose "https://github.com/onearmy/community-platform/blob/master/packages/cypress/src/support/db/firebase.ts"

  %% Click Events - Docker & Local Dev
  click DockerCompose "https://github.com/onearmy/community-platform/blob/master/docker-compose.yml"
  click DockerCompose "https://github.com/onearmy/community-platform/tree/master/Dockerfile"
  click DockerCompose "https://github.com/onearmy/community-platform/tree/master/containerization/Dockerfile"

  %% Click Events - CI/CD Config
  click CI "https://github.com/onearmy/community-platform/blob/master/.circleci/config.yml"
  click CI "https://github.com/onearmy/community-platform/tree/master/.github/workflows/"

  %% Styles
  classDef ui fill:#DDEEFF,stroke:#000
  classDef server fill:#D4F1C5,stroke:#000
  classDef data fill:#FCE9A8,stroke:#000
  classDef func fill:#E2D1F9,stroke:#000
  classDef dev fill:#CCCCCC,stroke:#000
```
