refactor: reorganize project structure and update paths for backend and frontend
This commit is contained in:
1 parent
6c1ea2da47
commit
64d22d0aac
11 files changed
+120
-112
No files matched your search
+3
-3
@@ -4,8 +4,8 @@
|
||||
.env
|
||||
*.log
|
||||
node_modules
|
||||
webui/node_modules
|
||||
webui/.svelte-kit
|
||||
webui/build
|
||||
frontend/node_modules
|
||||
frontend/.svelte-kit
|
||||
frontend/build
|
||||
data/
|
||||
collabtable.db
|
||||
@@ -5,14 +5,18 @@ on:
|
||||
branches:
|
||||
- "**"
|
||||
paths:
|
||||
- 'CollabTableServer/**'
|
||||
- 'backend/**'
|
||||
- 'frontend/**'
|
||||
- 'docker/**'
|
||||
- '.github/workflows/docker.yml'
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
paths:
|
||||
- 'CollabTableServer/**'
|
||||
- 'backend/**'
|
||||
- 'frontend/**'
|
||||
- 'docker/**'
|
||||
- '.github/workflows/docker.yml'
|
||||
workflow_dispatch: {}
|
||||
|
||||
@@ -56,7 +60,8 @@ jobs:
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v7
|
||||
with:
|
||||
context: ./CollabTableServer
|
||||
context: .
|
||||
file: ./docker/Dockerfile
|
||||
platforms: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/main') && 'linux/amd64,linux/arm64' || 'linux/amd64' }}
|
||||
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
||||
tags: ${{ steps.meta.outputs.tags }}
|
||||
|
||||
@@ -5,14 +5,16 @@ on:
|
||||
branches:
|
||||
- "**"
|
||||
paths:
|
||||
- 'CollabTableServer/**'
|
||||
- 'backend/**'
|
||||
- 'frontend/**'
|
||||
- '.github/workflows/lint.yml'
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
paths:
|
||||
- 'CollabTableServer/**'
|
||||
- 'backend/**'
|
||||
- 'frontend/**'
|
||||
- '.github/workflows/lint.yml'
|
||||
workflow_dispatch: {}
|
||||
|
||||
@@ -22,7 +24,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: CollabTableServer/webui
|
||||
working-directory: frontend
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
@@ -35,7 +37,7 @@ jobs:
|
||||
with:
|
||||
node-version: '20'
|
||||
cache: 'npm'
|
||||
cache-dependency-path: CollabTableServer/webui/package-lock.json
|
||||
cache-dependency-path: frontend/package-lock.json
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
@@ -5,14 +5,16 @@ on:
|
||||
branches:
|
||||
- "**"
|
||||
paths:
|
||||
- 'CollabTableServer/**'
|
||||
- 'backend/**'
|
||||
- 'frontend/**'
|
||||
- '.github/workflows/tests.yml'
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- master
|
||||
paths:
|
||||
- 'CollabTableServer/**'
|
||||
- 'backend/**'
|
||||
- 'frontend/**'
|
||||
- '.github/workflows/tests.yml'
|
||||
workflow_dispatch: {}
|
||||
|
||||
@@ -22,7 +24,7 @@ jobs:
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: CollabTableServer
|
||||
working-directory: backend
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
@@ -33,18 +35,18 @@ jobs:
|
||||
- name: Set up Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version-file: CollabTableServer/go.mod
|
||||
go-version-file: backend/go.mod
|
||||
cache: true
|
||||
|
||||
- name: Test
|
||||
run: go test ./...
|
||||
|
||||
webui:
|
||||
frontend:
|
||||
name: Dashboard checks
|
||||
runs-on: ubuntu-latest
|
||||
defaults:
|
||||
run:
|
||||
working-directory: CollabTableServer/webui
|
||||
working-directory: frontend
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
@@ -57,7 +59,7 @@ jobs:
|
||||
with:
|
||||
node-version: '22'
|
||||
cache: npm
|
||||
cache-dependency-path: CollabTableServer/webui/package-lock.json
|
||||
cache-dependency-path: frontend/package-lock.json
|
||||
|
||||
- name: Install dependencies
|
||||
run: npm ci
|
||||
|
||||
+7
-5
@@ -8,11 +8,13 @@ CollabTableAndroid/*.iml
|
||||
CollabTableAndroid/.DS_Store
|
||||
CollabTableAndroid/captures/
|
||||
|
||||
# Server
|
||||
CollabTableServer/node_modules/
|
||||
CollabTableServer/dist/
|
||||
CollabTableServer/.env
|
||||
CollabTableServer/*.log
|
||||
# Backend
|
||||
backend/.env
|
||||
backend/*.log
|
||||
|
||||
# Frontend
|
||||
frontend/node_modules/
|
||||
frontend/dist/
|
||||
|
||||
# IDEs
|
||||
.vscode/
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
[](https://opensource.org/licenses/MIT)
|
||||
[](https://android.com)
|
||||
[](https://go.dev)
|
||||
[](https://go.dev)
|
||||
|
||||
A collaborative list management system with Android app and server for creating and managing shared lists with custom fields and items.
|
||||
|
||||
@@ -20,7 +20,7 @@ CollabTable allows multiple users to collaboratively create and manage lists wit
|
||||
- ✨ **Beautiful Material 3 design** with dynamic colors
|
||||
- 📱 **Native Android app** built with Jetpack Compose
|
||||
- 💾 **Offline-first** with Room database
|
||||
- 🔄 **Synchronization** via transactional HTTP sync and notification polling
|
||||
- 🔄 **Synchronization** via transactional HTTP sync and notification polling
|
||||
- 🎨 **Custom fields** (name, link, price, category, etc.)
|
||||
- ✏️ **Inline editing** of items with auto-save
|
||||
- 📤 **Export functionality** (CSV format)
|
||||
@@ -30,11 +30,11 @@ CollabTable allows multiple users to collaboratively create and manage lists wit
|
||||
- 🎯 **Column alignment** options (left, center, right)
|
||||
|
||||
### Server
|
||||
- 🚀 **Go REST API** built with `net/http`
|
||||
- 🚀 **Go REST API** built with `net/http`
|
||||
- 🐳 **Fully containerized** with Docker
|
||||
- 💾 **PostgreSQL** database (bring your own instance)
|
||||
- 🔄 **Advanced sync protocol** for conflict resolution
|
||||
- 🔔 **Notification polling** for background updates
|
||||
- 🔔 **Notification polling** for background updates
|
||||
- 🔐 **Single-admin-account dashboard login** (session cookie) plus long-lived API tokens for sync clients/devices
|
||||
- 📊 **Complete CRUD operations** for all entities
|
||||
|
||||
@@ -42,7 +42,7 @@ CollabTable allows multiple users to collaboratively create and manage lists wit
|
||||
|
||||
### Server
|
||||
- **Docker** and a PostgreSQL instance (bring your own - this app does not run Postgres for you)
|
||||
- Or **Go 1.26+** and Node.js 22+ for local development
|
||||
- Or **Go 1.26+** and Node.js 22+ for local development
|
||||
|
||||
### Android App
|
||||
- **Android Studio** Hedgehog or later
|
||||
@@ -54,19 +54,14 @@ CollabTable allows multiple users to collaboratively create and manage lists wit
|
||||
|
||||
### Server (Docker)
|
||||
|
||||
1. **Navigate to server directory:**
|
||||
1. **From the repository root, copy the environment file (optional):**
|
||||
```bash
|
||||
cp backend/.env.example backend/.env
|
||||
```
|
||||
|
||||
2. **Build and run the server, pointing at your own PostgreSQL instance:**
|
||||
```bash
|
||||
cd CollabTableServer
|
||||
```
|
||||
|
||||
2. **Copy environment file (optional):**
|
||||
```bash
|
||||
cp .env.example .env
|
||||
```
|
||||
|
||||
3. **Build and run the server, pointing at your own PostgreSQL instance:**
|
||||
```bash
|
||||
docker build -t collabtable-server .
|
||||
docker build -f docker/Dockerfile -t collabtable-server .
|
||||
docker run -d --name collabtable-server --restart unless-stopped \
|
||||
-p 3000:3000 \
|
||||
-e DATABASE_URL=postgres://user:password@host:5432/collabtable \
|
||||
@@ -75,7 +70,7 @@ CollabTable allows multiple users to collaboratively create and manage lists wit
|
||||
|
||||
Server runs on `http://localhost:3000`. Open it in a browser to create the admin account,
|
||||
then generate an API token from the dashboard's Settings page for your sync clients/devices
|
||||
— see `CollabTableServer/README.md`'s "Authentication" section for details.
|
||||
— see `backend/README.md`'s "Authentication" section for details.
|
||||
|
||||
**Database:** PostgreSQL, bring your own instance via `DATABASE_URL`.
|
||||
|
||||
@@ -119,12 +114,13 @@ CollabTable/
|
||||
│ │ └── build.gradle
|
||||
│ └── README.md
|
||||
│
|
||||
└── CollabTableServer/ # Go server
|
||||
├── *.go # HTTP handlers, auth, sync, and database layer
|
||||
├── go.mod # Go dependencies
|
||||
├── webui/ # SvelteKit web dashboard (read-only database viewer)
|
||||
├── Dockerfile
|
||||
└── README.md
|
||||
├── backend/ # Go backend
|
||||
│ ├── *.go # HTTP handlers, auth, sync, and database layer
|
||||
│ ├── go.mod # Go dependencies
|
||||
│ └── README.md # Backend documentation
|
||||
├── frontend/ # SvelteKit web dashboard (read-only database viewer)
|
||||
└── docker/ # Container build files
|
||||
└── Dockerfile
|
||||
```
|
||||
|
||||
## Technology Stack
|
||||
@@ -133,18 +129,18 @@ CollabTable/
|
||||
- **Language:** Kotlin
|
||||
- **UI Framework:** Jetpack Compose with Material 3
|
||||
- **Database:** Room (SQLite)
|
||||
- **Networking:** Retrofit and OkHttp (HTTP)
|
||||
- **Networking:** Retrofit and OkHttp (HTTP)
|
||||
- **Async:** Coroutines & Flow
|
||||
- **Architecture:** MVVM with Repository pattern
|
||||
- **Build System:** Gradle with Kotlin DSL
|
||||
|
||||
### Server
|
||||
- **Runtime:** Go 1.26+
|
||||
- **Framework:** Go `net/http`
|
||||
- **Language:** Go
|
||||
- **Database:** PostgreSQL (pgx)
|
||||
- **Runtime:** Go 1.26+
|
||||
- **Framework:** Go `net/http`
|
||||
- **Language:** Go
|
||||
- **Database:** PostgreSQL (pgx)
|
||||
- **Containerization:** Docker
|
||||
- **Updates:** HTTP notification polling
|
||||
- **Updates:** HTTP notification polling
|
||||
|
||||
## API Endpoints
|
||||
|
||||
@@ -154,7 +150,7 @@ Fields, Items, sync) require an API token generated from the web dashboard's Set
|
||||
Authorization: Bearer your_api_token_here
|
||||
```
|
||||
The dashboard itself has its own separate single-admin-account login (session cookie, not a
|
||||
bearer token) — see `CollabTableServer/README.md`'s "Authentication" section.
|
||||
bearer token) — see `backend/README.md`'s "Authentication" section.
|
||||
|
||||
### Lists
|
||||
- `GET /api/lists` - Get all lists
|
||||
@@ -177,19 +173,19 @@ bearer token) — see `CollabTableServer/README.md`'s "Authentication" section.
|
||||
- `PUT /api/items/:id` - Update an item
|
||||
- `DELETE /api/items/:id` - Delete an item (soft delete)
|
||||
|
||||
### Sync
|
||||
- `POST /api/sync` - Synchronize data
|
||||
- `GET /api/notifications/poll?since=<timestamp-ms>` - Poll for remote changes
|
||||
### Sync
|
||||
- `POST /api/sync` - Synchronize data
|
||||
- `GET /api/notifications/poll?since=<timestamp-ms>` - Poll for remote changes
|
||||
|
||||
### Health
|
||||
- `GET /health` - Server health check
|
||||
|
||||
### Web UI
|
||||
`/`, `/about`, and `/lists/:id` serve an embedded SvelteKit dashboard (a single-page app with client-side routing) for browsing lists/fields/items read-only. The dashboard shell is public; its data endpoints require the admin session.
|
||||
`/`, `/about`, and `/lists/:id` serve an embedded SvelteKit dashboard (a single-page app with client-side routing) for browsing lists/fields/items read-only. The dashboard shell is public; its data endpoints require the admin session.
|
||||
- `GET /web/data` - JSON snapshot of all lists, fields, items, and values, used by the dashboard
|
||||
- `GET /web/info` - JSON tech stack info, shown on the dashboard's About page
|
||||
|
||||
See [Server README](CollabTableServer/README.md) for detailed API documentation.
|
||||
See [Server README](backend/README.md) for detailed API documentation.
|
||||
|
||||
## Development
|
||||
|
||||
@@ -197,36 +193,36 @@ See [Server README](CollabTableServer/README.md) for detailed API documentation.
|
||||
|
||||
**Local development without Docker:**
|
||||
|
||||
1. Run the Go backend:
|
||||
```bash
|
||||
cd CollabTableServer
|
||||
go test ./...
|
||||
go run .
|
||||
```
|
||||
|
||||
2. Create `.env` file:
|
||||
1. Run the Go backend:
|
||||
```bash
|
||||
cp .env.example .env
|
||||
cd backend
|
||||
go test ./...
|
||||
go run .
|
||||
```
|
||||
|
||||
3. Check and build the dashboard when changing web UI code:
|
||||
2. Create `.env` file:
|
||||
```bash
|
||||
cd webui
|
||||
npm ci
|
||||
npm run check
|
||||
npm run build
|
||||
cd ..
|
||||
cp -R webui/build web
|
||||
go build -o collabtable-server .
|
||||
```
|
||||
|
||||
**Useful backend commands:**
|
||||
```bash
|
||||
go test ./... # Run Go tests
|
||||
go vet ./... # Run static checks
|
||||
```
|
||||
|
||||
### Android Development
|
||||
cp .env.example .env
|
||||
```
|
||||
|
||||
3. Check and build the dashboard when changing web UI code:
|
||||
```bash
|
||||
cd ../frontend
|
||||
npm ci
|
||||
npm run check
|
||||
npm run build
|
||||
cd ..
|
||||
cp -R frontend/build backend/web
|
||||
go -C backend build -o collabtable-server .
|
||||
```
|
||||
|
||||
**Useful backend commands:**
|
||||
```bash
|
||||
go -C backend test ./... # Run Go tests
|
||||
go -C backend vet ./... # Run static checks
|
||||
```
|
||||
|
||||
### Android Development
|
||||
|
||||
1. Open `CollabTableAndroid` in Android Studio
|
||||
|
||||
@@ -350,7 +346,7 @@ docker logs -f collabtable-server
|
||||
|
||||
# Rebuild container
|
||||
docker stop collabtable-server && docker rm collabtable-server
|
||||
docker build -t collabtable-server . && docker run -d --name collabtable-server ...
|
||||
docker build -f docker/Dockerfile -t collabtable-server . && docker run -d --name collabtable-server ...
|
||||
```
|
||||
|
||||
**Database connection error (PostgreSQL)**
|
||||
@@ -361,7 +357,7 @@ docker build -t collabtable-server . && docker run -d --name collabtable-server
|
||||
### Getting Help
|
||||
|
||||
- Check the [Android README](CollabTableAndroid/README.md) for app-specific details
|
||||
- Check the [Server README](CollabTableServer/README.md) for server-specific details
|
||||
- Check the [Server README](backend/README.md) for server-specific details
|
||||
- Review Docker logs: `docker logs -f collabtable-server`
|
||||
- Open an issue on GitHub with detailed error messages
|
||||
|
||||
@@ -369,10 +365,10 @@ docker build -t collabtable-server . && docker run -d --name collabtable-server
|
||||
|
||||
CollabTable uses a sophisticated sync protocol to keep data consistent across clients:
|
||||
|
||||
### Sync Strategy
|
||||
- **Transport:** HTTP POST (`/api/sync`)
|
||||
- **Background updates:** Notification polling (`/api/notifications/poll`)
|
||||
- **Conflict Resolution:** Latest timestamp wins
|
||||
### Sync Strategy
|
||||
- **Transport:** HTTP POST (`/api/sync`)
|
||||
- **Background updates:** Notification polling (`/api/notifications/poll`)
|
||||
- **Conflict Resolution:** Latest timestamp wins
|
||||
|
||||
### How It Works
|
||||
1. **Client → Server:** Client sends all local changes since last sync timestamp
|
||||
@@ -393,7 +389,7 @@ Client Server
|
||||
| |
|
||||
```
|
||||
|
||||
### Features
|
||||
### Features
|
||||
- **Automatic Sync:** Triggered on app start and after local changes
|
||||
- **Soft Deletes:** Deleted items can be recovered on server
|
||||
- **Optimistic Updates:** UI updates immediately, syncs in background
|
||||
@@ -421,7 +417,7 @@ docker logs -f collabtable-server
|
||||
|
||||
**Rebuild and restart:**
|
||||
```bash
|
||||
docker build -t collabtable-server . && docker restart collabtable-server
|
||||
docker build -f docker/Dockerfile -t collabtable-server . && docker restart collabtable-server
|
||||
```
|
||||
|
||||
**Check running containers:**
|
||||
@@ -434,9 +430,9 @@ docker ps
|
||||
**Environment Variables**
|
||||
Configure these in `.env` or your `docker run` command:
|
||||
```env
|
||||
PORT=3000 # Server port
|
||||
APP_VERSION=dev # Dashboard version label
|
||||
DATABASE_URL=postgres://user:pass@postgres:5432/collabtable
|
||||
PORT=3000 # Server port
|
||||
APP_VERSION=dev # Dashboard version label
|
||||
DATABASE_URL=postgres://user:pass@postgres:5432/collabtable
|
||||
COOKIE_SECURE=true # Requires HTTPS
|
||||
```
|
||||
|
||||
@@ -455,7 +451,7 @@ server {
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:3000;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header Host $host;
|
||||
}
|
||||
}
|
||||
```
|
||||
@@ -477,7 +473,7 @@ Contributions are welcome! Here's how you can help:
|
||||
|
||||
**Code Style**
|
||||
- **Android:** Follow Kotlin conventions, use ktlint for formatting
|
||||
- **Server:** Follow Go conventions, run `gofmt`, and keep handlers testable
|
||||
- **Server:** Follow Go conventions, run `gofmt`, and keep handlers testable
|
||||
- Keep functions small and focused
|
||||
- Write meaningful variable and function names
|
||||
- Add comments for complex logic
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
# Local Go build/test cache
|
||||
.gocache/
|
||||
|
||||
# Generated: webui build output, copied to ./web before the Go build.
|
||||
# Generated: frontend build output, copied to ./web before the Go build.
|
||||
web/
|
||||
!web/
|
||||
!web/.gitkeep
|
||||
+5
-4
@@ -16,7 +16,8 @@ Svelte dashboard and the Android synchronization API from one container.
|
||||
## Quick start with Docker
|
||||
|
||||
```bash
|
||||
docker build -t collabtable-server .
|
||||
cd ..
|
||||
docker build -f docker/Dockerfile -t collabtable-server .
|
||||
docker run -d --name collabtable-server --restart unless-stopped \
|
||||
-p 3000:3000 \
|
||||
-e DATABASE_URL=postgres://user:password@host:5432/collabtable \
|
||||
@@ -40,13 +41,13 @@ go run .
|
||||
To build the dashboard for the embedded production binary:
|
||||
|
||||
```bash
|
||||
cd webui
|
||||
cd ../frontend
|
||||
npm ci
|
||||
npm run check
|
||||
npm run build
|
||||
cd ..
|
||||
Copy-Item -Recurse -Force webui/build web
|
||||
go build -o collabtable-server .
|
||||
Copy-Item -Recurse -Force frontend/build backend/web
|
||||
go -C backend build -o collabtable-server .
|
||||
```
|
||||
|
||||
The Dockerfile performs those dashboard and Go build steps automatically.
|
||||
|
||||
+7
-7
@@ -1,16 +1,16 @@
|
||||
FROM node:22-alpine AS webui-builder
|
||||
WORKDIR /webui
|
||||
COPY webui/package*.json ./
|
||||
FROM node:22-alpine AS frontend-builder
|
||||
WORKDIR /frontend
|
||||
COPY frontend/package*.json ./
|
||||
RUN npm ci
|
||||
COPY webui/ ./
|
||||
COPY frontend/ ./
|
||||
RUN npm run build
|
||||
|
||||
FROM golang:1.26-alpine AS builder
|
||||
WORKDIR /app
|
||||
COPY go.mod go.sum ./
|
||||
COPY backend/go.mod backend/go.sum ./
|
||||
RUN go mod download
|
||||
COPY *.go ./
|
||||
COPY --from=webui-builder /webui/build ./web
|
||||
COPY backend/*.go ./
|
||||
COPY --from=frontend-builder /frontend/build ./web
|
||||
RUN apk add --no-cache ca-certificates && \
|
||||
CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o server .
|
||||
|
||||
|
||||
Generated
+2
-2
@@ -1,11 +1,11 @@
|
||||
{
|
||||
"name": "collabtable-server-webui",
|
||||
"name": "collabtable-server-frontend",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "collabtable-server-webui",
|
||||
"name": "collabtable-server-frontend",
|
||||
"version": "1.0.0",
|
||||
"dependencies": {
|
||||
"@lucide/svelte": "latest",
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"name": "collabtable-server-webui",
|
||||
"name": "collabtable-server-frontend",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
|
||||
Reference in new issue
Block a user