Skip to contents

Starts a web server that lets users upload their counts (a BIOM file, QIIME 2 or mothur output, or a plain table) and explore them with 'rbiom' plots in their browser. Projects are stored in an SQLite database and a set of files under data_dir.

Usage

run(
  port = 8080,
  host = "127.0.0.1",
  auth = "none",
  public_url = NULL,
  oidc_issuer = "https://auth.globus.org",
  oidc_client_id = NULL,
  oidc_client_secret = NULL,
  admins = NULL,
  forwarded_proto_header = NULL,
  client_ip_header = NULL,
  signin_days = 30,
  operator = NULL,
  contact = NULL,
  data_dir = tools::R_user_dir("atima", "data"),
  temp_dir = tempfile(pattern = "atima_"),
  cpus = parallelly::availableCores(),
  time_limit = NULL,
  jobs_per_user = 16,
  cache_size_mb = 100,
  max_upload_mb = 50,
  session_hours = 24,
  guest_days = 30,
  trash_days = 30,
  mcp_writes = TRUE,
  app_days = 30,
  app_changes_per_hour = 60,
  usage = TRUE,
  usage_months = 25,
  geo_db = NULL,
  legacy = NULL,
  open = interactive()
)

Arguments

port

Port to listen on.

host

IP address to listen on. The default, "127.0.0.1", only accepts connections from this computer. Use "0.0.0.0" to listen on all interfaces; that needs auth = "oidc".

auth

Who may use the server. "none", the default, is for one person on their own computer: there are no accounts and nothing to sign in to, and host must be a loopback address. "oidc" is for a shared server: visitors sign in through an OpenID Connect provider. See the section on signing in.

public_url

With auth = "oidc": the address people type to reach the server, such as "https://atima.example.org". Needed unless the server is only used from this computer, when it defaults to http://localhost:<port>.

oidc_issuer

The OpenID Connect provider's issuer URL. The default is Globus Auth; for ORCID use "https://orcid.org".

oidc_client_id, oidc_client_secret

The client id and secret that the provider gave you when you registered this server with it. Prefer the environment variables ATIMA_OIDC_CLIENT_ID and ATIMA_OIDC_CLIENT_SECRET to writing the secret in a script.

admins

With auth = "oidc": the provider's identifiers (sub claims) of the people who are administrators, as a character vector or one comma-separated string. Administrators can change public projects. The default, NULL, leaves administrators as they are in the database.

forwarded_proto_header

The name of a request header, set by a reverse proxy you control, that says whether the visitor used HTTPS; usually "X-Forwarded-Proto". The default, NULL, trusts no such header. Not needed when public_url starts with https://.

client_ip_header

The name of a request header, set by a reverse proxy you control, that holds the visitor's network address; "X-Real-IP" or "X-Forwarded-For". If it lists several addresses, the last is used: the one the proxy itself added. The default, NULL, uses the address of the connection, which behind a proxy is the proxy's.

signin_days

How long a sign-in lasts before the browser has to sign in again.

operator

With auth = "oidc": who runs this server, as the words to finish the sentence "This server is run by ...", such as "the Example Lab at Example University". Shown on the app's "Privacy and terms" page. The default, NULL, leaves that sentence out.

contact

With auth = "oidc": how the people who use the server can reach whoever runs it: an email address, or the https:// address of a page. Shown on the same page.

data_dir

Directory for the database and stored BIOM files. It is created, and filled with two example projects, the first time the server starts.

temp_dir

Directory for temporary files, including the figures and exports that browsers download. It must not be data_dir, or inside it: old files here are deleted.

cpus

The most CPU cores the server may use: the process that answers requests and the worker processes that run jobs (plots, uploads, exports, ...) together. The default is every core available. With cpus = 1 or 2, jobs run one after another. See the section on jobs.

time_limit

The longest a job may run, in seconds. A job that takes longer is stopped and the user is told so. The default, NULL, is no limit with auth = "none", where the computer is the user's own, and 60 seconds with auth = "oidc", where the limit keeps one person's long analysis from holding up everyone else.

jobs_per_user

With auth = "oidc": the most jobs one person (or one guest) may have waiting or running at the same time. See the section on jobs.

cache_size_mb

Upper limit, in megabytes, for the cache of computed results kept in data_dir. Half is for atima's own cache and half for rbiom's.

max_upload_mb

Largest upload to accept, in megabytes.

session_hours

A session is closed, and its unsaved changes and temporary files are deleted, when its browser tab has not been heard from for this many hours.

guest_days

A guest (someone who has not signed in) is forgotten after this many days without a visit, along with any projects that only they could open.

trash_days

A deleted project is kept for this many days, during which its editors can restore it, and is then erased.

mcp_writes

May AI apps change data: upload, edit, copy, share, publish and delete projects? FALSE offers them only the tools that read and compute. See the section on AI apps.

app_days

With auth = "oidc": an AI app that a person has connected stays connected until it has not been used for this many days.

app_changes_per_hour

The most changes one connected AI app may make in an hour.

usage

With auth = "oidc": record how the server is used, for the administrators' "Usage" page? See the section on usage. A local install never records anything.

usage_months

How many months the record of single actions and visits is kept. The daily counts made from it are kept.

geo_db

With usage: one or more files in MaxMind DB format (.mmdb) in which the country and the owner of a visitor's network are looked up, such as DB-IP's free "IP to Country Lite" and "IP to ASN Lite". A character vector, or one string with the paths separated by ;. The default, NULL, records neither.

legacy

Older atima installations whose users may import their projects: a named character vector, c(<label shown to users> = <file>), of files made by legacy_convert(). As an environment variable, <label>=<file> entries separated by ;. See the section "Importing from an older atima".

open

Open the app in a web browser once the server is up?

Value

Does not return; the server runs until the R session is interrupted. It then cancels running jobs, stops the worker processes and closes the database.

Details

The R session that calls run() answers requests and owns the database. Everything that reads a BIOM file or calls 'rbiom' is done by a pool of worker processes, so the server keeps answering while a plot is drawn. See the section on jobs for how many there are.

Every argument can also be set with an environment variable or an R option. The first of these that is set is used:

  1. the argument itself, e.g. run(port = 8080)

  2. the environment variable ATIMA_<NAME>, e.g. ATIMA_PORT=8080

  3. the R option atima.<name>, e.g. options(atima.port = 8080)

  4. the default shown below

Signing in

With auth = "none" there is nothing to set up. The server refuses to start on an address other computers can reach, and only answers requests addressed to localhost, 127.0.0.1 or [::1]. Everything belongs to one local user, including projects that guests or password accounts made with an earlier version of atima. Anyone who can use this computer while the server runs can open the app.

With auth = "oidc" atima keeps no passwords. Register the server with the provider as a web application (a confidential client) whose redirect URL is <public_url>/auth/callback, and give run() the client id and secret. atima reads everything else from the provider's discovery document and uses the authorization code flow with PKCE. A person is recognised by the provider's identifier for them, never by their email address. Visitors who have not signed in are guests: they can explore public projects, and what they upload is kept for guest_days and becomes theirs when they sign in.

The browser is recognised by one cookie. It cannot be read by scripts, is not sent with requests made by other sites, and is marked Secure whenever the site is served over HTTPS (see public_url and forwarded_proto_header). Serve a public server over HTTPS, through a reverse proxy.

Privacy and terms

With auth = "oidc" the app has a page, "Privacy and terms", linked from the menu and from beside the sign-in button. Its text ships with the package and describes what the software does: what it stores and for how long (using this server's guest_days and session_hours), who can see a project, that public projects are not reviewed, and that the service comes without warranty. Set operator and contact so that it also says who runs the server and how to reach them. It is a description of the software, not legal advice: if your institution needs its own terms, link to them from contact.

Usage

A shared server (auth = "oidc") keeps a record of how it is used, and its administrators find a page, "Usage", in the menu: how many people used the server over time and how many came back, the countries and institutions they came from and the sites that sent them, which analyses they ran, through the browser or an AI app, and whether jobs had to wait for a worker. The page's numbers can be downloaded as CSV files and summed up for a period, for a grant report. usage = FALSE switches the recording and the page off.

What is recorded is a row per action: the time, the number that stands for the user, the kind of action, the name of the 'rbiom' function, how it ended and how long it took. No network address, name or email address is recorded, and nothing of a project or of a request's settings. For a visit, the site the browser was sent from is recorded, and, if geo_db names lookup files, the country and the owner of the network it came from; the address is looked up in those files on this server and is not kept with the record. Requests that carry no cookie (crawlers, scripts) are counted by a hash of address and user agent that changes every day and cannot be turned back into an address. No cookie is set for any of this. The app's "Privacy and terms" page says all of it to the people who use the server.

The lookup files are not part of atima. DB-IP publishes free ones monthly at https://db-ip.com/db/lite.php under the Creative Commons Attribution 4.0 licence, which asks for a link to db-ip.com where the data is used; the Usage page carries one. Behind a reverse proxy, set client_ip_header, or every visitor has the proxy's address.

With auth = "none" nothing is recorded, there is no such page, and atima never reports use to anyone.

Importing from an older atima

atima 2 kept every project encrypted with keys that only its users' passwords unlock, so its data cannot be moved by an administrator alone. Instead, save the old database to a file once with legacy_convert(), and name the file in legacy. Someone who is signed in (or, with auth = "none", the local user) then finds "Import from an older atima" in the menu, types the email address and password they used on the old site, and chooses the projects to bring over. They are imported in the background, one at a time, while the person keeps working. The password is checked and the projects are decrypted in memory; the server holds the password only while that person's import runs, and neither it nor any key is stored or logged. A project is imported once: when someone else who could open it on the old site imports it later, they are given the same project with the access they had (editor or viewer). After five wrong passwords a person, and the old account they tried, must wait 15 minutes. This needs the 'bcrypt' package.

AI apps

The server is also a Model Context Protocol (MCP) server, at the path /mcp (for example http://127.0.0.1:8080/mcp). An AI app that is given that address can list and describe a person's projects, run 'rbiom' statistics, draw plots and export data. Unless mcp_writes is FALSE, it can also upload files, change, copy, share, publish and delete projects, as that person can in the browser. Every change an app makes is recorded and shown on the app's "Connected apps" page, one app may make app_changes_per_hour changes an hour, and a deleted project can be restored for trash_days. What the tools return is handed to the app, which may send it to its provider's servers, so connect an app only if the data may leave the computer that way.

With auth = "none" any app that is given the address is let in, as the local user. With auth = "oidc" the app must be approved by the person it works for: the server is an OAuth 2.1 authorization server for its own /mcp endpoint, the person signs in as they do in the browser and chooses whether the app may only read or may also change things, and can disconnect it again. An app identifies itself with a Client ID Metadata Document, an https address that the server fetches; addresses inside private networks are refused. The endpoint follows revision 2026-07-28 of the MCP specification, and also answers apps that only know the revisions of 2025.

Database

The database is the file sqlite.db in data_dir. When a newer version of atima needs to change its structure, the server first saves a copy as sqlite.db.v<N>.<date>.bak in the same directory, then upgrades the database in place.

Jobs

A plot, an upload, an export and anything else that reads a project's data is a job, run by a worker process. cpus is the number of CPU cores the whole server may use. One of them is kept for the process that answers requests (unless cpus is 1), and there is a worker process for each of the others, but no more than one for every 2 GB of the computer's memory, since each is an R session with 'rbiom' loaded. So with cpus = 8, seven jobs can run at the same time.

A job that calls an 'rbiom' function with a cpus argument (most plots, statistics and tables, and some exports) is told, through that argument, that it may use the cores that are free when it starts: all of them with auth = "none", half of them on a shared server so that the next job finds some free, and its share of them when other jobs are waiting too. Those cores are reserved for the job until it ends; atima counts what it has handed out and does not measure what a job uses. Every other job (uploads, edits, the plots of taxa that take no cpus) has one core. A new job starts as soon as a worker and one core are free, in the order the jobs arrived, and is never made to wait for more than one core.

A request that needs a worker waits in a queue if none is free. The queue holds ten jobs per worker; when it is full, further requests are answered 503 ("the server is busy") until there is room. On a shared server one person may have jobs_per_user jobs waiting or running; the next is answered 429 with a message to wait, so that one person's browser tabs, or one AI app calling many tools at once, cannot fill the queue for everyone else. A new plot, rarefaction or table page from a browser tab replaces that tab's earlier request of the same kind if it is still waiting or running. A job that passes time_limit, or is replaced, is interrupted; if it has not stopped five seconds later, its worker process is ended and a new one takes its place. A local install (auth = "none") has no time limit unless time_limit is given: an analysis that is stopped on a shared server can be run to its end on one's own computer.

Cleanup

When the server starts, and every ten minutes after that, it deletes closed and expired sessions, working copies that no session has open, guests who have not returned, projects that were deleted trash_days ago, private projects that nobody has in their project tree any more, connections of AI apps that have run out, stored files that nothing refers to, and old temporary files. See session_hours and guest_days. A shared server also deletes its record of single actions and visits once it is usage_months old. Saved projects that belong to a signed-in user are never erased unless somebody deleted them.

Server log

The server writes one line of JSON per request and per error to standard error. An error shown in the browser carries a short id; the log line with the same id has the details. To write the log to a file instead, set options(atima.log = "path/to/atima.log") before calling run().

Examples

if (interactive()) {
  # Serve on http://127.0.0.1:8080 and keep data in a temporary directory.
  atima::run(data_dir = tempfile("atima_data_"))
}