docs: Add ASCII architecture and data flow diagrams
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
a7d5f39472
commit
203ba7197e
1 changed files with 64 additions and 0 deletions
64
README.md
64
README.md
|
|
@ -130,6 +130,70 @@ The dashboard is protected by an API key set in `.env`. When accessing the dashb
|
|||
|
||||
To reset the key in your browser: open DevTools (F12) > Application > Local Storage > delete `analyticsApiKey`, then refresh.
|
||||
|
||||
## Architecture
|
||||
|
||||
```
|
||||
https://your-domain
|
||||
|
|
||||
+-------v--------+
|
||||
| Nginx Proxy |
|
||||
| (LibreChat) |
|
||||
+---+-------+----+
|
||||
| |
|
||||
/api, /chat | | /librechat-analytics/*
|
||||
| |
|
||||
+-------v--+ +-v------------------+
|
||||
| LibreChat | | Analytics Dashboard |
|
||||
| :3080 | | :3001 |
|
||||
+-------+---+ +---------+----------+
|
||||
| |
|
||||
| MongoDB |
|
||||
| queries |
|
||||
| |
|
||||
+---v----------------v---+
|
||||
| MongoDB |
|
||||
| (LibreChat database) |
|
||||
| |
|
||||
| collections: |
|
||||
| - transactions |
|
||||
| - users |
|
||||
| - agents |
|
||||
+------------------------+
|
||||
```
|
||||
|
||||
```
|
||||
User sends message in LibreChat
|
||||
|
|
||||
v
|
||||
+------------------+ +------------------+ +-------------------+
|
||||
| LibreChat calls |---->| LLM processes |---->| LibreChat records |
|
||||
| LLM API | | prompt + reply | | transaction |
|
||||
| (Claude, GPT, | | returns tokens | | in MongoDB |
|
||||
| Gemini, etc.) | | used | | |
|
||||
+------------------+ +------------------+ +--------+----------+
|
||||
|
|
||||
Transaction record: |
|
||||
+----------------------------+ |
|
||||
| user: ObjectId |<+
|
||||
| model: "claude-sonnet-4-6" |
|
||||
| tokenType: "prompt" |
|
||||
| rawAmount: -15234 |
|
||||
| tokenValue: -45.702 |
|
||||
| (rawAmount x $3/1M) |
|
||||
| createdAt: Date |
|
||||
+----------------------------+
|
||||
|
|
||||
v
|
||||
+----------------------------+
|
||||
| Analytics Dashboard reads |
|
||||
| tokenValue from MongoDB |
|
||||
| |
|
||||
| cost = |tokenValue| / 1M |
|
||||
| = 45.702 / 1000000 |
|
||||
| = $0.000046 |
|
||||
+----------------------------+
|
||||
```
|
||||
|
||||
## Cost Calculation
|
||||
|
||||
### How it works
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue