Absolutely! Here’s a minimal, fast, and practical solution for your requirements using Go (Gin), SQLite, and a vanilla HTML/CSS frontend (with Shoelace for UI). The code is split into backend and frontend, with clear comments and a focus on performance and simplicity.
1. Backend: Go (Gin) + SQLite
Dependencies
go get github.com/gin-gonic/gin
go get gorm.io/gorm
go get gorm.io/driver/sqlite
main.go
package main
import (
"encoding/json"
"net/http"
"time"
"github.com/gin-gonic/gin"
"gorm.io/driver/sqlite"
"gorm.io/gorm"
)
type UserRequest struct {
ID uint `gorm:"primaryKey" json:"id"`
Data []byte `json:"data"` // Store as bytes
Served bool `json:"served"`
CreatedAt time.Time `json:"created_at"`
// Add more fields as needed
}
var db *gorm.DB
func main() {
var err error
db, err = gorm.Open(sqlite.Open("requests.db"), &gorm.Config{})
if err != nil {
panic("failed to connect database")
}
db.AutoMigrate(&UserRequest{})
r := gin.Default()
r.Static("/static", "./static")
// User submits a request
r.POST("/api/request", handleUserRequest)
// Admin views all requests
r.GET("/api/admin/requests", adminListRequests)
// Admin acts on a request (unlock)
r.POST("/api/admin/act/:id", adminActOnRequest)
// User acknowledges served data
r.POST("/api/request/ack/:id", userAcknowledge)
// Serve admin page
r.GET("/admin", func(c *gin.Context) {
c.File("./static/admin.html")
})
// Periodic cleanup (run in background)
go cleanupOldRequests()
r.Run(":8080")
}
func handleUserRequest(c *gin.Context) {
var req struct {
Data []byte `json:"data"`
}
if err := c.ShouldBindJSON(&req); err != nil {
c.JSON(http.StatusBadRequest, gin.H{"error": "invalid data"})
return
}
ur := UserRequest{Data: req.Data, Served: false, CreatedAt: time.Now()}
db.Create(&ur)
c.JSON(http.StatusOK, gin.H{"id": ur.ID})
}
func adminListRequests(c *gin.Context) {
var requests []UserRequest
db.Order("created_at desc").Limit(1000).Find(&requests)
c.JSON(http.StatusOK, requests)
}
func adminActOnRequest(c *gin.Context) {
id := c.Param("id")
var req UserRequest
if err := db.First(&req, id).Error; err != nil {
c.JSON(http.StatusNotFound, gin.H{"error": "not found"})
return
}
if req.Served {
c.JSON(http.StatusBadRequest, gin.H{"error": "already served"})
return
}
// Example: XOR the data with a config value (e.g., 0xAA)
key := byte(0xAA)
processed := make([]byte, len(req.Data))
for i, b := range req.Data {
processed[i] = b ^ key
}
// Mark as served
req.Served = true
db.Save(&req)
c.JSON(http.StatusOK, gin.H{
"id": req.ID,
"processed": processed,
})
}
func userAcknowledge(c *gin.Context) {
id := c.Param("id")
var req UserRequest
if err := db.First(&req, id).Error; err != nil {
c.JSON(http.StatusNotFound, gin.H{"error": "not found"})
return
}
// Optionally, delete or mark as acknowledged
db.Delete(&req)
c.JSON(http.StatusOK, gin.H{"status": "acknowledged"})
}
func cleanupOldRequests() {
for {
time.Sleep(1 * time.Hour)
cutoff := time.Now().Add(-24 * time.Hour)
db.Where("created_at < ?", cutoff).Delete(&UserRequest{})
}
}
2. Frontend: Minimal HTML + Shoelace
static/admin.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Admin Panel</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.15.0/cdn/themes/light.css">
<script type="module" src="https://cdn.jsdelivr.net/npm/@shoelace-style/shoelace@2.15.0/cdn/shoelace.js"></script>
<style>
body { font-family: sans-serif; margin: 2em; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 0.5em; border-bottom: 1px solid #ccc; }
tr:hover { background: #f0f0f0; cursor: pointer; }
#sidepanel { position: fixed; right: 0; top: 0; width: 350px; height: 100%; background: #fff; box-shadow: -2px 0 8px #ccc; display: none; flex-direction: column; padding: 1em; }
</style>
</head>
<body>
<h1>Admin Requests</h1>
<table id="requests">
<thead>
<tr>
<th>ID</th>
<th>Served</th>
<th>Created</th>
</tr>
</thead>
<tbody></tbody>
</table>
<div id="sidepanel">
<button onclick="closePanel()">Close</button>
<div id="panel-content"></div>
</div>
<script>
async function fetchRequests() {
const res = await fetch('/api/admin/requests');
const data = await res.json();
const tbody = document.querySelector('#requests tbody');
tbody.innerHTML = '';
data.forEach(req => {
const tr = document.createElement('tr');
tr.innerHTML = `<td>${req.id}</td><td>${req.served}</td><td>${new Date(req.created_at).toLocaleString()}</td>`;
tr.onclick = () => openPanel(req);
tbody.appendChild(tr);
});
}
async function openPanel(req) {
document.getElementById('sidepanel').style.display = 'flex';
let html = `<h2>Request #${req.id}</h2>
<p>Served: ${req.served}</p>
<p>Created: ${new Date(req.created_at).toLocaleString()}</p>
<p>Data: <code>${btoa(String.fromCharCode(...(req.data || [])))}</code></p>`;
if (!req.served) {
html += `<button onclick="actOnRequest(${req.id})">Unlock & Serve</button>`;
}
document.getElementById('panel-content').innerHTML = html;
}
function closePanel() {
document.getElementById('sidepanel').style.display = 'none';
}
async function actOnRequest(id) {
const res = await fetch(`/api/admin/act/${id}`, { method: 'POST' });
const data = await res.json();
if (data.processed) {
document.getElementById('panel-content').innerHTML += `<p>Processed Data: <code>${btoa(String.fromCharCode(...data.processed))}</code></p>`;
fetchRequests();
}
}
fetchRequests();
setInterval(fetchRequests, 5000);
</script>
</body>
</html>
3. Notes
- No frameworks: Only Shoelace for UI, no React/Vue/Angular.
- Minimal JS: Only for fetching and displaying data.
- Fast: No heavy dependencies, suitable for ARM64 boards.
- Security: Add authentication for
/admin in production!
- Data: User data is stored as bytes, processed with XOR as an example.
- Cleanup: Old requests are deleted every hour.
You can now run this on your ARM64 board, and access /admin for the admin panel.
Let me know if you need authentication, more complex unlock logic, or further optimizations!