The admin panel exposes two configuration endpoints that affect all users: the Terms of Service document and the NutriBot AI system prompt.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/JuanSebasSV/healtyhelp/llms.txt
Use this file to discover all available pages before exploring further.
Terms of Service
Data Model — TermsDocument
Each time terms are published a new document is created in the TermsDocument collection. The current active version is always the one with the most recent publishedAt.
| Field | Type | Description |
|---|---|---|
version | String (required) | Semantic version string, e.g. "1.2.0" |
content | String (required) | Full HTML content of the terms |
publishedBy | ObjectId → User | Admin who published this version |
publishedAt | Date | Defaults to new Date() at creation time |
Seeding Initial Terms
When the server starts,seedTerms.js checks whether any TermsDocument exists in the collection. If it is empty, version 1.0.0 (the default Colombian legal framework text) is inserted automatically. If any document already exists, the script exits silently with no changes.
Get the Current Terms
Returns the document with the latestpublishedAt.
terms is null.
Publish a New Version
- Both
versionandcontentare required — omitting either returns400. versionmust differ from the currently active version — publishing the same version string returns400.
updateMany — all other accounts (including other admins) match { _id: { $ne: req.user._id } } and have their termsAccepted reset to false.
TermsManager Component
client/src/components/admin/TermsManager.jsx provides a rich-text editor (using contentEditable + document.execCommand) with:
- Block-level format selector (paragraph, H1, H2, H3).
- Inline formatting buttons (bold, italic, underline).
- List buttons (unordered, ordered), blockquote.
- Undo / redo.
- Character counter.
- Side-by-side “Vista previa” toggle that renders the HTML output.
- Version input field — publish button is disabled until
versionis non-empty and differs from the active version.
NutriBot AI Prompt Configuration
Data Model — AIConfig
A single AIConfig document lives in the database. If none exists it is created automatically with the default prompt.
| Field | Type | Description |
|---|---|---|
prompt | String | System prompt injected before every NutriBot conversation |
TTL Cache
To avoid a database read on every chat message the server keeps an in-memory cache of theAIConfig document:
PUT /api/chat/prompt succeeds, _configCache is reset to null so the next request re-reads from MongoDB. This means changes to the prompt take effect within at most 60 seconds for any active conversations.
Get the Current Prompt
Update the Prompt
prompt returns 400.
The
GET and PUT /api/chat/prompt routes only require protect (any authenticated user). The admin panel UI restricts access at the component level — only users with role: "admin" reach the PanelIA tab.How the Prompt Is Used at Runtime
When a user sends a message to NutriBot (POST /api/chat), the system prompt is assembled as:
PanelIA Component
client/src/components/admin/PanelIA.jsx shows:
- A header with the NutriBot robot icon and subtitle.
- A status badge: Llama 3.3 70B · Activo.
- Metric cards (total users, messages today — placeholder, tokens used — placeholder).
- A resizable
<textarea>for editing the system prompt with a live character counter. - A note reminding admins that the user health profile is appended automatically.
- A Guardar instrucciones button that calls
PUT /api/chat/prompt.