Skip to content

Commit 40abd41

Browse files
authored
feat: add web server and ui (#2)
* feat: add web server and ui * chore: rename miners-scheduler to ems * feat: display plant running info
1 parent 8031ab0 commit 40abd41

44 files changed

Lines changed: 4961 additions & 497 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.dockerignore‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Git
2+
.git
3+
.gitignore
4+
.github
5+
6+
# Documentation
7+
*.md
8+
CONTRIBUTING.md
9+
LICENSE
10+
11+
# Development files
12+
.vscode
13+
.idea
14+
*.swp
15+
*.swo
16+
*~
17+
18+
# Go
19+
*.exe
20+
*.exe~
21+
*.dll
22+
*.so
23+
*.dylib
24+
*.test
25+
*.out
26+
vendor/
27+
28+
# Web development
29+
web/node_modules
30+
web/dist
31+
web/.vite
32+
web/.cache
33+
34+
# Logs
35+
*.log
36+
logs/
37+
38+
# Test data
39+
test_data/
40+
41+
# Configuration (keep config.json as it's needed)
42+
config.example.json
43+
44+
# OS files
45+
.DS_Store
46+
Thumbs.db
47+
48+
# Temporary files
49+
tmp/
50+
temp/
51+
*.tmp
52+
53+
# Build artifacts
54+
build/
55+
dist/
56+
57+
# Dependencies that will be downloaded during build
58+
go.sum.backup

‎.github/SETUP_COVERAGE_BADGE.md‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ For **private repositories**:
3030
If your repository is private:
3131

3232
1. **Get Your Codecov Token**
33-
- Navigate to https://codecov.io/gh/devskill-org/miners-scheduler
33+
- Navigate to https://codecov.io/gh/devskill-org/energy-management-system
3434
- Click on "Settings" in the left sidebar
3535
- Copy the "Repository Upload Token"
3636

@@ -46,21 +46,21 @@ If your repository is private:
4646

4747
1. **Commit and push** your changes (if you haven't already)
4848
2. **Wait for workflow** to complete (check the Actions tab)
49-
3. **Visit Codecov** dashboard at https://codecov.io/gh/devskill-org/miners-scheduler
49+
3. **Visit Codecov** dashboard at https://codecov.io/gh/devskill-org/energy-management-system
5050
4. **Check your README** - the badge should now display the coverage percentage
5151

5252
## Badge Configuration
5353

5454
The coverage badge is already configured in your README.md:
5555

5656
```markdown
57-
[![Coverage](https://codecov.io/gh/devskill-org/miners-scheduler/branch/main/graph/badge.svg)](https://codecov.io/gh/devskill-org/miners-scheduler)
57+
[![Coverage](https://codecov.io/gh/devskill-org/energy-management-system/branch/main/graph/badge.svg)](https://codecov.io/gh/devskill-org/energy-management-system)
5858
```
5959

6060
If you use a different default branch (e.g., `master`), update the badge URL:
6161

6262
```markdown
63-
[![Coverage](https://codecov.io/gh/devskill-org/miners-scheduler/branch/master/graph/badge.svg)](https://codecov.io/gh/devskill-org/miners-scheduler)
63+
[![Coverage](https://codecov.io/gh/devskill-org/energy-management-system/branch/master/graph/badge.svg)](https://codecov.io/gh/devskill-org/energy-management-system)
6464
```
6565

6666
## Codecov Features
@@ -95,17 +95,17 @@ You can customize your badge appearance:
9595

9696
### Default Badge
9797
```markdown
98-
[![Coverage](https://codecov.io/gh/devskill-org/miners-scheduler/branch/main/graph/badge.svg)](https://codecov.io/gh/devskill-org/miners-scheduler)
98+
[![Coverage](https://codecov.io/gh/devskill-org/energy-management-system/branch/main/graph/badge.svg)](https://codecov.io/gh/devskill-org/energy-management-system)
9999
```
100100

101101
### Flat Style Badge
102102
```markdown
103-
[![Coverage](https://codecov.io/gh/devskill-org/miners-scheduler/branch/main/graph/badge.svg?style=flat)](https://codecov.io/gh/devskill-org/miners-scheduler)
103+
[![Coverage](https://codecov.io/gh/devskill-org/energy-management-system/branch/main/graph/badge.svg?style=flat)](https://codecov.io/gh/devskill-org/energy-management-system)
104104
```
105105

106106
### Flat-Square Style Badge
107107
```markdown
108-
[![Coverage](https://codecov.io/gh/devskill-org/miners-scheduler/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/devskill-org/miners-scheduler)
108+
[![Coverage](https://codecov.io/gh/devskill-org/energy-management-system/branch/main/graph/badge.svg?style=flat-square)](https://codecov.io/gh/devskill-org/energy-management-system)
109109
```
110110

111111
## Troubleshooting

‎.github/workflows/README.md‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,27 +55,27 @@ To get coverage badges and detailed reports at [Codecov](https://codecov.io):
5555
- Value: Your Codecov token
5656

5757
4. **View Coverage Reports**
58-
- After the first workflow run, visit https://codecov.io/gh/devskill-org/miners-scheduler
58+
- After the first workflow run, visit https://codecov.io/gh/devskill-org/energy-management-system
5959
- View detailed coverage reports, trends, and file-by-file analysis
6060
- The badge in README.md will automatically update
6161

6262
**Badge:**
6363
```markdown
64-
[![Coverage](https://codecov.io/gh/devskill-org/miners-scheduler/branch/main/graph/badge.svg)](https://codecov.io/gh/devskill-org/miners-scheduler)
64+
[![Coverage](https://codecov.io/gh/devskill-org/energy-management-system/branch/main/graph/badge.svg)](https://codecov.io/gh/devskill-org/energy-management-system)
6565
```
6666

6767
### Alternative: Simple Test Status Badge
6868

6969
If you don't want to use Codecov, you can use just the test status badge:
7070

7171
```markdown
72-
[![Tests](https://github.com/devskill-org/miners-scheduler/actions/workflows/test.yml/badge.svg)](https://github.com/devskill-org/miners-scheduler/actions/workflows/test.yml)
72+
[![Tests](https://github.com/devskill-org/energy-management-system/actions/workflows/test.yml/badge.svg)](https://github.com/devskill-org/energy-management-system/actions/workflows/test.yml)
7373
```
7474

7575
## Viewing Coverage Reports
7676

7777
### In Codecov
78-
1. Visit https://codecov.io/gh/devskill-org/miners-scheduler
78+
1. Visit https://codecov.io/gh/devskill-org/energy-management-system
7979
2. View coverage percentage, trends, and file-by-file breakdown
8080
3. See coverage changes in pull requests
8181

@@ -110,9 +110,9 @@ Then open `coverage.html` in your browser.
110110
Add these badges to your README.md:
111111

112112
```markdown
113-
[![Tests](https://github.com/devskill-org/miners-scheduler/actions/workflows/test.yml/badge.svg)](https://github.com/devskill-org/miners-scheduler/actions/workflows/test.yml)
114-
[![Coverage](https://codecov.io/gh/devskill-org/miners-scheduler/branch/main/graph/badge.svg)](https://codecov.io/gh/devskill-org/miners-scheduler)
115-
[![Go Report Card](https://goreportcard.com/badge/github.com/devskill-org/miners-scheduler)](https://goreportcard.com/report/github.com/devskill-org/miners-scheduler)
113+
[![Tests](https://github.com/devskill-org/energy-management-system/actions/workflows/test.yml/badge.svg)](https://github.com/devskill-org/energy-management-system/actions/workflows/test.yml)
114+
[![Coverage](https://codecov.io/gh/devskill-org/energy-management-system/branch/main/graph/badge.svg)](https://codecov.io/gh/devskill-org/energy-management-system)
115+
[![Go Report Card](https://goreportcard.com/badge/github.com/devskill-org/energy-management-system)](https://goreportcard.com/report/github.com/devskill-org/energy-management-system)
116116
```
117117

118118
## Troubleshooting

‎.github/workflows/test.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,11 @@ jobs:
9696

9797
- name: Build
9898
run: |
99-
CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -o bin/miners-scheduler .
99+
CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -o bin/ems .
100100
101101
- name: Upload binary artifact
102102
uses: actions/upload-artifact@v4
103103
with:
104-
name: miners-scheduler-linux-amd64
105-
path: bin/miners-scheduler
104+
name: ems-linux-amd64
105+
path: bin/ems
106106
retention-days: 7

‎.gitignore‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
test-binary
2-
miners-scheduler
2+
ems
33
config.json
4-
miners-scheduler.tar
5-
miners-scheduler-working.tar
4+
ems.tar
5+
ems-working.tar

‎CONTRIBUTING.md‎

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
# Contributing to Miners Scheduler
1+
# Contributing to Energy Management System
22

3-
Thank you for your interest in contributing to Miners Scheduler! This document provides guidelines and instructions for contributing to the project.
3+
Thank you for your interest in contributing to the Energy Management System! This document provides guidelines and instructions for contributing to the project.
44

55
## Table of Contents
66

@@ -18,12 +18,12 @@ Thank you for your interest in contributing to Miners Scheduler! This document p
1818
1. Fork the repository
1919
2. Clone your fork:
2020
```bash
21-
git clone https://github.com/YOUR_USERNAME/miners-scheduler.git
22-
cd miners-scheduler
21+
git clone https://github.com/YOUR_USERNAME/energy-management-system.git
22+
cd energy-management-system
2323
```
2424
3. Add the upstream repository:
2525
```bash
26-
git remote add upstream https://github.com/devskill-org/miners-scheduler.git
26+
git remote add upstream https://github.com/devskill-org/energy-management-system.git
2727
```
2828

2929
## Development Setup
@@ -276,15 +276,16 @@ make test-coverage
276276
### Code Organization
277277

278278
```
279-
miners-scheduler/
280-
├── entsoe/ # ENTSO-E API client
281-
├── meteo/ # Weather/meteorological data
282-
├── miners/ # Miner control logic
283-
├── mpc/ # Model Predictive Control
284-
├── scheduler/ # Main scheduler logic
285-
├── sigenergy/ # Energy signature analysis
286-
├── sun/ # Solar calculations
279+
energy-management-system/
280+
├── entsoe/ # ENTSO-E API client for electricity pricing
281+
├── meteo/ # Weather/meteorological data integration
282+
├── miners/ # Controllable load management (miners, etc.)
283+
├── mpc/ # Model Predictive Control for optimization
284+
├── scheduler/ # Main scheduling and control logic
285+
├── sigenergy/ # SigEnergy PV/battery system integration
286+
├── sun/ # Solar position calculations
287287
├── utils/ # Utility functions
288+
├── web/ # Web dashboard and API
288289
└── test_data/ # Test fixtures
289290
```
290291

@@ -298,7 +299,7 @@ miners-scheduler/
298299

299300
Example:
300301
```go
301-
func TestScheduler_Run_WithHighPrice_StopsMiners(t *testing.T) {
302+
func TestScheduler_Run_WithHighPrice_ReducesLoads(t *testing.T) {
302303
// Arrange
303304
scheduler := NewScheduler(...)
304305

@@ -336,7 +337,7 @@ Types:
336337

337338
Example:
338339
```
339-
feat(scheduler): add thermal protection for miners
340+
feat(scheduler): add thermal protection for controllable loads
340341
341342
Implements automatic mode switching when fan speeds exceed 70%
342343
to prevent overheating. Recovers to standard mode when temps normalize.

‎Dockerfile‎

Lines changed: 38 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
1-
# Multi-stage build for Go application
2-
FROM golang:1.25.1-alpine AS builder
1+
# Multi-stage build for Go application with React web UI
2+
3+
# Stage 1: Build web application
4+
FROM node:18-alpine AS web-builder
5+
6+
# Set working directory for web build
7+
WORKDIR /web
8+
9+
# Copy web application files
10+
COPY web/package*.json ./
11+
12+
# Install dependencies
13+
RUN npm ci --only=production=false
14+
15+
# Copy web source code
16+
COPY web/ ./
17+
18+
# Build the web application
19+
RUN npm run build
20+
21+
# Stage 2: Build Go application
22+
FROM golang:1.25.1-alpine AS go-builder
323

424
# Install build dependencies
525
RUN apk add --no-cache git ca-certificates tzdata
@@ -8,18 +28,21 @@ RUN apk add --no-cache git ca-certificates tzdata
828
WORKDIR /app
929

1030
# Copy go mod files
11-
COPY go.mod ./
31+
COPY go.mod go.sum ./
1232

1333
# Download dependencies
1434
RUN go mod download
1535

1636
# Copy source code
1737
COPY . .
1838

39+
# Copy built web assets from web-builder stage
40+
COPY --from=web-builder /web/dist ./web/dist
41+
1942
# Build the application
20-
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -o miners-scheduler .
43+
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-w -s" -o ems .
2144

22-
# Final stage
45+
# Stage 3: Final runtime image
2346
FROM alpine:latest
2447

2548
# Install runtime dependencies
@@ -28,31 +51,34 @@ RUN apk add --no-cache ca-certificates tzdata
2851
ENV TZ=Europe/Riga
2952

3053
# Create non-root user
31-
RUN addgroup -g 1001 miners && \
32-
adduser -D -u 1001 -G miners miners
54+
RUN addgroup -g 1001 ems && \
55+
adduser -D -u 1001 -G ems ems
3356

3457
# Set working directory
3558
WORKDIR /app
3659

3760
# Copy binary from builder stage
38-
COPY --from=builder /app/miners-scheduler .
61+
COPY --from=go-builder /app/ems .
62+
63+
# Copy web assets from builder stage
64+
COPY --from=go-builder /app/web/dist ./web/dist
3965

4066
# Copy configuration example
4167
COPY config.json /app/config.json
4268

4369
# Create directories for logs and data
4470
RUN mkdir -p /app/logs /app/data && \
45-
chown -R miners:miners /app
71+
chown -R ems:ems /app
4672

4773
# Switch to non-root user
48-
USER miners
74+
USER ems
4975

50-
# Expose health check port (if configured)
76+
# Expose application port
5177
EXPOSE 8080
5278

5379
# Health check
5480
HEALTHCHECK --interval=30s --timeout=10s --start-period=5s --retries=3 \
5581
CMD wget --no-verbose --tries=1 --spider http://localhost:8080/health || exit 1
5682

5783
# Default command
58-
ENTRYPOINT ["./miners-scheduler"]
84+
ENTRYPOINT ["./ems"]

‎Makefile‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
.PHONY: build test clean lint fmt vet run dev docker docker-push help deps check
22

33
# Build variables
4-
BINARY_NAME=miners-scheduler
4+
BINARY_NAME=ems
55
BUILD_DIR=./bin
6-
DOCKER_IMAGE=miners-scheduler
6+
DOCKER_IMAGE=energy-management-system
77
DOCKER_TAG=latest
88
PLATFORMS=linux/amd64,linux/arm64,linux/arm/v7
99

@@ -76,11 +76,11 @@ dev-watch: ## Run with file watching (requires entr: brew install entr)
7676

7777
# Docker targets
7878
docker: ## Build Docker image for ARM7 (Raspberry Pi)
79-
rm -f miners-scheduler-working.tar
79+
rm -f ems-working.tar
8080
docker buildx build --platform linux/arm/v7 --no-cache --output=type=docker -t $(DOCKER_IMAGE):$(DOCKER_TAG)-arm7 .
81-
docker save miners-scheduler:latest-arm7 > miners-scheduler.tar
82-
skopeo copy docker-archive:miners-scheduler.tar docker-archive:miners-scheduler-working.tar
83-
cp miners-scheduler-working.tar ~/Downloads/miners-scheduler-working.tar
81+
docker save $(DOCKER_IMAGE):latest-arm7 > ems.tar
82+
skopeo copy docker-archive:ems.tar docker-archive:ems-working.tar
83+
cp ems-working.tar ~/Downloads/ems-working.tar
8484

8585
docker-multi: ## Build Docker image for multiple platforms
8686
docker buildx build --platform $(PLATFORMS) -t $(DOCKER_IMAGE):$(DOCKER_TAG) .

0 commit comments

Comments
 (0)