How lucasjoel1/openmc-panel works
Project Type and Purpose
• This is a full-stack server-management application.
– Backend in Go (HTTP server, WebSocket, Discord bot).
– Frontend in React+TypeScript (Vite, Tailwind CSS, Radix UI).
– Integrates with a local Minecraft server process.
– Enables control via web UI and Discord commands.
File Structure
• Top-level “src” folder is the Go backend.
– src/main.go boots: starts HTTP server + Discord bot.
– src/globals/ holds state managers (player, serverProperties, buffer, state).
– src/listeners/bot/ implements Discord event handling.
– src/listeners/share/ deals with WebSocket connections for real-time data and logs.
– src/server/ contains code to start/stop/restart the Minecraft process.
– src/web/ defines HTTP API handlers (/api/...) and static‐file serving.
• “frontend/” folder is the web client: React components, hooks, UI primitives under src/components/*, Vite config, static public/, built assets snapshot under src/web/frontend/assets/.
• Root config: .env.example, server.json, Go modules.
README Insights
• Main features: start/stop/restart server, real-time monitoring via WebSocket, console access, server properties editor, memory controls, Discord chat bridge, notifications.
• Tech stack callouts: Discord API via discordgo, gopsutil, WebSocket for real-time, React + TanStack Query.
• API endpoints: REST (/api/startServer, /api/stopServer, etc.) and WebSocket at /api/ws/serverInfo.
• Lifecycle: go run src/main.go → HTTP+WebSocket+Discord gateway; frontend built & served from Go binary.
Main Components and Their Relationships
a. External Actors:
• Web user (browser)
• Discord user (Discord client)
b. Presentation Layer:
• React Frontend (served as static files)
• Uses REST (HTTP) for administrative actions
• Opens WebSocket for real-time server status & logs
c. Application Layer (Go backend):
• HTTP Server (net/http)
• WebSocket Hub (listeners/share/connectionHandler.go)
• Discord Bot (listeners/bot/messageListener.go)
• API Handlers (src/web/api/*.go)
• Global State Managers (in-memory)
d. Domain / Service Layer:
• Server Management Service (src/server/startServer.go + stop/restart routines)
• Player Manager, Server Properties Manager
• System Monitor (gopsutil) for CPU/RAM metrics
e. Persistence / Infrastructure:
• Minecraft Server Process (JVM)
• Local filesystem (server/ directory with JAR, worlds, properties)
f. External Service:
• Discord Gateway API
Architectural Patterns & Design Principles
• Layered architecture: Presentation → Application → Domain → Infrastructure
• Event-driven for Discord and WebSocket listeners
• Single process monolith grouping all concerns but logically separated in packages
• Real-time pub/sub pattern for logs & status updates via WebSocket hub
• Clear, human-readable labels for each component.
• Callouts for critical technologies: Go 1.24.1, React+Vite, WebSocket, discordgo, gopsutil, Tailwind CSS.