# forem/forem architecture

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

- Interactive diagram: https://gitdiagram.com/forem/forem
- Repository: https://github.com/forem/forem

## Overview

Forem is a Rails community platform for publishing and discovering content, participating in discussions, and managing community identities and spaces. The principal web workflow begins with a visitor request, routes it to a feed controller, and returns community content; members also create articles and interact through comments and profiles. The graph preserves major product areas visible in the tree, but sampled evidence is limited: only relationships shown in the README or excerpts are solid, and unverified workflow links are omitted.

Main entry points: [`config/routes.rb`](https://github.com/forem/forem/blob/main/config/routes.rb) (Request routing), [`app/controllers/incoming_webhooks/stripe_events_controller.rb`](https://github.com/forem/forem/blob/main/app/controllers/incoming_webhooks/stripe_events_controller.rb) (Stripe webhook), [`app/services/agent_sessions/s3_storage.rb`](https://github.com/forem/forem/blob/main/app/services/agent_sessions/s3_storage.rb) (Session object storage), [`app/controllers/stories_controller.rb`](https://github.com/forem/forem/blob/main/app/controllers/stories_controller.rb) (Community feeds)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_routes["Request routing<br/>[routes.rb]"]
  node_feed["Community feeds"]
  node_search["Search"]
  node_api["Public API<br/>[api_controller.rb]"]
end

subgraph group_content["Publishing and discussion"]
  node_articles["Article publishing"]
  node_article_api["Article API"]
  node_comments["Comments"]
  node_tags["Tags and topics<br/>[tags_controller.rb]"]
end

subgraph group_community["Community management"]
  node_profiles["Member profiles"]
  node_organizations["Organizations"]
  node_admin_users["Admin user management"]
end

subgraph group_services["Integrations and intelligence"]
  node_agent_sessions["Agent sessions"]
  node_session_storage["Session object storage<br/>[s3_storage.rb]"]
  node_stripe_webhook["Stripe webhook"]
  node_semantic_workers["Embedding workers"]
  node_user_interest["Interest embeddings"]
end

node_visitor(("Visitor or member"))
node_aws_s3[("AWS S3")]
node_stripe(("Stripe"))

node_visitor -->|"sends request"| node_routes
node_routes -->|"dispatches feed"| node_feed
node_routes -->|"dispatches article"| node_articles
node_routes -.->|"dispatches comments"| node_comments
node_routes -.->|"dispatches search"| node_search
node_routes -.->|"dispatches profile"| node_profiles
node_routes -.->|"dispatches organization"| node_organizations
node_routes -.->|"dispatches admin"| node_admin_users
node_routes -.->|"dispatches API"| node_api
node_routes -.->|"dispatches API article"| node_article_api
node_routes -->|"dispatches sessions"| node_agent_sessions
node_routes -->|"routes webhook"| node_stripe_webhook
node_session_storage -->|"signs storage URLs"| node_aws_s3
node_stripe -.->|"sends events"| node_stripe_webhook

click node_routes "https://github.com/forem/forem/blob/main/config/routes.rb"
click node_feed "https://github.com/forem/forem/blob/main/app/controllers/stories_controller.rb"
click node_search "https://github.com/forem/forem/blob/main/app/controllers/search_controller.rb"
click node_articles "https://github.com/forem/forem/blob/main/app/controllers/articles_controller.rb"
click node_article_api "https://github.com/forem/forem/blob/main/app/controllers/api/v1/articles_controller.rb"
click node_comments "https://github.com/forem/forem/blob/main/app/controllers/comments_controller.rb"
click node_tags "https://github.com/forem/forem/blob/main/app/controllers/tags_controller.rb"
click node_profiles "https://github.com/forem/forem/blob/main/app/controllers/profiles_controller.rb"
click node_organizations "https://github.com/forem/forem/blob/main/app/controllers/organizations_controller.rb"
click node_admin_users "https://github.com/forem/forem/blob/main/app/controllers/admin/users_controller.rb"
click node_api "https://github.com/forem/forem/blob/main/app/controllers/api/v1/api_controller.rb"
click node_agent_sessions "https://github.com/forem/forem/blob/main/app/controllers/agent_sessions_controller.rb"
click node_session_storage "https://github.com/forem/forem/blob/main/app/services/agent_sessions/s3_storage.rb"
click node_stripe_webhook "https://github.com/forem/forem/blob/main/app/controllers/incoming_webhooks/stripe_events_controller.rb"
click node_semantic_workers "https://github.com/forem/forem/blob/main/app/workers/comments/generate_embedding_worker.rb"
click node_user_interest "https://github.com/forem/forem/blob/main/app/workers/update_user_interest_embedding_worker.rb"

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_routes,node_feed,node_search,node_api toneBlue
class node_articles,node_article_api,node_comments,node_tags,node_aws_s3 toneAmber
class node_profiles,node_organizations,node_admin_users toneMint
class node_agent_sessions,node_session_storage,node_stripe_webhook,node_semantic_workers,node_user_interest toneRose
class node_visitor,node_stripe toneIndigo
```

## Components

### Web experience

- [Request routing](https://github.com/forem/forem/blob/main/config/routes.rb): `config/routes.rb`
- [Community feeds](https://github.com/forem/forem/blob/main/app/controllers/stories_controller.rb): `app/controllers/stories_controller.rb`
- [Search](https://github.com/forem/forem/blob/main/app/controllers/search_controller.rb): `app/controllers/search_controller.rb`
- [Public API](https://github.com/forem/forem/blob/main/app/controllers/api/v1/api_controller.rb): `app/controllers/api/v1/api_controller.rb`

### Publishing and discussion

- [Article publishing](https://github.com/forem/forem/blob/main/app/controllers/articles_controller.rb): `app/controllers/articles_controller.rb`
- [Article API](https://github.com/forem/forem/blob/main/app/controllers/api/v1/articles_controller.rb): `app/controllers/api/v1/articles_controller.rb`
- [Comments](https://github.com/forem/forem/blob/main/app/controllers/comments_controller.rb): `app/controllers/comments_controller.rb`
- [Tags and topics](https://github.com/forem/forem/blob/main/app/controllers/tags_controller.rb): `app/controllers/tags_controller.rb`

### Community management

- [Member profiles](https://github.com/forem/forem/blob/main/app/controllers/profiles_controller.rb): `app/controllers/profiles_controller.rb`
- [Organizations](https://github.com/forem/forem/blob/main/app/controllers/organizations_controller.rb): `app/controllers/organizations_controller.rb`
- [Admin user management](https://github.com/forem/forem/blob/main/app/controllers/admin/users_controller.rb): `app/controllers/admin/users_controller.rb`

### Integrations and intelligence

- [Agent sessions](https://github.com/forem/forem/blob/main/app/controllers/agent_sessions_controller.rb): `app/controllers/agent_sessions_controller.rb`
- [Session object storage](https://github.com/forem/forem/blob/main/app/services/agent_sessions/s3_storage.rb): `app/services/agent_sessions/s3_storage.rb`
- [Stripe webhook](https://github.com/forem/forem/blob/main/app/controllers/incoming_webhooks/stripe_events_controller.rb): `app/controllers/incoming_webhooks/stripe_events_controller.rb`
- [Embedding workers](https://github.com/forem/forem/blob/main/app/workers/comments/generate_embedding_worker.rb): `app/workers/comments/generate_embedding_worker.rb`
- [Interest embeddings](https://github.com/forem/forem/blob/main/app/workers/update_user_interest_embedding_worker.rb): `app/workers/update_user_interest_embedding_worker.rb`

### Other components

- **Visitor or member**
- **AWS S3**
- **Stripe**

## Connections

- Visitor or member → Request routing: sends request (evidence: `config/routes.rb`)
- Request routing → Community feeds: dispatches feed (evidence: `config/routes.rb`)
- Request routing → Article publishing: dispatches article (evidence: `config/routes.rb`)
- Request routing → Comments: dispatches comments
- Request routing → Search: dispatches search
- Request routing → Member profiles: dispatches profile
- Request routing → Organizations: dispatches organization
- Request routing → Admin user management: dispatches admin
- Request routing → Public API: dispatches API
- Request routing → Article API: dispatches API article
- Request routing → Agent sessions: dispatches sessions (evidence: `config/routes.rb`)
- Request routing → Stripe webhook: routes webhook (evidence: `config/routes.rb`)
- Session object storage → AWS S3: signs storage URLs (evidence: `app/services/agent_sessions/s3_storage.rb`)
- Stripe → Stripe webhook: sends events
