Skip to content

Commit 08db7a0

Browse files
committed
Enhance project structure and configuration
- Update .gitignore to exclude SvelteKit and SQLite database files. - Modify docker-compose.yml to specify the latest image and container name. - Adjust Dockerfile to create a data directory for SQLite and set the production environment. - Refactor Makefile to clean up build artifacts and add an install target. - Revise README for improved clarity on the application’s purpose. - Update CI workflow to rename job for better clarity and optimize backend build command. - Remove obsolete backend files and configurations, transitioning to a SvelteKit frontend. - Introduce new Svelte components and utilities for enhanced functionality and maintainability. - Implement new data handling and visualization features in the frontend. This commit lays the groundwork for a more organized and efficient development process.
1 parent 068c4e5 commit 08db7a0

103 files changed

Lines changed: 6766 additions & 13012 deletions

File tree

Some content is hidden

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

.github/workflows/ci.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
branches: [main]
88

99
jobs:
10-
lint-frontend:
10+
check-frontend:
1111
runs-on: ubuntu-latest
1212
steps:
1313
- uses: actions/checkout@v4
@@ -22,13 +22,9 @@ jobs:
2222
working-directory: ./frontend
2323
run: npm ci
2424

25-
- name: Lint
25+
- name: Svelte check (types + lint)
2626
working-directory: ./frontend
27-
run: npm run lint
28-
29-
- name: Type check
30-
working-directory: ./frontend
31-
run: npm run type-check
27+
run: npm run check
3228

3329
test-backend:
3430
runs-on: ubuntu-latest
@@ -50,7 +46,7 @@ jobs:
5046

5147
build:
5248
runs-on: ubuntu-latest
53-
needs: [lint-frontend, test-backend]
49+
needs: [check-frontend, test-backend]
5450
steps:
5551
- uses: actions/checkout@v4
5652

@@ -67,11 +63,14 @@ jobs:
6763

6864
- name: Build frontend
6965
working-directory: ./frontend
70-
run: npm ci && npm run build
66+
run: |
67+
npm ci
68+
mkdir -p ../backend/frontend
69+
npm run build
7170
7271
- name: Build backend
7372
working-directory: ./backend
74-
run: go build -o tsflow ./main.go
73+
run: go build -ldflags="-w -s" -o tsflow .
7574

7675
- name: Verify binary
7776
run: ./backend/tsflow --help || true

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ Thumbs.db
6262
# TypeScript
6363
*.tsbuildinfo
6464

65+
# SvelteKit
66+
frontend/.svelte-kit/
67+
68+
# Database
69+
data/
70+
*.db
71+
*.db-shm
72+
*.db-wal
73+
6574
# Optional npm cache directory
6675
.npm
6776

Dockerfile

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Multi-stage build for TSFlow with embedded frontend
2-
# Optimized for multi-arch builds (amd64/arm64)
1+
# Multi-stage build for TSFlow
2+
# Produces a single binary with embedded SvelteKit frontend
33

44
# Frontend build stage
55
FROM node:20-alpine AS frontend-build
@@ -10,10 +10,12 @@ COPY frontend/package*.json ./
1010
RUN npm ci
1111

1212
COPY frontend/ ./
13-
RUN npm run build
1413

15-
# Backend build stage - compile on native arch, cross-compile for target
16-
FROM --platform=$BUILDPLATFORM golang:1.25-alpine AS backend-build
14+
# SvelteKit builds to ../backend/frontend/dist via adapter config
15+
RUN mkdir -p ../backend/frontend && npm run build
16+
17+
# Backend build stage
18+
FROM --platform=$BUILDPLATFORM golang:1.24-alpine AS backend-build
1719

1820
ARG TARGETOS
1921
ARG TARGETARCH
@@ -23,28 +25,29 @@ WORKDIR /app/backend
2325
RUN apk add --no-cache git ca-certificates
2426

2527
COPY backend/go.mod backend/go.sum ./
26-
27-
# Cache Go modules
28-
RUN --mount=type=cache,target=/go/pkg/mod \
29-
go mod download
28+
RUN --mount=type=cache,target=/go/pkg/mod go mod download
3029

3130
COPY backend/ ./
3231
COPY --from=frontend-build /app/backend/frontend/dist ./frontend/dist
3332

34-
# Cross-compile with cache mounts for speed
33+
# Cross-compile with optimizations
3534
RUN --mount=type=cache,target=/go/pkg/mod \
3635
--mount=type=cache,target=/root/.cache/go-build \
3736
CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} \
38-
go build -ldflags="-w -s" -trimpath -o tsflow ./main.go
37+
go build -ldflags="-w -s" -trimpath -o tsflow .
3938

40-
# Runtime stage - distroless for minimal image
39+
# Runtime stage - minimal distroless image
4140
FROM gcr.io/distroless/static:nonroot
4241

4342
WORKDIR /app
4443

4544
COPY --from=backend-build /app/backend/tsflow .
4645

46+
# Create data directory for SQLite
47+
VOLUME /app/data
48+
4749
ENV ENVIRONMENT=production
50+
ENV PORT=8080
4851

4952
EXPOSE 8080
5053

Makefile

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: dev dev-backend dev-frontend build clean docker help
1+
.PHONY: dev dev-backend dev-frontend build clean docker install check help
22

33
# Default target
44
help:
@@ -8,10 +8,16 @@ help:
88
@echo " make dev-backend - Run backend only (no embedded frontend)"
99
@echo " make dev-frontend - Run frontend dev server with hot reload"
1010
@echo " make build - Build production binary with embedded frontend"
11+
@echo " make check - Run linting and type checks"
1112
@echo " make docker - Build Docker image"
1213
@echo " make clean - Remove build artifacts"
1314
@echo ""
1415

16+
# Install dependencies
17+
install:
18+
cd frontend && npm install
19+
cd backend && go mod download
20+
1521
# Development: run backend without embedded frontend
1622
dev-backend:
1723
cd backend && go build -tags exclude_frontend -o tsflow . && ./tsflow
@@ -28,20 +34,27 @@ dev:
2834
@echo "Starting frontend dev server..."
2935
@cd frontend && npm run dev
3036

37+
# Linting and type checking
38+
check:
39+
@echo "Checking frontend..."
40+
cd frontend && npm run check
41+
@echo "Checking backend..."
42+
cd backend && go vet -tags exclude_frontend ./...
43+
3144
# Production: build single binary with embedded frontend
3245
build:
33-
@echo "Building frontend..."
46+
@echo "Building frontend (outputs to backend/frontend/dist)..."
3447
cd frontend && npm run build
3548
@echo "Building backend with embedded frontend..."
36-
cd backend && go build -o tsflow .
37-
@echo "Done! Binary at backend/tsflow ($(shell ls -lh backend/tsflow | awk '{print $$5}'))"
49+
cd backend && go build -ldflags="-w -s" -o tsflow .
50+
@echo "Done! Binary at backend/tsflow"
3851

3952
# Docker build
4053
docker:
4154
docker build -t tsflow .
4255

4356
# Clean build artifacts
4457
clean:
45-
rm -rf backend/tsflow backend/tsflow-backend
58+
rm -f backend/tsflow
4659
rm -rf backend/frontend/dist
47-
rm -rf frontend/dist
60+
rm -rf frontend/.svelte-kit

0 commit comments

Comments
 (0)