To make this stand out for a senior-year portfolio, consider moving from a "functional tool" to a "production-grade system":
-
Security & Sandboxing (Highest Priority)✅ DONECurrently, the tool executes AI-generated code directly on the host machine. This is a major security risk.Implemented in
python_exec.rsviause_docker = trueinpymakebot.toml. Scripts run inside an isolatedpython-sandboxDocker container with:- No network access (
--network none) - Read-only script mount
- Non-root
sandboxuser - Dependency installation via
docker commit - Timeout support and graceful fallback to host execution
Build the image:
docker build -t python-sandbox . - No network access (
-
Virtual Environment Isolation (host & Docker)✅ DONEThe project currently uses the system pip to install dependencies.Implemented in
python_exec.rsviause_venv = true(default) inpymakebot.toml. Each script execution runs inside a temporary Python virtual environment:- Host mode: creates a temp venv in the OS temp directory, installs deps into it, runs the script with the venv's Python, then cleans up automatically.
- Docker mode: creates a venv inside the ephemeral container at execution time (via
bash -centrypoint), installs deps and runs the script — all in a singledocker run --rm. No image mutation (docker commit) needed. - Configurable: set
use_venv = falseinpymakebot.tomlto revert to system-wide pip behavior.
-
Versatile Model Support (Cloud + Local LLMs)✅ DONEYou currently rely on the HuggingFace API.Implemented in
api.rsvia aProviderenum (HuggingFace,Ollama,OpenAiCompatible). Configured withproviderfield inpymakebot.toml:- HuggingFace (default): cloud API, requires
HF_TOKENin.env. - Ollama: local inference at
http://localhost:11434/v1/chat/completions, no API key required (optionalLLM_API_KEYfor proxy setups). - OpenAI-compatible: any endpoint following the OpenAI chat completions spec, with optional
LLM_API_KEYauth. - Auto URL resolution: when switching provider with the default HF URL still set, the provider's default URL is used automatically.
- New
/providerREPL command shows active provider, model, and resolved API URL. - All providers use OpenAI-compatible chat completions format with
stream: false.
- HuggingFace (default): cloud API, requires
-
Static Analysis (Linting)✅ DONEYou currently use py_compile to check syntax.Implemented in
python_exec.rsviaruff checkintegration. Configured withuse_linting = true(default) inpymakebot.toml:- Runs
ruff check --output-format=concise --no-fixafter syntax check passes. - Classifies diagnostics as errors (E/F rules) or warnings (W/C/etc. rules).
- On lint errors: offers auto-refine via LLM to fix the issues.
- On warnings only: displays them but proceeds to execution.
- New
/lintREPL command to lint code on demand. - Graceful degradation: if
ruffis not installed, linting is skipped with a helpful install message. - Configurable: set
use_linting = falseto disable.
- Runs
-
Static Security Analysis (The "Pre-Flight" Check)✅ DONEBefore the code ever reaches the Docker container, you should "inspect" it.Implemented in
python_exec.rsviabanditintegration. Configured withuse_security_check = true(default) inpymakebot.toml:- Runs
bandit -f json -qafter syntax and lint checks pass, before execution. - Parses JSON output into structured diagnostics with severity (LOW/MEDIUM/HIGH) and confidence.
- On HIGH severity findings: prompts the user before proceeding with execution.
- On MEDIUM/LOW findings: displays them but does not block execution.
- New
/securityREPL command to scan code on demand. - Graceful degradation: if
banditis not installed, security scanning is skipped with a helpful install message. - Configurable: set
use_security_check = falseto disable.
- Runs
-
Real-Time Web Dashboard (Axum + HTML/HTMX)✅ DONECLI tools are powerful but not user-friendly. A visual dashboard unlocks non-technical users and recruiters.Implemented in
src/dashboard/module viaenable_dashboard = trueinpymakebot.toml. Provides a local web interface athttp://localhost:3000(configurable port) running alongside the CLI REPL:- Backend: Axum web framework serving REST API endpoints and HTML pages:
GET /— main dashboard page with script history, prompt input, code viewer, and real-time logsGET /api/history— JSON list of generated scripts with timestampsPOST /api/generate— accept a prompt, call the LLM, return generated codeGET /api/stats— session metrics (requests, successes, failures, success rate)GET /api/containers— active Docker sandbox containersWS /api/logs— WebSocket endpoint for real-time execution log streaming
- Frontend: HTML/HTMX interface with Tailwind CSS dark theme:
- Left sidebar: clickable script history (auto-refreshed via HTMX)
- Center: prompt form with code generation, syntax-highlighted code viewer (highlight.js)
- Bottom: real-time execution log panel (WebSocket-driven)
- Right sidebar: session stats and Docker container status (HTMX-polled)
- Concurrency:
tokio::sync::broadcastchannels stream execution events to WebSocket clients - Shared State:
Arc<DashboardState>withRwLockfor metrics, conversation history, and generated code — shared between REPL and dashboard - Configuration:
enable_dashboard = trueanddashboard_port = 3000inpymakebot.toml - New
/dashboardREPL command shows the dashboard URL
- Backend: Axum web framework serving REST API endpoints and HTML pages:
-
"Chat with Data" (Local RAG)✅ DONECurrently, the bot generates code based only on LLM training data.Implemented in
src/rag.rswith the/context <file_path>REPL command. Supports TXT, MD, and CSV files:- Text chunking with configurable chunk size and 10% overlap
- Embedding generation via provider-specific APIs (HuggingFace, Ollama, OpenAI-compatible)
- In-memory vector store with cosine similarity retrieval
- Automatic RAG injection into prompts when
enable_rag = true - Configurable:
enable_rag,rag_embedding_model,rag_chunk_sizeinpymakebot.toml
-
Multi-File Project Generation (Scaffolding) Today, the bot returns single scripts. Professional engineering requires generating complete project structures.
Feature: Instead of a single code block, the bot generates a folder structure with main files, dependencies, README, and utils. Output is written to a
generated/<project_name>/directory.Why it impresses recruiters: It transforms the tool from a "code snippet generator" to a "productivity accelerator." Parsing and structuring complex LLM outputs (JSON/XML) demonstrates engineering maturity.
Implementation Plan:
- Prompt Engineering: Update the LLM system prompt to request JSON output following this schema:
{ "project_name": "string", "description": "string", "files": [ {"path": "main.py", "content": "..."}, {"path": "requirements.txt", "content": "..."}, {"path": "README.md", "content": "..."}, {"path": "src/utils.py", "content": "..."} ] } - Parsing: Deserialize the JSON response into a Rust struct
ProjectBlueprintusingserde_json. - File I/O: Iterate through
filesand write each togenerated/<project_name>/<path>usingstd::fs::write. - Directory Creation: Create parent directories as needed using
std::fs::create_dir_all. - Auto-Setup: After generation, optionally auto-install dependencies:
- For Python: run
pip install -r requirements.txtin the generated directory (or in a venv). - Configurable: Add
auto_install_deps = trueoption inpymakebot.toml.
- For Python: run
- User Feedback: Display the generated file tree and provide commands to open the folder or run the project.
- Prompt Engineering: Update the LLM system prompt to request JSON output following this schema:
-
GitHub Actions CI/CD Pipeline✅ DONE Automated quality gates on every push and pull request:cargo fmt --check— formatting verificationcargo clippy -- -D warnings— zero-warning lint policycargo test— full test suite execution- Uses Rust stable on ubuntu-latest with dependency caching
-
Code Explanation Mode✅ DONE The bot can now explain generated code step-by-step via/explainREPL command and dashboard endpoint:- Dedicated explanation system prompt for educational breakdowns
- Explains: overview, step-by-step walkthrough, key concepts, potential improvements
- Dashboard "Explain" button for one-click explanations
-
Conversation Persistence✅ DONE Sessions can be saved and loaded across restarts:/session save <name>— serialize conversation history to JSON/session load <name>— restore a previous session/session list— browse saved sessions- Dashboard endpoints for session persistence
-
Streaming LLM Responses✅ DONE Real-time token-by-token code generation:- REPL: characters appear as the model generates them
- Dashboard: Server-Sent Events (SSE) for live streaming
- Configurable via
use_streaming = trueinpymakebot.toml - Graceful fallback to non-streaming on error
-
Multi-File Project Generation✅ DONE Generate entire project structures, not just single scripts:/project <prompt>scaffolds a complete project directory- LLM outputs structured JSON with file paths and contents
- Writes to
generated/<project_name>/with proper directory structure - Dashboard endpoint for project generation
Optimization Tip: Creating a fresh venv inside the ephemeral container for every execution is secure but computationally expensive (slow).
Suggestion: For your portfolio demo, consider pre-baking common data science libraries (pandas, numpy, scikit-learn) into your Dockerfile so the bot doesn't have to install them every single time.
Optimization Tip: Ensure your prompt templates in api.rs are generic enough. Some local models (like Mistral) adhere strictly to specific chat templates ([INST]...[/INST]), whereas OpenAI is more flexible.