# balderdashy/sails architecture

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

- Interactive diagram: https://gitdiagram.com/balderdashy/sails
- Repository: https://github.com/balderdashy/sails

## Overview

Sails is an MVC-oriented Node.js web and API framework with realtime capabilities. Its main lifecycle is to create a Sails app, load configuration and hooks, lift the app, route HTTP requests to actions, and return responses. The graph also preserves documented blueprint and realtime capabilities plus the request, response, and routing layers. Some domain integrations are documented in the README but their runtime wiring is not shown in the excerpts, so those links are marked as unverified or omitted.

Main entry points: [`lib/router/index.js`](https://github.com/balderdashy/sails/blob/master/lib/router/index.js) (Router), [`lib/app/Sails.js`](https://github.com/balderdashy/sails/blob/master/lib/app/Sails.js) (Sails app), [`lib/hooks/index.js`](https://github.com/balderdashy/sails/blob/master/lib/hooks/index.js) (Hook lifecycle), [`lib/app/index.js`](https://github.com/balderdashy/sails/blob/master/lib/app/index.js) (App factory)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_lifecycle["App lifecycle"]
  node_sails["Sails app<br/>[Sails.js]"]
  node_app_factory["App factory<br/>[index.js]"]
  node_configuration["Configuration<br/>[index.js]"]
  node_config_loading["Config loading<br/>[load.js]"]
  node_rc_config["RC config<br/>[rc.js]"]
end

subgraph group_http["HTTP routing"]
  node_http_hook["HTTP hook<br/>[index.js]"]
  node_router["Router<br/>[index.js]"]
  node_route_binding["Route binding<br/>[bind.js]"]
  node_request_layer["Request helpers<br/>[req.js]"]
  node_response_layer["Response helpers<br/>[res.js]"]
  node_view_rendering["View rendering<br/>[render.js]"]
end

subgraph group_actions["Actions and APIs"]
  node_action_loading["Action loading"]
  node_blueprints["Blueprint routes<br/>[index.js]"]
  node_blueprint_actions["Blueprint actions<br/>[create.js]"]
end

subgraph group_hooks["Core hooks"]
  node_hook_lifecycle["Hook lifecycle<br/>[index.js]"]
  node_hook_loading["Hook loading<br/>[loadHooks.js]"]
  node_security["Security hooks<br/>[index.js]"]
  node_sessions["Sessions<br/>[index.js]"]
end

subgraph group_realtime["Realtime and data"]
  node_pubsub["Pub/sub<br/>[index.js]"]
  node_waterline{{"Waterline ORM"}}
  node_socketio{{"Socket.io"}}
end

node_developer(("App developer"))
node_http_client(("HTTP client"))

node_developer -->|"creates app"| node_app_factory
node_app_factory -->|"instantiates"| node_sails
node_sails -->|"configures"| node_configuration
node_configuration -->|"loads config"| node_config_loading
node_config_loading -.->|"reads overrides"| node_rc_config
node_sails -->|"loads hooks"| node_hook_loading
node_hook_loading -->|"initializes"| node_hook_lifecycle
node_sails -->|"sets up routing"| node_router
node_router -->|"binds routes"| node_route_binding
node_router -->|"uses helpers"| node_request_layer
node_router -->|"uses helpers"| node_response_layer
node_http_client -->|"sends requests"| node_router
node_router -.->|"dispatches actions"| node_action_loading
node_blueprints -->|"registers actions"| node_blueprint_actions
node_router -.->|"renders views"| node_view_rendering
node_hook_lifecycle -.->|"initializes hook"| node_http_hook
node_hook_lifecycle -.->|"initializes hook"| node_security
node_hook_lifecycle -.->|"initializes hook"| node_sessions
node_hook_lifecycle -.->|"initializes hook"| node_pubsub
node_waterline -.->|"provides ORM"| node_sails
node_socketio -.->|"enables realtime"| node_sails

click node_sails "https://github.com/balderdashy/sails/blob/master/lib/app/Sails.js"
click node_app_factory "https://github.com/balderdashy/sails/blob/master/lib/app/index.js"
click node_configuration "https://github.com/balderdashy/sails/blob/master/lib/app/configuration/index.js"
click node_config_loading "https://github.com/balderdashy/sails/blob/master/lib/app/configuration/load.js"
click node_rc_config "https://github.com/balderdashy/sails/blob/master/lib/app/configuration/rc.js"
click node_hook_lifecycle "https://github.com/balderdashy/sails/blob/master/lib/hooks/index.js"
click node_hook_loading "https://github.com/balderdashy/sails/blob/master/lib/app/private/loadHooks.js"
click node_http_hook "https://github.com/balderdashy/sails/blob/master/lib/hooks/http/index.js"
click node_router "https://github.com/balderdashy/sails/blob/master/lib/router/index.js"
click node_route_binding "https://github.com/balderdashy/sails/blob/master/lib/router/bind.js"
click node_request_layer "https://github.com/balderdashy/sails/blob/master/lib/router/req.js"
click node_response_layer "https://github.com/balderdashy/sails/blob/master/lib/router/res.js"
click node_action_loading "https://github.com/balderdashy/sails/blob/master/lib/app/private/controller/load-action-modules.js"
click node_blueprints "https://github.com/balderdashy/sails/blob/master/lib/hooks/blueprints/index.js"
click node_blueprint_actions "https://github.com/balderdashy/sails/blob/master/lib/hooks/blueprints/actions/create.js"
click node_view_rendering "https://github.com/balderdashy/sails/blob/master/lib/hooks/views/render.js"
click node_security "https://github.com/balderdashy/sails/blob/master/lib/hooks/security/index.js"
click node_sessions "https://github.com/balderdashy/sails/blob/master/lib/hooks/session/index.js"
click node_pubsub "https://github.com/balderdashy/sails/blob/master/lib/hooks/pubsub/index.js"

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_sails,node_app_factory,node_configuration,node_config_loading,node_rc_config,node_http_client toneBlue
class node_http_hook,node_router,node_route_binding,node_request_layer,node_response_layer,node_view_rendering toneAmber
class node_action_loading,node_blueprints,node_blueprint_actions toneMint
class node_hook_lifecycle,node_hook_loading,node_security,node_sessions toneRose
class node_pubsub,node_waterline,node_socketio,node_developer toneIndigo
```

## Components

### App lifecycle

- [Sails app](https://github.com/balderdashy/sails/blob/master/lib/app/Sails.js): `lib/app/Sails.js`
- [App factory](https://github.com/balderdashy/sails/blob/master/lib/app/index.js): `lib/app/index.js`
- [Configuration](https://github.com/balderdashy/sails/blob/master/lib/app/configuration/index.js): `lib/app/configuration/index.js`
- [Config loading](https://github.com/balderdashy/sails/blob/master/lib/app/configuration/load.js): `lib/app/configuration/load.js`
- [RC config](https://github.com/balderdashy/sails/blob/master/lib/app/configuration/rc.js): `lib/app/configuration/rc.js`

### HTTP routing

- [HTTP hook](https://github.com/balderdashy/sails/blob/master/lib/hooks/http/index.js): `lib/hooks/http/index.js`
- [Router](https://github.com/balderdashy/sails/blob/master/lib/router/index.js): `lib/router/index.js`
- [Route binding](https://github.com/balderdashy/sails/blob/master/lib/router/bind.js): `lib/router/bind.js`
- [Request helpers](https://github.com/balderdashy/sails/blob/master/lib/router/req.js): `lib/router/req.js`
- [Response helpers](https://github.com/balderdashy/sails/blob/master/lib/router/res.js): `lib/router/res.js`
- [View rendering](https://github.com/balderdashy/sails/blob/master/lib/hooks/views/render.js): `lib/hooks/views/render.js`

### Actions and APIs

- [Action loading](https://github.com/balderdashy/sails/blob/master/lib/app/private/controller/load-action-modules.js): `lib/app/private/controller/load-action-modules.js`
- [Blueprint routes](https://github.com/balderdashy/sails/blob/master/lib/hooks/blueprints/index.js): `lib/hooks/blueprints/index.js`
- [Blueprint actions](https://github.com/balderdashy/sails/blob/master/lib/hooks/blueprints/actions/create.js): `lib/hooks/blueprints/actions/create.js`

### Core hooks

- [Hook lifecycle](https://github.com/balderdashy/sails/blob/master/lib/hooks/index.js): `lib/hooks/index.js`
- [Hook loading](https://github.com/balderdashy/sails/blob/master/lib/app/private/loadHooks.js): `lib/app/private/loadHooks.js`
- [Security hooks](https://github.com/balderdashy/sails/blob/master/lib/hooks/security/index.js): `lib/hooks/security/index.js`
- [Sessions](https://github.com/balderdashy/sails/blob/master/lib/hooks/session/index.js): `lib/hooks/session/index.js`

### Realtime and data

- [Pub/sub](https://github.com/balderdashy/sails/blob/master/lib/hooks/pubsub/index.js): `lib/hooks/pubsub/index.js`
- **Waterline ORM**
- **Socket.io**

### Other components

- **App developer**
- **HTTP client**

## Connections

- App developer → App factory: creates app
- App factory → Sails app: instantiates (evidence: `lib/app/index.js`)
- Sails app → Configuration: configures (evidence: `lib/app/Sails.js`)
- Configuration → Config loading: loads config (evidence: `lib/app/configuration/index.js`)
- Config loading → RC config: reads overrides
- Sails app → Hook loading: loads hooks (evidence: `lib/app/Sails.js`)
- Hook loading → Hook lifecycle: initializes (evidence: `lib/app/private/loadHooks.js`)
- Sails app → Router: sets up routing (evidence: `lib/app/Sails.js`)
- Router → Route binding: binds routes (evidence: `lib/router/index.js`)
- Router → Request helpers: uses helpers (evidence: `lib/router/index.js`)
- Router → Response helpers: uses helpers (evidence: `lib/router/index.js`)
- HTTP client → Router: sends requests
- Router → Action loading: dispatches actions
- Blueprint routes → Blueprint actions: registers actions (evidence: `lib/hooks/blueprints/index.js`)
- Router → View rendering: renders views
- Hook lifecycle → HTTP hook: initializes hook
- Hook lifecycle → Security hooks: initializes hook
- Hook lifecycle → Sessions: initializes hook
- Hook lifecycle → Pub/sub: initializes hook
- Waterline ORM → Sails app: provides ORM
- Socket.io → Sails app: enables realtime
