# Running modes

| Mode                | Description                                              |
| ------------------- | -------------------------------------------------------- |
| `LOCAL` ,`EMBEDDED` | To run Datashare on a single computer for a single user. |
| `SERVER`            | To run Datashare on a server for multiple users.         |

> **Note:** Document processing pipeline stages are run with `datashare stage run` (see [CLI stages](/datashare/concepts/cli-stages.md)). The async task worker daemon is started with `datashare worker run`.

## Web modes

There are two modes:

In **local mode** and **embedded mode**, Datashare provides a self-contained software application that users can install and run on their own local machines. The software allows users to search into their documents within their own local environments, without relying on external servers or cloud infrastructure. This mode offers enhanced data privacy and control, as the datasets and analysis remain entirely within the user's own infrastructure.

In **server mode**, Datashare operates as a centralized server-based system. Users can access to the platform through a web interface, and the documents are stored and processed on Datashare's servers. This mode offers the advantage of easy accessibility from anywhere with an internet connection, as users can log in to the platform remotely. It also facilitate seamless collaboration among users, as all the documents and analysis are centralized.

### Comparaison between modes

The running modes offer advantages and limitations. This matrix summarizes the differences:

|                 | `local` | `server` |
| --------------- | ------- | -------- |
| Multi-users     | ❌       | ✅        |
| Multi-projects  | ✅       | ✅        |
| Access-control  | ❌       | ✅        |
| Indexing UI     | ✅       | ❌        |
| Plugins UI      | ✅       | ❌        |
| Extension UI    | ✅       | ❌        |
| HTTP API        | ✅       | ✅        |
| API Key         | ✅       | ✅        |
| Single JVM      | ✅       | ❌        |
| Tasks execution | ✅       | ❌        |

*When running Datashare in local mode, users can choose to use embedded services (like ElasticSearch, SQLITE, in-memory key/value store) on the same JVM than Datashare. This variant of the local mode is called "*[*embedded mode*](/datashare/local-mode/about-the-local-mode/embedded-mode.md)*" and allows user to run Datashare without having to setup any additional software. The embedded mode is used by default.*

## Pipeline stages

Pipeline stages allow Datashare to process documents without a web server. Stages can be used in conjunction with both local and server modes, and allow users to distribute heavy tasks between several servers. They are now run with `datashare stage run --stages SCAN,INDEX,NLP`.

If you want to learn more about which stages you can execute, checkout the [stages documentation](/datashare/concepts/cli-stages.md).

## Daemon modes

Those modes are intended to be used for actions that require "waiting" for pending tasks. The task worker daemon is started with `datashare worker run`.

In **batch download mode**, the daemon waits for a user to request a batch download of documents. When a request is received, the daemon starts a task to download the document matching the user search, and bundle them into a zip file.

In **batch search mode**, the daemon waits for a user to request a batch search of documents. To create a batch search, users must go through the dedicated form on Datashare where they can upload a list of search terms (in CSV format). The daemon will then start a task to search all matching documents and store every occurrences in the database.

## How to change modes

Datashare is shipped as a single executable, with all modes available. As previously mentioned, the default mode is the embedded mode. Running `datashare` with no arguments is equivalent to `datashare app start` — it starts the web application in the default mode. You can optionally specify a different mode. For instance on Ubuntu/Debian:

```sh
datashare app start --mode SERVER \
  # Dummy session filter to creates ephemeral users
  --authFilter org.icij.datashare.session.YesCookieAuthFilter \
  # Name of the default project for every user
  --defaultProject local-datashare \
  # URI of Elasticsearch
  --elasticsearchAddress http://elasticsearch:9200 \
  # URI of Redis 
  --redisAddress redis://redis:6379 \
  # store user sessions in Redis.
  --sessionStoreType REDIS
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://icij.gitbook.io/datashare/concepts/running-modes.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
