How tejas-2232/gemchat-rs works
Project type and purpose
• This is a Rust-based, standalone microservice (using Axum async framework) that exposes a REST API and an embeddable JS widget.
• Its purpose is to serve as a cybersecurity-focused chatbot powered by Google Gemini AI. It can either be called directly via HTTP POST (/api/chat) or loaded in any web page as a drop-in widget (widget.js).
File structure
• Top-level files:
• Cargo.toml – Rust dependencies and metadata
• Dockerfile/docker-compose.yml – containerization and multi-container orchestration
• env.example/.env – environment variable template (GEMINI_API_KEY, PORT, RUST_LOG)
• README.md/troubleshooting.md – docs
• src/ directory:
• main.rs – HTTP server setup, route definitions (/health, /api/chat, /widget.js, static/*)
• gemini.rs – logic for calling Google Gemini API and building the system prompt
• models.rs – request/response structs for serialization (serde)
• static/:
• widget.js – client-side script that bootstraps the widget, fetches /api/chat, injects HTML/CSS into host page
• widget-test.html – example of widget integration
• No database directory/files: state is ephemeral per request, logs shipped via tracing.
README for additional insights
• “Two Integration Methods” (REST vs widget) implies two client-facing entry points.
• Highlights CORS-enabled, structured logging (tracing), Docker-ready.
• Mentions environment-driven config, reverse-proxy recommendation (nginx/Traefik), scaling behind LB.