# DollarSign Bot GUI – Flask/Jinja2 Edition (v4) Below are the **three key files** you can drop straight into your existing Flask project. They comply with your CSP, design‑system, and routing standards. --- ## 1. `app.py` – add the route ```python from flask import Blueprint, render_template, jsonify, request from flask_login import login_required, current_user from models import db, BotPreset, UserBotSlot # adjust imports to your structure bots_bp = Blueprint("bots", __name__, url_prefix="/bots") @bots_bp.route("/gui") @login_required def bot_gui(): # Pull preset bots from DB (or hard‑code for now) presets = BotPreset.query.order_by(BotPreset.risk.asc()).all() # User’s current slot assignments slots = UserBotSlot.query.filter_by(user_id=current_user.id).all() return render_template( "bot_gui.html", presets=presets, slots=slots, ) @bots_bp.route("/add-bot", methods=["POST"]) @login_required def add_bot(): bot_id = request.form.get("bot_id") # Simplified: put into first empty slot slot = UserBotSlot.add_to_first_empty(current_user.id, bot_id) db.session.commit() return jsonify({"success": True, "slot": slot.to_dict()}) ``` Add `bots_bp` to your main `create_app` factory: ```python app.register_blueprint(bots_bp) ``` --- ## 2. `templates/bot_gui.html` ```jinja {% extends 'base.html' %} {% block content %}

DollarSign Bot Commander

{% for bot in presets %}
{{ bot.name }}

{{ bot.description }}

{% endfor %}
Ari avatar
Chat with Ari

Active Bots

{% for slot in slots %}
{% if slot.bot %}
{{ slot.bot.name }}
Risk {{ slot.bot.risk }} {% else %} Empty Slot {% endif %}
{% endfor %}
{% endblock %} {% block scripts %} {{ super() }} {% endblock %} ``` **Design‑System Helper Classes (examples)** ```css /* In dollarsign-design-system.css */ .text-gold { color:#F3BA2F; } .btn-gold { background:#F3BA2F; color:#000; } .btn-gold:hover { background:#e0ac27; } .avatar-lg { width:96px; height:96px; object-fit:cover; } .border-dashed { border:2px dashed #6c757d !important; } ``` --- ## 3. `static/js/bot_gui.js` ```js /* global $, feather */ $(function () { feather.replace(); // Theme toggle (persists in localStorage) const $html = $(document.documentElement); const saved = localStorage.getItem("theme"); if (saved === "dark") $html.attr("data-bs-theme", "dark"); $("#themeToggle").on("click", function () { const isDark = $html.attr("data-bs-theme") === "dark"; $html.attr("data-bs-theme", isDark ? "light" : "dark"); localStorage.setItem("theme", isDark ? "light" : "dark"); }); // Risk slider live badge $("#riskRange").on("input", function () { $("#riskValue").text(this.value); }); // Add bot button $(".add-bot-btn").on("click", function () { const botId = $(this).data("bot-id"); $.post("/bots/add-bot", { bot_id: botId }).done(({ slot }) => { // Simple UI update: redraw empty card → filled const $card = $(`[data-slot-id='${slot.id}']`).removeClass("border-dashed"); $card.find(".card-body").html( `
${slot.bot_name}
Risk ${slot.bot_risk}` ); // Toast or flash feedback bootstrap.Toast.getOrCreateInstance( $("#toastAddedBot") ).show(); }); }); // Simple Ari bot stub const $chatLog = $("#chatLog"); $("#chatForm").on("submit", function (e) { e.preventDefault(); const txt = $(this).find("input[name='msg']").val().trim(); if (!txt) return; $chatLog.append(`
${txt}
`); this.reset(); // Fake response setTimeout(() => { $chatLog.append("
Interesting… I'll watch the charts! 📈
"); $chatLog.scrollTop($chatLog[0].scrollHeight); }, 600); }); }); ``` --- ### How to Plug‑In 1. **Models** – create `BotPreset` and `UserBotSlot` with SQLAlchemy (id, name, risk, description, etc.). 2. **Migrations** – `flask db migrate && flask db upgrade`. 3. **Blueprint** – register `bots_bp` inside `create_app`. 4. **Static + Template** – copy files into `static/js/` and `templates/` folders. 5. **Design System** – ensure `dollarsign-design-system.css` is already included in `base.html`. That’s it — fully CSP‑compliant, no inline JS, no React/JSX, and it uses your Bootstrap + golden theme classes.