The RAGFlow Admin Service and CLI provide a dedicated management layer for system administrators to oversee users, monitor service health, and perform maintenance tasks. This system is implemented as a dual-layer architecture: a Go-based admin server for core operations and a multi-language CLI (Python and Go) for developer and operator interactions.
The Admin Service operates as a privileged management interface. It provides endpoints for superuser authentication, user lifecycle management, and system-wide settings.
The administrative logic is primarily implemented in the Go backend, which provides high-performance handling of system management tasks.
Handler struct internal/admin/handler.go40-43is_superuser flag to be true. The system checks this flag during the login process in Handler.Login internal/admin/handler.go110-113/api/v1/admin prefix to handle user management, service control, and system variables via the Router.Setup method internal/admin/router.go45-167Service struct encapsulates interactions with various DAOs (Data Access Objects) for managing tenants, files, tasks, and ingestion processes internal/admin/service.go46-67The following diagram illustrates the authentication flow for administrative access.
Admin Login Sequence
Sources: internal/admin/handler.go94-136 internal/admin/router.go49 internal/admin/handler.go46-51
The ragflow-cli is a command-line interface that allows administrators and users to interact with RAGFlow services. The codebase features both a Go-native implementation and a Python client wrapper.
Lexer and Parser to handle SQL-like syntax (e.g., LIST DATASETS, CREATE USER) and meta-commands internal/cli/parser.go27-42 internal/cli/user_parser.go128-169Lark-based parser to translate natural language commands into API calls via the RAGFlowClient admin/client/ragflow_client.py52-55APIMode and AdminMode, allowing it to target different system components based on the CommandLineMode internal/cli/parser.go236-249 internal/cli/cli_http.go25-36Lexer performs tokenization of input strings, identifying keywords like LOGIN, LIST, SERVICES, and ADMIN internal/cli/lexer.go187-251The ragflow-cli supports a wide range of commands. Commands are parsed by the Parser internal/cli/parser.go50-61 and then executed by the CLI struct's methods internal/cli/cli_http.go25-36
| Category | Example Commands | Go Parser Method | Go Executor Method |
|---|---|---|---|
| System (User) | PING, SHOW VERSION, LIST CONFIGS | parseAPIPingServer internal/cli/user_parser.go65-73 parseAPIShowVersion internal/cli/user_parser.go301-315 parseAPIListConfigs internal/cli/user_parser.go172-180 | PingServerByCommand internal/cli/common_command.go112-118 APIShowVersionCommand internal/cli/user_command.go41-73 ListConfigs internal/cli/user_command.go75-115 |
| System (Admin) | ADMIN PING, ADMIN SHOW VERSION, ADMIN LIST CONFIGS | parseAdminPingServer internal/cli/admin_parser.go72-98 parseAdminShowVersion internal/cli/admin_parser.go338-352 parseAdminListConfigs internal/cli/admin_parser.go194-202 | PingAdmin internal/cli/admin_command.go27-48 AdminShowVersionCommand internal/cli/admin_command.go109-116 AdminListConfigsCommand internal/cli/admin_command.go263-264 |
| User Management (User) | REGISTER USER, LOGIN USER, LOGOUT | parseAPIRegister internal/cli/user_parser.go75-120 parseAPILoginUser internal/cli/user_parser.go19-53 parseAPILogout internal/cli/user_parser.go55-63 | LoginUserByCommand internal/cli/common_command.go33-54 Logout internal/cli/common_command.go216-253 |
| User Management (Admin) | ADMIN CREATE USER, ADMIN DROP USER, ADMIN LIST USERS | parseAdminCreateUser internal/cli/admin_parser.go303-315 parseAdminDropUser internal/cli/admin_parser.go317-328 parseAdminListUsersCommand internal/cli/admin_parser.go273-281 | AdminCreateUserCommand internal/cli/admin_command.go221-222 AdminDropUserCommand internal/cli/admin_command.go242-243 AdminListUsersCommand internal/cli/admin_command.go253-254 |
| Service Management (Admin) | ADMIN LIST SERVICES, ADMIN START SERVICE | parseAdminListServices internal/cli/admin_parser.go154-162 parseAdminStartService internal/cli/admin_parser.go362-373 | AdminListServicesCommand internal/cli/admin_command.go266-267 AdminStartServiceCommand internal/cli/admin_command.go268-269 |
| Ingestion Management (Admin) | ADMIN LIST INGESTION TASKS, ADMIN STOP INGESTION TASKS | parseAdminListIngestionTasks internal/cli/admin_parser.go258-274 parseAdminStopIngestionTasks internal/cli/admin_parser.go433-446 | ListAdminIngestionTasks internal/cli/admin_command.go290-291 AdminStopIngestionCommand internal/cli/admin_command.go284-285 |
Sources: internal/cli/user_parser.go128-169 internal/cli/parser.go80-144 internal/cli/parser.go146-234 internal/cli/cli_http.go38-200
The following diagram illustrates the general flow of how a command is processed by the Go CLI.
CLI Command Processing Flow
Sources: internal/cli/parser.go50-61 internal/cli/cli_http.go25-35 internal/cli/cli_http.go38-200 internal/admin/handler.go40-51 internal/admin/service.go70-93
The administrative logic is primarily contained in the Go internal/admin package and the Python admin/server directory.
Service in internal/admin/service.go provides methods to list all users and handle their lifecycle, including transaction-safe user creation internal/admin/service.go144-161 internal/admin/service.go172-229IsSuperuser pointer in the user entity internal/admin/handler.go110-113Service provides functions to list, stop, and remove ingestion tasks by wrapping the IngestionTaskService internal/admin/service.go106-116The admin handler provides endpoints to monitor the health and configuration of internal components.
GET /healthz returns the status of various components (Redis, DB, etc.) via service.GetComponentsHealthz internal/admin/handler.go60-73ListConfigs command retrieves settings, reporting on Redis, Database, and Document Engine status internal/cli/user_command.go75-115GET /version endpoint internal/admin/router.go99Code Entity Mapping: Admin Service Layer
Sources: internal/admin/handler.go40-51 internal/admin/router.go36-167 internal/admin/service.go70-93 internal/admin/service.go106-116
The system tracks service availability through heartbeats and periodic status updates.
/healthz, /live, and /api/v1/admin/ping endpoints used by the CLI to verify connectivity internal/admin/router.go40-48 internal/admin/handler.go60-83GetConfigs function in the CLI parses server configuration data to report on the status of Redis, the Document Engine (Elasticsearch/Infinity), and the Database internal/cli/user_command.go117-208Service.ListIngestionTasks method retrieves all tasks for administrative oversight internal/admin/service.go106-108Handler.ShowMessageQueue endpoint allows monitoring of message flow in the system internal/admin/router.go103Sources: internal/admin/handler.go60-83 internal/cli/user_command.go117-208 internal/admin/service.go106-108 internal/admin/router.go103
Refresh this wiki
This wiki was recently refreshed. Please wait 4 days to refresh again.