2025-10-24 20:27:18 +02:00
# CollabTable
2025-12-29 15:54:58 +00:00
[](https://opensource.org/licenses/MIT)
[](https://android.com)
[](https://nodejs.org)
2025-10-24 20:27:18 +02:00
A collaborative list management system with Android app and server for creating and managing shared lists with custom fields and items.
## Overview
CollabTable allows multiple users to collaboratively create and manage lists with custom fields. Perfect for:
- Shopping lists with price tracking
- Product catalogs
- Task management with custom attributes
- Any structured data collection
## Features
2025-12-29 15:54:58 +00:00
### Android App
- ✨ **Beautiful Material 3 design** with dynamic colors
- 📱 **Native Android app** built with Jetpack Compose
- 💾 **Offline-first** with Room database
- 🔄 **Real-time synchronization** via WebSocket (with HTTP fallback)
- 🎨 **Custom fields** (name, link, price, category, etc.)
- ✏️ **Inline editing** of items with auto-save
- 📤 **Export functionality** (CSV format)
- 🗑️ **Soft delete support** for data recovery
- ⚙️ **Configurable server** URL and authentication
- 📊 **Optimized performance** for large tables with thousands of rows
- 🎯 **Column alignment** options (left, center, right)
2025-10-24 20:27:18 +02:00
### Server
2025-12-29 15:54:58 +00:00
- 🚀 **Express.js REST API** with TypeScript
- 🐳 **Fully containerized** with Docker
2026-08-01 19:57:47 +02:00
- 💾 **PostgreSQL** database (bring your own instance)
2025-12-29 15:54:58 +00:00
- 🔄 **Advanced sync protocol** for conflict resolution
- 🔌 **WebSocket support** for real-time updates
2026-08-01 19:57:47 +02:00
- 🔐 **Single-admin-account dashboard login** (session cookie) plus long-lived API tokens for sync clients/devices
2025-12-29 15:54:58 +00:00
- 📊 **Complete CRUD operations** for all entities
## Prerequisites
### Server
2026-08-01 19:53:32 +02:00
- **Docker** and a PostgreSQL instance (bring your own - this app does not run Postgres for you)
2025-12-29 15:54:58 +00:00
- Or **Node.js 20+** for local development
### Android App
- **Android Studio** Hedgehog or later
- **Android SDK 26+** (Android 8.0 or higher)
- **JDK 21**
- Android emulator or physical device
2025-10-24 20:27:18 +02:00
## Quick Start
### Server (Docker)
2025-12-29 15:54:58 +00:00
1. **Navigate to server directory:**
```bash
cd CollabTableServer
` ``
2. **Copy environment file (optional):**
` ``bash
cp .env.example .env
` ``
2026-08-01 19:53:32 +02:00
3. **Build and run the server, pointing at your own PostgreSQL instance:**
2025-12-29 15:54:58 +00:00
` ``bash
2026-08-01 19:53:32 +02:00
docker build -t collabtable-server .
docker run -d --name collabtable-server --restart unless-stopped \
-p 3000:3000 \
-e DATABASE_URL=postgres://user:password@host:5432/collabtable \
collabtable-server
2025-12-29 15:54:58 +00:00
` ``
2025-10-24 20:27:18 +02:00
2026-08-01 12:51:02 +02:00
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.
2025-10-24 20:27:18 +02:00
2026-08-01 19:53:32 +02:00
**Database:** PostgreSQL, bring your own instance via ` DATABASE_URL`.
2025-12-29 15:54:58 +00:00
2025-10-24 20:27:18 +02:00
### Android App
2025-12-29 15:54:58 +00:00
1. **Open project in Android Studio:**
- Open ` CollabTableAndroid` folder in Android Studio
- Wait for Gradle sync to complete
2. **Run the app:**
- Run on emulator or physical device
3. **Configure server connection:**
- Tap the Settings icon (⚙️) in the top bar
- Enter your server URL:
- **For emulator:** ` http://10.0.2.2:3000/api/`
- **For physical device:** ` http://YOUR_COMPUTER_IP:3000/api/`
2026-08-01 19:57:47 +02:00
- Enter the API token generated from the server dashboard's Settings page (the app's
"Server Password" field doubles as the API token field — see note below)
2025-12-29 15:54:58 +00:00
- Tap "Save"
**Note:** Make sure to include the trailing ` /api/` in the URL.
2025-10-24 20:27:18 +02:00
## Project Structure
` ``
CollabTable/
2025-12-29 15:54:58 +00:00
├── CollabTableAndroid/ # Android app
2025-10-24 20:27:18 +02:00
│ ├── app/
│ │ ├── src/main/java/com/collabtable/app/
2025-12-29 15:54:58 +00:00
│ │ │ ├── data/ # Database, API, repositories
│ │ │ │ ├── api/ # Retrofit interfaces
│ │ │ │ ├── dao/ # Room DAOs
│ │ │ │ ├── database/ # Room database setup
│ │ │ │ ├── model/ # Data models
│ │ │ │ └── repository/ # Repository pattern
│ │ │ └── ui/ # Compose UI
│ │ │ ├── navigation/ # Navigation setup
│ │ │ ├── screens/ # UI screens & ViewModels
│ │ │ └── theme/ # Material 3 theme
2025-10-24 20:27:18 +02:00
│ │ └── build.gradle
│ └── README.md
│
2025-12-29 15:54:58 +00:00
└── CollabTableServer/ # Node.js server
2025-10-24 20:27:18 +02:00
├── src/
2025-12-29 15:54:58 +00:00
│ ├── models/ # Data models & database logic
│ ├── routes/ # API endpoints
│ └── index.ts # Server entry point
2026-07-31 18:26:08 +02:00
├── webui/ # SvelteKit web dashboard (read-only database viewer)
2025-10-24 20:27:18 +02:00
├── Dockerfile
└── README.md
` ``
## Technology Stack
### Android
2025-12-29 15:54:58 +00:00
- **Language:** Kotlin
- **UI Framework:** Jetpack Compose with Material 3
- **Database:** Room (SQLite)
- **Networking:** Retrofit (HTTP), OkHttp WebSocket
- **Async:** Coroutines & Flow
- **Architecture:** MVVM with Repository pattern
- **Build System:** Gradle with Kotlin DSL
2025-10-24 20:27:18 +02:00
### Server
2025-12-29 15:54:58 +00:00
- **Runtime:** Node.js 20+
- **Framework:** Express.js
- **Language:** TypeScript
2026-08-01 12:51:02 +02:00
- **Database:** PostgreSQL (pg)
2026-08-01 19:57:47 +02:00
- **Containerization:** Docker
2025-12-29 15:54:58 +00:00
- **Real-time:** WebSocket support
2025-10-24 20:27:18 +02:00
## API Endpoints
2026-08-01 12:51:02 +02:00
All endpoints are prefixed with ` /api/`. The sync/collaboration endpoints below (Lists,
Fields, Items, sync) require an API token generated from the web dashboard's Settings page:
2025-12-29 15:54:58 +00:00
` ``
2026-08-01 12:51:02 +02:00
Authorization: Bearer your_api_token_here
2025-12-29 15:54:58 +00:00
` ``
2026-08-01 12:51:02 +02:00
The dashboard itself has its own separate single-admin-account login (session cookie, not a
bearer token) — see ` CollabTableServer/README.md`'s "Authentication" section.
2025-12-29 15:54:58 +00:00
### Lists
- ` GET /api/lists` - Get all lists
- ` GET /api/lists/:id` - Get a specific list
- ` POST /api/lists` - Create a new list
- ` PUT /api/lists/:id` - Update a list
- ` DELETE /api/lists/:id` - Delete a list (soft delete)
### Fields
- ` GET /api/fields/list/:listId` - Get all fields for a list
- ` POST /api/fields` - Create a new field
- ` PUT /api/fields/:id` - Update a field (including alignment)
- ` DELETE /api/fields/:id` - Delete a field (soft delete)
### Items
- ` GET /api/items/list/:listId` - Get all items for a list
- ` GET /api/items/:itemId/values` - Get all values for an item
- ` POST /api/items` - Create a new item
- ` POST /api/items/values` - Create/update item values
- ` PUT /api/items/:id` - Update an item
- ` DELETE /api/items/:id` - Delete an item (soft delete)
### Sync
- ` POST /api/sync` - Synchronize data (HTTP fallback)
2025-12-29 15:58:12 +00:00
- ` WebSocket /api/ws` - WebSocket endpoint for real-time sync
2025-12-29 15:54:58 +00:00
### Health
- ` GET /health` - Server health check
2025-10-24 20:27:18 +02:00
2026-07-31 18:26:08 +02:00
### Web UI
` /`, ` /about`, and ` /lists/:id` serve a SvelteKit dashboard (a single-page app with client-side routing) for browsing lists/fields/items read-only. It's unauthenticated, same as before this endpoint existed.
- ` 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
2025-10-24 20:27:18 +02:00
See [Server README](CollabTableServer/README.md) for detailed API documentation.
## Development
2025-12-29 15:54:58 +00:00
### Server Development
**Local development without Docker:**
1. Install dependencies:
` ``bash
cd CollabTableServer
npm install
` ``
2. Create ` .env` file:
` ``bash
cp .env.example .env
` ``
3. Start development server with hot reload:
` ``bash
npm run dev
` ``
4. Build for production:
` ``bash
npm run build
npm start
` ``
**Useful commands:**
2025-10-24 20:27:18 +02:00
` ``bash
2025-12-29 15:54:58 +00:00
npm run lint # Check code style
npm run format # Auto-format code
2025-10-24 20:27:18 +02:00
` ``
2025-12-29 15:54:58 +00:00
### Android Development
1. Open ` CollabTableAndroid` in Android Studio
2. Build the project:
` ``bash
./gradlew build
` ``
3. Run linters:
` ``bash
./gradlew ktlintCheck # Check Kotlin code style
./gradlew detekt # Run static analysis
` ``
4. Format code:
` ``bash
./gradlew ktlintFormat
` ``
2025-10-24 20:27:18 +02:00
## Data Model
2025-12-29 15:54:58 +00:00
### Database Schema
2025-10-24 20:27:18 +02:00
2025-12-29 15:54:58 +00:00
#### List
Represents a table/list container:
` ``typescript
{
id: string; // Unique identifier
name: string; // List name
createdAt: number; // Creation timestamp
updatedAt: number; // Last update timestamp
isDeleted: boolean; // Soft delete flag
}
` ``
2025-10-24 20:27:18 +02:00
2025-12-29 15:54:58 +00:00
#### Field
Defines a column/attribute in a list:
` ``typescript
{
id: string; // Unique identifier
listId: string; // Parent list ID
name: string; // Field name (e.g., "Price", "Category")
order: number; // Display order
alignment: string; // Content alignment: "left", "center", "right"
createdAt: number; // Creation timestamp
updatedAt: number; // Last update timestamp
isDeleted: boolean; // Soft delete flag
}
` ``
2025-10-24 20:27:18 +02:00
2025-12-29 15:54:58 +00:00
#### Item
Represents a row in a list:
` ``typescript
{
id: string; // Unique identifier
listId: string; // Parent list ID
createdAt: number; // Creation timestamp
updatedAt: number; // Last update timestamp
isDeleted: boolean; // Soft delete flag
}
` ``
#### ItemValue
The actual value for a specific field of an item:
` ``typescript
{
id: string; // Unique identifier
itemId: string; // Parent item ID
fieldId: string; // Associated field ID
value: string; // The actual value
updatedAt: number; // Last update timestamp
}
` ``
### Relationships
- One **List** has many **Fields**
- One **List** has many **Items**
- One **Item** has many **ItemValues** (one per Field)
## Troubleshooting
### Common Issues
#### Android App
**Cannot connect to server**
- Verify server is running: visit ` http://localhost:3000/health` in browser
- Check server URL in app settings:
- Emulator: Use ` http://10.0.2.2:3000/api/`
- Physical device: Use your computer's IP address
- Ensure trailing ` /api/` is included in URL
2026-08-01 19:57:47 +02:00
- Verify the API token is correct (generate/regenerate one from the dashboard's Settings page)
2025-12-29 15:54:58 +00:00
**Gradle sync failed**
- Update Android Studio to latest version
- Ensure JDK 21 is installed and selected
- Try: File → Invalidate Caches → Invalidate and Restart
**Build errors with Room/Kotlin**
- Clean and rebuild: Build → Clean Project → Rebuild Project
- Check that you're using compatible versions
**Large tables are slow**
- Performance is optimized for thousands of rows
- For tens of thousands of rows, consider server-side filtering
- Check that debouncing is enabled (default)
#### Server
**Port 3000 already in use**
` ``bash
# Find and kill process using port 3000
lsof -ti:3000 | xargs kill -9
2026-08-01 19:53:32 +02:00
# Or change the port mapping in your ` docker run` command or .env
2025-12-29 15:54:58 +00:00
` ``
**Docker container won't start**
` ``bash
# View logs
2026-08-01 19:53:32 +02:00
docker logs -f collabtable-server
2025-12-29 15:54:58 +00:00
# Rebuild container
2026-08-01 19:53:32 +02:00
docker stop collabtable-server && docker rm collabtable-server
docker build -t collabtable-server . && docker run -d --name collabtable-server ...
2025-12-29 15:54:58 +00:00
` ``
**Database connection error (PostgreSQL)**
2026-08-01 19:53:32 +02:00
- Verify your PostgreSQL instance is running and reachable from the container
- Check ` DATABASE_URL` in ` .env`
- Ensure the database exists
2025-12-29 15:54:58 +00:00
### Getting Help
- Check the [Android README](CollabTableAndroid/README.md) for app-specific details
- Check the [Server README](CollabTableServer/README.md) for server-specific details
2026-08-01 19:53:32 +02:00
- Review Docker logs: ` docker logs -f collabtable-server`
2025-12-29 15:54:58 +00:00
- Open an issue on GitHub with detailed error messages
2025-10-24 20:27:18 +02:00
## Synchronization
2025-12-29 15:54:58 +00:00
CollabTable uses a sophisticated sync protocol to keep data consistent across clients:
### Sync Strategy
- **Primary:** WebSocket (` /api/ws`) for real-time, low-latency sync
- **Fallback:** HTTP POST (` /api/sync`) when WebSocket fails
- **Conflict Resolution:** Latest timestamp wins
### How It Works
1. **Client → Server:** Client sends all local changes since last sync timestamp
2. **Server Processing:** Server saves client changes and retrieves server changes
3. **Server → Client:** Server returns changes made since client's last sync
4. **Client Update:** Client applies server updates locally
5. **Timestamp Update:** Client stores new server timestamp for next sync
### Sync Flow
` ``
Client Server
| |
|-- Sync Request (local changes) ---->|
| (lists, fields, items, values) |
| |
|<-- Sync Response (server changes) --|
| (updates + new serverTimestamp) |
| |
` ``
### WebSocket Protocol
Send JSON messages to ` /api/ws`:
` ``json
{
"type": "sync",
"id": "unique-request-id",
"payload": {
"lastSyncTimestamp": 1234567890,
"lists": [...],
"fields": [...],
"items": [...],
"itemValues": [...]
}
}
` ``
Response:
` ``json
{
"type": "syncResponse",
"id": "unique-request-id",
"payload": {
"lists": [...],
"fields": [...],
"items": [...],
"itemValues": [...],
"serverTimestamp": 1234567890
}
}
` ``
### 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
- **Performance:** Debounced updates for large table operations
## Docker & Deployment
### Data Persistence
**PostgreSQL**
2026-08-01 19:53:32 +02:00
- Use standard PostgreSQL backup tools (` pg_dump`, ` pg_restore`) against your own instance -
this app does not manage Postgres storage itself
2025-12-29 15:54:58 +00:00
### Docker Commands
2026-08-01 19:53:32 +02:00
**Stop the container:**
2025-12-29 15:54:58 +00:00
` ``bash
2026-08-01 19:53:32 +02:00
docker stop collabtable-server
2025-12-29 15:54:58 +00:00
` ``
**View logs:**
` ``bash
2026-08-01 19:53:32 +02:00
docker logs -f collabtable-server
2025-12-29 15:54:58 +00:00
` ``
**Rebuild and restart:**
` ``bash
2026-08-01 19:53:32 +02:00
docker build -t collabtable-server . && docker restart collabtable-server
2025-12-29 15:54:58 +00:00
` ``
**Check running containers:**
` ``bash
docker ps
` ``
### Production Deployment
**Environment Variables**
2026-08-01 19:53:32 +02:00
Configure these in ` .env` or your ` docker run` command:
2025-12-29 15:54:58 +00:00
` ``env
2026-08-01 12:51:02 +02:00
PORT=3000 # Server port
NODE_ENV=production # Environment
DATABASE_URL=postgres://user:pass@postgres:5432/collabtable
COOKIE_SECURE=true # Requires HTTPS
2025-12-29 15:54:58 +00:00
` ``
**Security Recommendations**
2026-08-01 12:51:02 +02:00
1. Generate the admin account and an API token on first run (see "Authentication" above)
2. Use HTTPS with a reverse proxy (nginx, Caddy), and set ` COOKIE_SECURE=true`
2025-12-29 15:54:58 +00:00
3. Regular database backups
4. Keep Docker images updated
5. Restrict network access to server ports
**Reverse Proxy Example (nginx)**
` ``nginx
server {
listen 80;
2025-12-29 15:56:14 +00:00
server_name example.com;
2025-12-29 15:54:58 +00:00
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
` ``
## Contributing
Contributions are welcome! Here's how you can help:
### Getting Started
1. Fork the repository
2. Create a feature branch: ` git checkout -b feature/your-feature-name`
3. Make your changes
4. Test your changes thoroughly
5. Commit with clear messages: ` git commit -m "feat: add new feature"`
6. Push to your fork: ` git push origin feature/your-feature-name`
7. Open a Pull Request
### Development Guidelines
**Code Style**
- **Android:** Follow Kotlin conventions, use ktlint for formatting
- **Server:** Follow TypeScript/JavaScript conventions, use Prettier
- Keep functions small and focused
- Write meaningful variable and function names
- Add comments for complex logic
**Testing**
- Test your changes on both emulator and physical devices (Android)
2026-08-01 19:57:47 +02:00
- Test against a PostgreSQL backend (Server)
2025-12-29 15:54:58 +00:00
- Verify sync works correctly with multiple clients
- Test with large datasets to ensure performance
**Commit Messages**
Follow conventional commits:
- ` feat:` for new features
- ` fix:` for bug fixes
- ` docs:` for documentation changes
- ` style:` for formatting changes
- ` refactor:` for code refactoring
- ` test:` for adding tests
- ` chore:` for maintenance tasks
### Areas for Contribution
**Features**
- Additional export formats (JSON, Excel)
- Search and filter functionality
- Batch operations
- User authentication and permissions
- Drag-and-drop row reordering
- Rich text field support
**Improvements**
- Performance optimization for very large tables
- Better offline support
- Enhanced error handling
- Accessibility improvements
- Internationalization (i18n)
**Documentation**
- API documentation improvements
- Tutorial videos or blog posts
- Translation to other languages
- More code examples
### Pull Request Guidelines
- Keep PRs focused on a single feature or fix
- Update documentation if needed
- Ensure all tests pass
- Add screenshots for UI changes
- Reference any related issues
2025-10-24 20:27:18 +02:00
## License
MIT