IN PROGRESS
Technical summary
Core NEXUS plugin that manages the platform's credits and resource consumption — tracks AI usage, fires a single alert when the configurable limit (default 90%) is reached and keeps a full transaction history, with a billing modal, bonus/plan pools and the /credits chat command.
Executed scope
plugin.json: v1.0.0, slugnexus-credits, "Core" category,is_core: true.- No own tab (no
tab.php):registerDoc"Sistema de Créditos" (credit-cardicon) +registerModal("credits")+ 4 API actions + Fastr. - State — JSON in
admin_configs(cfg_key = 'credits_state'):total(550),used,bonus_total(500),bonus_used(409),plan_total(50),plan_used,warn_sent; history incredits_history(idINT PK AI,amountDECIMAL,reasonTEXT,created_atDATETIME). credits_read()— defaults + saved-state merge + last 50 transactions (amount,reason,created_at as at).credits_write()— stripshistoryfrom the state and persists the JSON withINSERT ... ON DUPLICATE KEY UPDATE.credits_add($amount, $reason)— adds toused, records the transaction, computespct = used/total*100and, whenpct >= credits.warn_pct(default 90%, viasetting()) withwarn_sentfalse, callsnotify_credit_warning()and markswarn_sent = true— the alert fires only once per cycle.credits_set_total()— resets the limit and clears the alert flag.credits_reset()— deletes the state,TRUNCATE credits_historyand restarts with the defaults (CREDIT_TOTAL,used 0,warn_sent false).credits_pct()—min(100, used/total*100).- API: 4 actions —
credits(read),credits_add(floatamount+reason),ia_credits({ ia_credits: read }for the AIs) andia_credits_legacy(compat). - Modal
modals/credits.php(118 lines, PHP server-rendered, slate + indigo/violet theme) — "System Billing / Resource Consumption"; Bonus Resource Pool card (indigo-600 → violet-600gradient bar with glow; "Cycle expires in 29 days") and Base Tier Credits card (slate-200bar,emerald-600values); conditional Distributed Node Telemetry per-AI breakdown (emoji, author,last_updated, Bonusindigo-500/40+ Baseemerald-500/40bars — renders only when$ia_credits['ias']is populated externally); Credential Management admin panel (bg-indigo-50) withcredits_setform (Total Allocated Credits $,step 0.01, UPDATE POOL buttonindigo-600) andcredits_resetform (TERMINATE CYCLE & RESET COUNTER). - Fastr —
/credits(arg_required: false) — shows balance and history. - Empty cron (
jobs: [], on-demand); no migrations; no i18n (modal UI in English).
Stack and tools
- PHP 8 (no framework)
- MySQL 8 (
admin_configs+credits_history) - Tailwind CSS + Alpine.js (premium light, slate/indigo/violet)
- NEXUS plugin system (PluginManager: docs, modals, API actions, Fastr)
Operational tags
- Credits
- Créditos
- Billing
- Consumo de Recursos
- IA
- Core Plugin
- Plugin NEXUS
Operational result
- Central consumption control: credit state in a single JSON with full MySQL history.
- Automatic 90% alert: notification fired once per cycle (no spam) when usage crosses the configurable threshold.
- Two independent pools: bonus (
bonus_total/bonus_used) and plan (plan_total/plan_used) with progress bars in the modal. - AI compatibility:
ia_creditsandia_credits_legacyactions expose the balance to assistant consumption. - Admin control: reset the allocated limit and restart the cycle in 1 click (UPDATE POOL / TERMINATE CYCLE & RESET COUNTER).
- Quick access:
/creditschat command shows balance and history without opening the panel.
GitHub progress (issues)
Real-time panel with latest repository issues.
live feed
open issues on GitHubcarregando andamento...
não foi possivel carregar as issues agora. abra no github pelo link acima.
Real results
Credit management and AI resource billing control system. Monitors token usage across users, manages balances, sets operational quotas, and ensures predictable expenses with external LLM providers.
Architecture and organization
- PHP 8
- MySQL 8
- Tailwind CSS
- Alpine.js
- Plugin NEXUS
Execution and operations
The project follows reproducible execution flow with technical validation in production-like environments.
Screenshots
Talk about this project
Apply this implementation pattern in your environment and accelerate delivery with technical consistency.