Metadata-Version: 2.4
Name: zettabrain-teams
Version: 0.1.0
Summary: Multi-user RAG server with team access control — built on zettabrain-rag
Author-email: ZettaBrain <hello@zettabrain.ai>
License: Proprietary
Requires-Python: >=3.9
Description-Content-Type: text/markdown
Requires-Dist: zettabrain-rag
Requires-Dist: fastapi>=0.111.0
Requires-Dist: uvicorn[standard]>=0.29.0
Requires-Dist: python-jose[cryptography]>=3.3.0
Requires-Dist: bcrypt>=4.1.0
Requires-Dist: sqlmodel>=0.0.19
Requires-Dist: python-multipart>=0.0.9
Requires-Dist: aiofiles>=23.2.1
Requires-Dist: ldap3>=2.9.1

# ZettaBrain Teams

Multi-user RAG server with team access control — the commercial layer built on [zettabrain-rag](https://github.com/zettabrain/zettabrain-rag).

- JWT-based login with admin / user roles
- Teams with manager / member / viewer roles
- Per-team isolated document collections (ChromaDB)
- Full audit log — every query recorded
- Confidence scoring on every answer
- Single-page web UI with admin console

---

## Quick install (Linux server, run as root)

```bash
# 1. Install pipx if needed
python3 -m pip install pipx && python3 -m pipx ensurepath

# 2. Install zettabrain-teams
pipx install git+https://github.com/zettabrain/zettabrain-teams

# 3. Run the one-command setup (installs Ollama, pulls models, creates systemd service)
sudo zettabrain-teams-setup
```

That's it. The setup script:
- Installs [Ollama](https://ollama.com) if not present
- Pulls `llama3.1:8b` (~5 GB) and `nomic-embed-text` (~274 MB)
- Creates `/opt/zettabrain-teams/{data,chromadb,certs}`
- Registers and starts a `zettabrain-teams` systemd service

Then open **`http://<your-server-ip>:7861`** in a browser.  
The default admin password is printed to the console on first boot.

---

## Setup options

```bash
sudo zettabrain-teams-setup \
  --port 7861 \
  --llm  llama3.1:8b \
  --embed nomic-embed-text \
  --no-systemd        # skip systemd, start manually instead
```

---

## Starting / stopping

```bash
# Managed by systemd after setup
sudo systemctl start   zettabrain-teams
sudo systemctl stop    zettabrain-teams
sudo systemctl restart zettabrain-teams
sudo journalctl -u zettabrain-teams -f   # live logs

# Or start manually (e.g. dev/testing)
zettabrain-teams --port 7861
```

---

## Firewall

Open port **7861** on your firewall or cloud security group so users can reach the UI.

**AWS example:**
```bash
aws ec2 authorize-security-group-ingress \
  --group-id sg-xxxxxxxx \
  --protocol tcp --port 7861 --cidr 0.0.0.0/0
```

**UFW example:**
```bash
sudo ufw allow 7861/tcp
```

---

## Admin workflow

1. Log in at `http://<ip>:7861` with `admin` + the generated password
2. **Admin → Users** — create user accounts
3. **Admin → Teams & Members** — create a team, expand it, add users with roles
4. Ingest documents for a team:
   ```bash
   ZETTABRAIN_CHROMA=/opt/zettabrain-teams/chromadb/<team-slug> \
   ZETTABRAIN_DOCS=/path/to/your/documents \
   zettabrain-ingest
   ```
5. Users log in, select their team from the sidebar, and start chatting

---

## Configuration

`/opt/zettabrain-teams/teams.env` is created on first setup:

| Variable | Default | Description |
|----------|---------|-------------|
| `ZBT_PORT` | `7861` | Server port |
| `ZETTABRAIN_LLM_MODEL` | `llama3.1:8b` | Ollama LLM model |
| `ZETTABRAIN_EMBED_MODEL` | `nomic-embed-text` | Ollama embed model |
| `OLLAMA_HOST` | `http://localhost:11434` | Remote Ollama if not local |
| `ZBT_JWT_SECRET` | auto-generated | JWT signing secret (auto-created) |
| `ZBT_TOKEN_EXPIRE` | `480` | Token expiry in minutes |

---

## Requirements

- Linux (Ubuntu 20.04+ recommended)
- Python 3.9+
- 8 GB RAM minimum (16 GB recommended for `llama3.1:8b`)
- ~10 GB disk for models

GPU is optional — Ollama runs in CPU-only mode if no GPU is detected.

---

## Architecture

```
zettabrain-teams (port 7861)
├── FastAPI + SQLModel (SQLite)     — users, teams, audit log
├── JWT auth                         — login / token
├── ChromaDB per team               — /opt/zettabrain-teams/chromadb/<slug>/
└── zettabrain-rag                  — hybrid_retrieve(), RAG prompt, embeddings
        └── Ollama (port 11434)     — LLM + embeddings
```

---

## Upgrading

```bash
pipx upgrade zettabrain-teams
# or reinstall from GitHub for latest commit:
pipx reinstall zettabrain-teams
sudo systemctl restart zettabrain-teams
```
