> ## Documentation Index
> Fetch the complete documentation index at: https://forest-chore-open-api.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview

> Load your data into Forest and enrich it with additional sources

Forest connects to your databases and external services to expose your data and make it actionable.

## How data flows into Forest

Forest loads data through **datasources**, connections to your databases, APIs, or any system that holds data.

<CodeGroup>
  ```javascript Node.js theme={null}
  const agent = createAgent(options);

  // Connect your primary database
  agent.addDataSource(
    createSqlDataSource('postgresql://localhost/mydb')
  );

  // Add a second datasource (e.g. MongoDB)
  agent.addDataSource(
    createMongooseDataSource(mongoConnection)
  );

  // Forest automatically:
  // - Discovers all tables
  // - Detects column types
  // - Identifies relationships (foreign keys)
  // - Creates collections for each table
  ```

  ```ruby Ruby theme={null}
  agent = Forestadmin::Agent.new(options)

  # Connect your primary database
  agent.add_datasource(
    Forestadmin::Datasource::ActiveRecord.new
  )

  # Add a second datasource
  agent.add_datasource(
    Forestadmin::Datasource::Mongoid.new
  )

  # Forest automatically:
  # - Discovers all tables
  # - Detects column types
  # - Identifies relationships (foreign keys)
  # - Creates collections for each table
  ```
</CodeGroup>

## Forest datasources

Forest loads data through **datasources**, connections to your databases, APIs, or any system that holds data. For some datasources, Forest performs introspection to discover the schema automatically. For others (like ORM-based connections), the schema is already known from your model definitions.

**ORM-based connections** (Sequelize, Mongoose):

* Forest reads your ORM model definitions
* Uses the schemas you've already defined in your application code
* Detects relationships from model associations
* No database introspection needed - everything comes from your models

**Direct database connections** (SQL, MongoDB):

* **SQL databases**: Forest queries the database metadata (information\_schema or system catalogs) to discover tables, columns, data types, constraints, foreign keys, and indexes
* **MongoDB**: Forest samples a subset of documents (default: 100 per collection) and analyzes them to infer the schema structure, including nested fields and references

**API-based connections** (REST, GraphQL): Forest uses the API schema or a custom mapping to expose data.

Once introspection is complete, Forest automatically:

1. **Discovers schema** - all tables/collections and their structure
2. **Maps data types** - converts database types to Forest types
3. **Detects relationships** - foreign keys or references become navigable relationships
4. **Creates collections** - each table/collection becomes a collection in the UI
5. **Enables CRUD operations** - browse, create, edit, delete records

## Loading more data: multi-datasources

Connect multiple databases or APIs in the same back-end:

<CodeGroup>
  ```javascript Node.js theme={null}
  // Primary PostgreSQL database
  agent.addDataSource(
    createSqlDataSource('postgresql://localhost/main'),
    { name: 'main' }
  );

  // MongoDB for analytics
  agent.addDataSource(
    createMongooseDataSource(mongoConnection),
    { name: 'analytics' }
  );
  ```

  ```ruby Ruby theme={null}
  # Primary PostgreSQL database
  agent.add_datasource(
    Forestadmin::Datasource::ActiveRecord.new,
    name: 'main'
  )

  # MongoDB for analytics
  agent.add_datasource(
    Forestadmin::Datasource::Mongoid.new,
    name: 'analytics'
  )
  ```
</CodeGroup>

<Warning>
  **Looking to enrich a single record?**

  If you want to add computed fields or fetch external data to enrich individual records (not load entire collections), use **Smart Fields** instead of adding a datasource.

  [Learn how to enrich data with computed fields →](/product/process/fields/computed)
</Warning>

[Browse available datasources →](/get-started/connect/data-sources/overview)
