open-glean README

The project's README from github.com/hydra-db/open-glean. As one markdown file: README.md.

Open Glean, your second brain on Hydra DB

Open Glean is the AI workspace over Hydra DB. Ask a question across your memories, files, and connected apps. Open Glean retrieves the context, writes the answer, and cites its sources.

This is the open-source code for Open Glean. The Next.js server proxies requests to the official @hydradb/sdk. Keys are held in an encrypted, httpOnly session cookie and used server-side, never in the browser. You can also run it yourself with your own Hydra DB key.

Open Glean

Features

Getting started

npm ci
npm run dev

Copy .env.example to .env.local and set at least OPEN_GLEAN_SESSION_SECRET. Everything else is optional. Without a Hydra key, the app shows a connect screen and asks for one.

Open http://localhost:3000, then:

  1. Connect: paste your Hydra DB API key (create one at app.hydradb.com/keys) and pick a database.
  2. Add a model: in Settings, paste an OpenRouter (or other OpenAI-compatible) key and pick a model. It only writes answers; search works without it.
  3. Ask away, or add context first from the Context page (files, notes, URLs).

Running with Docker

docker build -t open-glean .
docker run -p 3000:3000 \
  -e OPEN_GLEAN_SESSION_SECRET=your-random-16-char-secret \
  -e HYDRA_API_KEY=your-hydra-key \
  -e OPENROUTER_API_KEY=your-openrouter-key \
  -e OPEN_GLEAN_LLM_MODEL=google/gemini-3.7-flash \
  -e MONGODB_URI=mongodb://your-mongo-host:27017 \
  open-glean

The image uses Next.js standalone output, so it ships only the runtime files and the dependencies the build uses. It runs as a non-root user.

How it works

Browser ──► Next.js proxy (/api/hydra/*) ──► @hydradb/sdk ──► api.hydradb.com
        └─► /api/llm/chat (streaming + web plugin) ─► your LLM provider

Environment & key security

API keys are not stored in the browser. When you connect in Settings, the key is verified server-side and stored in an AES-256-GCM-encrypted, httpOnly session cookie; every proxied request resolves it on the server. Nothing key-shaped is inlined into the JS bundle, localStorage, or any client state.

A stored key is also pinned to the endpoint it was stored with. A request may only choose the LLM base URL when it supplies its own API key. Otherwise a caller could pair an attacker-controlled URL with the server's key and have it sent there in an Authorization header.

Variable Purpose
OPEN_GLEAN_SESSION_SECRET Required in production. Any random 16+ char string. Encrypts the key session cookie.
HYDRA_API_KEY Optional deployment-level shared key: when set, no user key is needed at all
HYDRA_BASE_URL Optional default backend URL (defaults to https://api.hydradb.com)
HYDRA_DEFAULT_DATABASE Optional default tenant. Requests with no explicit database scope to this one.
MONGODB_URI Chat persistence. A MongoDB connection string, or a bare DocumentDB cluster endpoint (auto-detected via .docdb.*.amazonaws.com).
MONGODB_DB Database name for chats (defaults to open_glean).
OPENROUTER_API_KEY Optional server-level LLM key. When set, users need not enter their own.
OPEN_GLEAN_LLM_MODEL Default answer model id, e.g. openai/gpt-4o-mini. No built-in default. Without it (or a per-user model), answers are unavailable.
OPEN_GLEAN_LLM_BASE_URL Optional OpenAI-compatible endpoint for the server-level key (defaults to OpenRouter)
OPEN_GLEAN_ALLOW_PRIVATE_LLM_URL Allow an LLM base URL on a private or loopback address, for a local model such as Ollama or LM Studio. Off by default. It permits plaintext http: on a private address only. A public host still requires https:, and non-http schemes are rejected.
MONGODB_PROXY_KEY Shared secret for the Lambda proxy. The Lambda reads the same value as PROXY_KEY; the two names must match.
OPEN_GLEAN_MAX_CONCURRENT_RESEARCH Concurrent Deep Research runs per instance (default 3). Each run costs many LLM and retrieval calls

DocumentDB does not support IAM database authentication. The IAM token path in the code cannot authenticate against Amazon DocumentDB. AWS_REGION, AWS_IAM_USER_ARN and AWS_ACCESS_KEY_ID / AWS_SECRET_ACCESS_KEY are read by that path and are listed here only to describe what it expects. For DocumentDB, use a standard MongoDB connection string or the Lambda proxy.

Stack

Next.js 16, React 19, Tailwind CSS v4, and @hydradb/sdk. No other runtime dependency for data or AI.

License

Apache-2.0. See LICENSE and NOTICE.

Read NOTICE: connector logos are third-party trademarks and are not covered by the Apache grant.

open-glean (hydra-db/open-glean)

mongodb
Searching Database…

What is this?Open Glean is an open-source AI workspace built on Hydra DB: a 'second brain' you ask questions across your memories, files, and connected apps, with answers written from retrieved context and cited sources.
Is it a complete platform, or a frontend that needs Hydra DB behind it?It's a Next.js web app on top of Hydra DB: retrieval and storage live in your Hydra database, and the app's server proxies every call through the official @hydradb/sdk — you connect it to your Hydra side.
How do I get it running?Copy .env.example to .env.local and set OPENGLEANSESSIONSECRET (the rest is optional), then run the app — a Docker image is also available; it ships only runtime files and runs as a non-root user.
Do I need a Hydra DB API key to actually search my data?Yes — retrieval runs against your Hydra database. Create a key at app.hydradb.com/keys and paste it on the connect screen; a deployment can instead set a shared HYDRAAPIKEY so users need no key at all.
Will it answer out of the box, or do I have to configure a model first?Answers need an LLM: there is no built-in default model, so without OPENGLEANLLMMODEL (or a per-user pick in Settings) answers are unavailable. Hydra retrieval itself still works without one.
Where do my API keys and chat history end up?Keys never touch the browser: they are verified server-side and kept in an AES-256-GCM-encrypted httpOnly session cookie. Chats persist to MongoDB when reachable, with a localStorage fallback.
Is it free to use and modify, or is there a catch in the license?Apache-2.0 — free to use and modify. One catch from NOTICE: connector logos are third-party trademarks and are not covered by the Apache grant.
What is Deep Research?A mode for questions one query cannot answer: Open Glean plans a DAG of sub-questions, runs each level against Hydra in parallel, writes a finding per branch, dedupes sources into one numbered citation list, then writes the answer. A timeline shows the plan and live progress.
Which AI models can it use?Any OpenAI-compatible endpoint with your own key — a searchable OpenRouter model picker with favourites is built in. Local models such as Ollama or LM Studio work too if OPENGLEANALLOWPRIVATELLMURL is enabled (off by default).
Can I narrow where a query looks?Yes — from the top bar you pick the database and collections a query searches, and retrieval fans out across every selected collection. You can also open a single collection to search within it.
Does it search the live web too?Optionally — web search is served by your LLM provider's web plugin (OpenRouter), and its citations appear alongside the Hydra sources in the sources panel.
Creator
hydra-db
Size
1.4 MB
Stars
1.6K
Updated
CommitOct 14
Age
1mo
Commits · 90 Days