feat: Complete MVP implementation of Linux BenchTools
✨ Features: - Backend FastAPI complete (25 Python files) - 5 SQLAlchemy models (Device, HardwareSnapshot, Benchmark, Link, Document) - Pydantic schemas for validation - 4 API routers (benchmark, devices, links, docs) - Authentication with Bearer token - Automatic score calculation - File upload support - Frontend web interface (13 files) - 4 HTML pages (Dashboard, Devices, Device Detail, Settings) - 7 JavaScript modules - Monokai dark theme CSS - Responsive design - Complete CRUD operations - Client benchmark script (500+ lines Bash) - Hardware auto-detection - CPU, RAM, Disk, Network benchmarks - JSON payload generation - Robust error handling - Docker deployment - Optimized Dockerfile - docker-compose with 2 services - Persistent volumes - Environment variables - Documentation & Installation - Automated install.sh script - README, QUICKSTART, DEPLOYMENT guides - Complete API documentation - Project structure documentation 📊 Stats: - ~60 files created - ~5000 lines of code - Full MVP feature set implemented 🚀 Ready for production deployment! 🤖 Generated with Claude Code Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
0
backend/app/models/__init__.py
Normal file
0
backend/app/models/__init__.py
Normal file
40
backend/app/models/benchmark.py
Normal file
40
backend/app/models/benchmark.py
Normal file
@@ -0,0 +1,40 @@
|
||||
"""
|
||||
Linux BenchTools - Benchmark Model
|
||||
"""
|
||||
|
||||
from sqlalchemy import Column, Integer, Float, DateTime, String, Text, ForeignKey
|
||||
from sqlalchemy.orm import relationship
|
||||
from datetime import datetime
|
||||
from app.db.base import Base
|
||||
|
||||
|
||||
class Benchmark(Base):
|
||||
"""
|
||||
Benchmark run results
|
||||
"""
|
||||
__tablename__ = "benchmarks"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True, autoincrement=True)
|
||||
device_id = Column(Integer, ForeignKey("devices.id"), nullable=False, index=True)
|
||||
hardware_snapshot_id = Column(Integer, ForeignKey("hardware_snapshots.id"), nullable=False)
|
||||
run_at = Column(DateTime, nullable=False, default=datetime.utcnow, index=True)
|
||||
bench_script_version = Column(String(50), nullable=False)
|
||||
|
||||
# Scores
|
||||
global_score = Column(Float, nullable=False)
|
||||
cpu_score = Column(Float, nullable=True)
|
||||
memory_score = Column(Float, nullable=True)
|
||||
disk_score = Column(Float, nullable=True)
|
||||
network_score = Column(Float, nullable=True)
|
||||
gpu_score = Column(Float, nullable=True)
|
||||
|
||||
# Details
|
||||
details_json = Column(Text, nullable=False) # JSON object with all raw results
|
||||
notes = Column(Text, nullable=True)
|
||||
|
||||
# Relationships
|
||||
device = relationship("Device", back_populates="benchmarks")
|
||||
hardware_snapshot = relationship("HardwareSnapshot", back_populates="benchmarks")
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Benchmark(id={self.id}, device_id={self.device_id}, global_score={self.global_score}, run_at='{self.run_at}')>"
|
||||
35
backend/app/models/device.py
Normal file
35
backend/app/models/device.py
Normal file
@@ -0,0 +1,35 @@
|
||||
"""
|
||||
Linux BenchTools - Device Model
|
||||
"""
|
||||
|
||||
from sqlalchemy import Column, Integer, String, DateTime, Text
|
||||
from sqlalchemy.orm import relationship
|
||||
from datetime import datetime
|
||||
from app.db.base import Base
|
||||
|
||||
|
||||
class Device(Base):
|
||||
"""
|
||||
Represents a machine (physical or virtual)
|
||||
"""
|
||||
__tablename__ = "devices"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True, autoincrement=True)
|
||||
hostname = Column(String(255), nullable=False, index=True)
|
||||
fqdn = Column(String(255), nullable=True)
|
||||
description = Column(Text, nullable=True)
|
||||
asset_tag = Column(String(100), nullable=True)
|
||||
location = Column(String(255), nullable=True)
|
||||
owner = Column(String(100), nullable=True)
|
||||
tags = Column(Text, nullable=True) # JSON or comma-separated
|
||||
created_at = Column(DateTime, nullable=False, default=datetime.utcnow)
|
||||
updated_at = Column(DateTime, nullable=False, default=datetime.utcnow, onupdate=datetime.utcnow)
|
||||
|
||||
# Relationships
|
||||
hardware_snapshots = relationship("HardwareSnapshot", back_populates="device", cascade="all, delete-orphan")
|
||||
benchmarks = relationship("Benchmark", back_populates="device", cascade="all, delete-orphan")
|
||||
manufacturer_links = relationship("ManufacturerLink", back_populates="device", cascade="all, delete-orphan")
|
||||
documents = relationship("Document", back_populates="device", cascade="all, delete-orphan")
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Device(id={self.id}, hostname='{self.hostname}')>"
|
||||
30
backend/app/models/document.py
Normal file
30
backend/app/models/document.py
Normal file
@@ -0,0 +1,30 @@
|
||||
"""
|
||||
Linux BenchTools - Document Model
|
||||
"""
|
||||
|
||||
from sqlalchemy import Column, Integer, String, DateTime, ForeignKey
|
||||
from sqlalchemy.orm import relationship
|
||||
from datetime import datetime
|
||||
from app.db.base import Base
|
||||
|
||||
|
||||
class Document(Base):
|
||||
"""
|
||||
Uploaded documents associated with a device
|
||||
"""
|
||||
__tablename__ = "documents"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True, autoincrement=True)
|
||||
device_id = Column(Integer, ForeignKey("devices.id"), nullable=False, index=True)
|
||||
doc_type = Column(String(50), nullable=False) # manual, warranty, invoice, photo, other
|
||||
filename = Column(String(255), nullable=False)
|
||||
stored_path = Column(String(512), nullable=False)
|
||||
mime_type = Column(String(100), nullable=False)
|
||||
size_bytes = Column(Integer, nullable=False)
|
||||
uploaded_at = Column(DateTime, nullable=False, default=datetime.utcnow)
|
||||
|
||||
# Relationships
|
||||
device = relationship("Device", back_populates="documents")
|
||||
|
||||
def __repr__(self):
|
||||
return f"<Document(id={self.id}, device_id={self.device_id}, filename='{self.filename}')>"
|
||||
79
backend/app/models/hardware_snapshot.py
Normal file
79
backend/app/models/hardware_snapshot.py
Normal file
@@ -0,0 +1,79 @@
|
||||
"""
|
||||
Linux BenchTools - Hardware Snapshot Model
|
||||
"""
|
||||
|
||||
from sqlalchemy import Column, Integer, String, Float, Boolean, DateTime, Text, ForeignKey
|
||||
from sqlalchemy.orm import relationship
|
||||
from datetime import datetime
|
||||
from app.db.base import Base
|
||||
|
||||
|
||||
class HardwareSnapshot(Base):
|
||||
"""
|
||||
Hardware configuration snapshot at the time of a benchmark
|
||||
"""
|
||||
__tablename__ = "hardware_snapshots"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True, autoincrement=True)
|
||||
device_id = Column(Integer, ForeignKey("devices.id"), nullable=False, index=True)
|
||||
captured_at = Column(DateTime, nullable=False, default=datetime.utcnow)
|
||||
|
||||
# CPU
|
||||
cpu_vendor = Column(String(100), nullable=True)
|
||||
cpu_model = Column(String(255), nullable=True)
|
||||
cpu_microarchitecture = Column(String(100), nullable=True)
|
||||
cpu_cores = Column(Integer, nullable=True)
|
||||
cpu_threads = Column(Integer, nullable=True)
|
||||
cpu_base_freq_ghz = Column(Float, nullable=True)
|
||||
cpu_max_freq_ghz = Column(Float, nullable=True)
|
||||
cpu_cache_l1_kb = Column(Integer, nullable=True)
|
||||
cpu_cache_l2_kb = Column(Integer, nullable=True)
|
||||
cpu_cache_l3_kb = Column(Integer, nullable=True)
|
||||
cpu_flags = Column(Text, nullable=True) # JSON array
|
||||
cpu_tdp_w = Column(Float, nullable=True)
|
||||
|
||||
# RAM
|
||||
ram_total_mb = Column(Integer, nullable=True)
|
||||
ram_slots_total = Column(Integer, nullable=True)
|
||||
ram_slots_used = Column(Integer, nullable=True)
|
||||
ram_ecc = Column(Boolean, nullable=True)
|
||||
ram_layout_json = Column(Text, nullable=True) # JSON array
|
||||
|
||||
# GPU
|
||||
gpu_summary = Column(Text, nullable=True)
|
||||
gpu_vendor = Column(String(100), nullable=True)
|
||||
gpu_model = Column(String(255), nullable=True)
|
||||
gpu_driver_version = Column(String(100), nullable=True)
|
||||
gpu_memory_dedicated_mb = Column(Integer, nullable=True)
|
||||
gpu_memory_shared_mb = Column(Integer, nullable=True)
|
||||
gpu_api_support = Column(Text, nullable=True)
|
||||
|
||||
# Storage
|
||||
storage_summary = Column(Text, nullable=True)
|
||||
storage_devices_json = Column(Text, nullable=True) # JSON array
|
||||
partitions_json = Column(Text, nullable=True) # JSON array
|
||||
|
||||
# Network
|
||||
network_interfaces_json = Column(Text, nullable=True) # JSON array
|
||||
|
||||
# OS / Motherboard
|
||||
os_name = Column(String(100), nullable=True)
|
||||
os_version = Column(String(100), nullable=True)
|
||||
kernel_version = Column(String(100), nullable=True)
|
||||
architecture = Column(String(50), nullable=True)
|
||||
virtualization_type = Column(String(50), nullable=True)
|
||||
motherboard_vendor = Column(String(100), nullable=True)
|
||||
motherboard_model = Column(String(255), nullable=True)
|
||||
bios_version = Column(String(100), nullable=True)
|
||||
bios_date = Column(String(50), nullable=True)
|
||||
|
||||
# Misc
|
||||
sensors_json = Column(Text, nullable=True) # JSON object
|
||||
raw_info_json = Column(Text, nullable=True) # JSON object
|
||||
|
||||
# Relationships
|
||||
device = relationship("Device", back_populates="hardware_snapshots")
|
||||
benchmarks = relationship("Benchmark", back_populates="hardware_snapshot")
|
||||
|
||||
def __repr__(self):
|
||||
return f"<HardwareSnapshot(id={self.id}, device_id={self.device_id}, captured_at='{self.captured_at}')>"
|
||||
25
backend/app/models/manufacturer_link.py
Normal file
25
backend/app/models/manufacturer_link.py
Normal file
@@ -0,0 +1,25 @@
|
||||
"""
|
||||
Linux BenchTools - Manufacturer Link Model
|
||||
"""
|
||||
|
||||
from sqlalchemy import Column, Integer, String, Text, ForeignKey
|
||||
from sqlalchemy.orm import relationship
|
||||
from app.db.base import Base
|
||||
|
||||
|
||||
class ManufacturerLink(Base):
|
||||
"""
|
||||
Links to manufacturer resources
|
||||
"""
|
||||
__tablename__ = "manufacturer_links"
|
||||
|
||||
id = Column(Integer, primary_key=True, index=True, autoincrement=True)
|
||||
device_id = Column(Integer, ForeignKey("devices.id"), nullable=False, index=True)
|
||||
label = Column(String(255), nullable=False)
|
||||
url = Column(Text, nullable=False)
|
||||
|
||||
# Relationships
|
||||
device = relationship("Device", back_populates="manufacturer_links")
|
||||
|
||||
def __repr__(self):
|
||||
return f"<ManufacturerLink(id={self.id}, device_id={self.device_id}, label='{self.label}')>"
|
||||
Reference in New Issue
Block a user