Skip to content

Commit efaf375

Browse files
committed
feat(api): default port 7566 + name the install extra/command "web"
The API server also serves the Knowledge Workbench UI, so `web` reads truer than `api` for what people install and run. Make `[web]` the canonical extra and add an `openkb-web` console script; keep `[api]` (as a self-referential alias) and `openkb-api` working for backwards compatibility. README and the rest-api example now lead with the `web` names. `python -m openkb.api` (the module path) is unchanged. Also move the default API port off the crowded 8000 to 7566 ("KB" = ASCII 75,66) to cut collisions with other local dev servers. Updated: the argparse default, the default CORS origins, the Vite dev-proxy target, the connection-dialog placeholder, and the README/examples. A server already running on 8000 keeps its port; the new default only applies to freshly started servers. Claude-Session: https://claude.ai/code/session_01XMxbhmAkxxVV8CFWCZDBaG
1 parent 715a623 commit efaf375

8 files changed

Lines changed: 37 additions & 23 deletions

File tree

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,13 +123,13 @@ Subscription-based providers that authenticate via OAuth device flow (e.g. `chat
123123
OpenKB ships a bundled web UI, served by the REST API at `/`. Install the API extra and start the server — no configuration needed:
124124

125125
```bash
126-
pip install "openkb[api]"
127-
openkb-api # serves the API + Workbench at http://127.0.0.1:8000/
126+
pip install "openkb[web]"
127+
openkb-web # serves the API + Workbench at http://127.0.0.1:7566/
128128
```
129129

130-
Open `http://127.0.0.1:8000/` for the Workbench. Auth is off by default (local-first); set `OPENKB_API_TOKEN` to require a bearer token before exposing the server. See the [full Web UI guide](examples/rest-api/README.md#knowledge-workbench-web-ui).
130+
Open `http://127.0.0.1:7566/` for the Workbench. Auth is off by default (local-first); set `OPENKB_API_TOKEN` to require a bearer token before exposing the server. See the [full Web UI guide](examples/rest-api/README.md#knowledge-workbench-web-ui).
131131

132-
> Working on the UI itself? Run the Vite dev server with `cd frontend && npm install && npm run dev` (it proxies `/api` to a running `openkb-api`), or `npm run build` to regenerate the bundled `openkb/web/`.
132+
> Working on the UI itself? Run the Vite dev server with `cd frontend && npm install && npm run dev` (it proxies `/api` to a running `openkb-web`), or `npm run build` to regenerate the bundled `openkb/web/`.
133133
134134
# 🧩 How OpenKB Works
135135

@@ -341,7 +341,7 @@ The skill is read-only. It won't run `openkb add`, `remove`, or `lint --fix` wit
341341

342342
# REST API
343343

344-
OpenKB ships a FastAPI service for HTTP clients. Install with `pip install -e ".[api]"`, then start with `python -m openkb.api`. The interactive API reference is at [`/docs`](http://127.0.0.1:8000/docs) (importable into Postman).
344+
OpenKB ships a FastAPI service for HTTP clients. Install with `pip install -e ".[web]"`, then start with `python -m openkb.api`. The interactive API reference is at [`/docs`](http://127.0.0.1:7566/docs) (importable into Postman).
345345

346346
See the [full REST API reference](examples/rest-api/README.md#rest-api) for endpoints, auth, and SSE streaming.
347347

examples/rest-api/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This guide covers the OpenKB REST API (FastAPI) and the bundled Knowledge Workbench web UI.
44

5-
> The interactive API reference is served live at [`/docs`](http://127.0.0.1:8000/docs) (OpenAPI/Swagger) once the server is running — you can import `/openapi.json` directly into Postman.
5+
> The interactive API reference is served live at [`/docs`](http://127.0.0.1:7566/docs) (OpenAPI/Swagger) once the server is running — you can import `/openapi.json` directly into Postman.
66
77
## Knowledge Workbench (Web UI)
88

@@ -11,20 +11,20 @@ OpenKB ships a bundled web single-page app — the **Knowledge Workbench** — s
1111

1212
```bash
1313
# 1. Install with the API extra (the built UI ships inside the package)
14-
pip install "openkb[api]"
14+
pip install "openkb[web]"
1515

1616
# 2. Start the server — no config needed for local use
17-
openkb-api --host 127.0.0.1 --port 8000 # serves the API + Workbench at http://127.0.0.1:8000/
17+
openkb-web --host 127.0.0.1 --port 7566 # serves the API + Workbench at http://127.0.0.1:7566/
1818
```
1919

2020
Optional environment variables:
2121

2222
- `OPENKB_KB_ROOT` — where REST-created knowledge bases are stored (default `~/.config/openkb/kbs`).
2323
- `OPENKB_API_TOKEN` — set it to require bearer auth (see [Authentication](#authentication-and-common-behavior)); leave unset for open local use.
2424

25-
> **From a source checkout?** The built bundle (`openkb/web/`) is git-ignored, so an editable install (`pip install -e ".[api]"`) has no UI until you build it once: `cd frontend && npm install && npm run build` (outputs to `openkb/web/`). Or run the Vite dev server with `npm run dev` (it proxies `/api` to a running `openkb-api`). Without the bundle, `openkb-api` serves only the REST API under `/api/v1` and `/` returns a 404.
25+
> **From a source checkout?** The built bundle (`openkb/web/`) is git-ignored, so an editable install (`pip install -e ".[web]"`) has no UI until you build it once: `cd frontend && npm install && npm run build` (outputs to `openkb/web/`). Or run the Vite dev server with `npm run dev` (it proxies `/api` to a running `openkb-web`). Without the bundle, `openkb-web` serves only the REST API under `/api/v1` and `/` returns a 404.
2626
27-
Open `http://127.0.0.1:8000/` in your browser. With no `OPENKB_API_TOKEN` set it connects to the local API immediately — no prompt. (If a token is configured, a **Connection** dialog asks for it once and caches it in the browser; you can also open it manually to point the UI at a remote API base.) The Workbench then provides:
27+
Open `http://127.0.0.1:7566/` in your browser. With no `OPENKB_API_TOKEN` set it connects to the local API immediately — no prompt. (If a token is configured, a **Connection** dialog asks for it once and caches it in the browser; you can also open it manually to point the UI at a remote API base.) The Workbench then provides:
2828

2929
- **Overview** — index/concept/summary/report stat cards, clickable concept chips, recent documents, and last-compile/lint activity.
3030
- **Documents** — drag-and-drop multi-file upload with per-file SSE progress, hash table, and delete with confirmation.
@@ -44,15 +44,15 @@ frontends, or other HTTP clients.
4444
Install the API dependencies if needed:
4545

4646
```bash
47-
pip install -e ".[api]"
47+
pip install -e ".[web]"
4848
```
4949

5050
Start the API server:
5151

5252
```powershell
5353
$env:OPENKB_API_TOKEN="test-token"
5454
$env:OPENKB_KB_ROOT="D:\project\OpenKB\kbs"
55-
.\.venv\Scripts\python.exe -m openkb.api --host 127.0.0.1 --port 8000
55+
.\.venv\Scripts\python.exe -m openkb.api --host 127.0.0.1 --port 7566
5656
```
5757

5858
### Authentication and common behavior
@@ -61,7 +61,7 @@ Auth is **opt-in**, controlled by the `OPENKB_API_TOKEN` server environment
6161
variable:
6262

6363
- **Unset (default)** — the API is unauthenticated. This is the local-first
64-
default, so `openkb-api` and the Workbench work with no configuration.
64+
default, so `openkb-web` and the Workbench work with no configuration.
6565
- **Set** — every request must carry the token, and the Workbench prompts for
6666
it once (cached in the browser):
6767

@@ -73,7 +73,7 @@ variable:
7373

7474
> **Exposing the server?** Always set `OPENKB_API_TOKEN` when binding to a
7575
> non-loopback host (e.g. `--host 0.0.0.0`) — otherwise the API, and every KB
76-
> it can reach, is world-open. `openkb-api` prints a warning in that case.
76+
> it can reach, is world-open. `openkb-web` prints a warning in that case.
7777
7878
`OPENKB_KB_ROOT` is optional. It controls where REST-created knowledge bases
7979
are stored. If unset, OpenKB uses `~/.config/openkb/kbs`.
@@ -419,4 +419,4 @@ no watcher is active for that KB.
419419
stop after this many seconds). Stream events: `start`, the watcher's own events
420420
(e.g. `added`, `updated`, `failed`, `final`), `error`, `done`.
421421

422-
The full OpenAPI schema is at [`/openapi.json`](http://127.0.0.1:8000/openapi.json) — importable into Postman or any OpenAPI-compatible client.
422+
The full OpenAPI schema is at [`/openapi.json`](http://127.0.0.1:7566/openapi.json) — importable into Postman or any OpenAPI-compatible client.

frontend/src/App.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ function ConnectionDialog({
107107
<input
108108
value={base}
109109
onChange={(e) => setBase(e.target.value)}
110-
placeholder="http://127.0.0.1:8000"
110+
placeholder="http://127.0.0.1:7566"
111111
className={inputCls}
112112
/>
113113
</div>

frontend/vite.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import path from "path"
22
import react from "@vitejs/plugin-react"
33
import { defineConfig } from "vite"
44

5-
// Dev server proxies /api to the OpenKB REST API on :8000; production
5+
// Dev server proxies /api to the OpenKB REST API on :7566; production
66
// serves the built bundle from the same origin via FastAPI StaticFiles.
77
// outDir MUST stay ../openkb/web — the wheel packages it from there
88
// (see pyproject.toml [tool.hatch.build] artifacts).
@@ -22,7 +22,7 @@ export default defineConfig({
2222
port: 5173,
2323
proxy: {
2424
"/api": {
25-
target: "http://127.0.0.1:8000",
25+
target: "http://127.0.0.1:7566",
2626
changeOrigin: true,
2727
},
2828
},

openkb/api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -776,7 +776,7 @@ async def api_not_found(path: str) -> Any:
776776
def main() -> None:
777777
parser = argparse.ArgumentParser(description="Run the OpenKB REST API.")
778778
parser.add_argument("--host", default="127.0.0.1")
779-
parser.add_argument("--port", type=int, default=8000)
779+
parser.add_argument("--port", type=int, default=7566)
780780
parser.add_argument("--reload", action="store_true")
781781
args = parser.parse_args()
782782

openkb/api_helpers.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ def _configure_cors(app: FastAPI) -> None:
6969
origins = [o.strip() for o in raw.split(",") if o.strip()] or [
7070
"http://localhost:5173",
7171
"http://127.0.0.1:5173",
72-
"http://localhost:8000",
73-
"http://127.0.0.1:8000",
72+
"http://localhost:7566",
73+
"http://127.0.0.1:7566",
7474
]
7575
# A wildcard origin with credentials is insecure: any site can issue
7676
# credentialed cross-origin requests. Reject this combination by forcing

pyproject.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ Issues = "https://github.com/VectifyAI/OpenKB/issues"
5959

6060
[project.scripts]
6161
openkb = "openkb.cli:cli"
62+
openkb-web = "openkb.api:main"
63+
# Backwards-compatible alias for the historical name; same entry point.
6264
openkb-api = "openkb.api:main"
6365

6466
[tool.pytest.ini_options]
@@ -73,7 +75,11 @@ dev = [
7375
"mypy==1.15.0",
7476
"types-PyYAML==6.0.12.20260518",
7577
]
76-
api = ["fastapi", "uvicorn", "python-multipart"]
78+
# The Knowledge Workbench Web UI is served by this FastAPI server. `web` is the
79+
# canonical extra; `api` is a backwards-compatible alias so an existing
80+
# `pip install "openkb[api]"` keeps working.
81+
web = ["fastapi", "uvicorn", "python-multipart"]
82+
api = ["openkb[web]"]
7783

7884
[tool.hatch.version]
7985
source = "vcs"

uv.lock

Lines changed: 9 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)