Implementation:1Panel dev MaxKB URL Routing
| Knowledge Sources | |
|---|---|
| Domains | API, Deployment |
| Last Updated | 2026-10-10 00:00 GMT |
Overview
Concrete URL configuration that defines two configurable API surfaces (admin and chat) plus SPA static file serving, provided by MaxKB.
Description
MaxKB's web URL configuration (`urls/web.py`) defines two API surfaces whose prefixes are configurable via CONFIG.get_admin_path() (default `/admin`) and CONFIG.get_chat_path() (default `/chat`):
- /admin/api/* — Management API: users, tools, models_provider, folders, knowledge, system_manage, application, trigger, oss, homepage
- /chat/api/* — Runtime chat API: chat views + MCP endpoint
Both are backed by DRF + drf-spectacular (Swagger at `/admin/api-doc`). The Vue admin SPA and chat SPA are served as Django static files from `ui/dist` via `STATICFILES_DIRS`. The model service (`urls/model.py`) has a minimal routing with only `local_model.urls`.
Usage
Import this configuration when you need to:
- Understand the API URL layout
- Add new URL routes for admin or chat APIs
- Configure custom API path prefixes
Code Reference
Source Location
- Repository: MaxKB
- File: apps/maxkb/urls/web.py (web mode), apps/maxkb/urls/model.py (model mode)
Signature
# apps/maxkb/urls/web.py
admin_api_prefix = CONFIG.get_admin_path()[1:] + '/api/' # "admin/api/"
chat_api_prefix = CONFIG.get_chat_path()[1:] + '/api/' # "chat/api/"
urlpatterns = [
path(f"{admin_api_prefix}", include("users.urls")),
path(f"{admin_api_prefix}", include("tools.urls")),
path(f"{admin_api_prefix}", include("models_provider.urls")),
path(f"{admin_api_prefix}", include("folders.urls")),
path(f"{admin_api_prefix}", include("knowledge.urls")),
path(f"{admin_api_prefix}", include("system_manage.urls")),
path(f"{admin_api_prefix}", include("application.urls")),
path(f"{admin_api_prefix}", include("trigger.urls")),
path(f"{admin_api_prefix}", include("oss.urls")),
path(f"{admin_api_prefix}", include("homepage.urls")),
path(f"{chat_api_prefix}", include("chat.urls")),
# SPA static file serving
re_path(r'^(?P<path>(admin|chat)/.*)$', views.serve, ...),
]
# apps/maxkb/urls/model.py (minimal)
urlpatterns = [
path(f"{admin_api_prefix}", include("local_model.urls")),
]
Import
# URLs are loaded by Django automatically via ROOT_URLCONF setting
# from maxkb.urls.web import urlpatterns # (web mode)
# from maxkb.urls.model import urlpatterns # (model mode)
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| CONFIG.get_admin_path() | str | No | Admin API prefix (default: /admin) |
| CONFIG.get_chat_path() | str | No | Chat API prefix (default: /chat) |
Outputs
| Name | Type | Description |
|---|---|---|
| urlpatterns | Django URL patterns for all API apps + SPA serving |
Usage Examples
Understanding the URL Layout
# Admin API surface (management):
# /admin/api/users/... → users app
# /admin/api/models_provider/... → models_provider app
# /admin/api/knowledge/... → knowledge app
# /admin/api/application/... → application app
# /admin/api-doc → Swagger UI
# Chat API surface (runtime):
# /chat/api/chat/... → chat app
# /chat/api/mcp → MCP JSON-RPC endpoint
# SPA static files:
# /admin/... → Vue admin SPA (ui/dist)
# /chat/... → Vue chat embed SPA (ui/dist)