Init with specs

This commit is contained in:
2026-03-16 22:44:21 +13:00
parent 4275cbd795
commit b7539ac86e
13 changed files with 911 additions and 1 deletions

View File

@@ -0,0 +1,67 @@
---
status: archived
created: '2026-03-16'
tags:
- auth
- roles
priority: high
created_at: '2026-03-16T07:51:49.636Z'
depends_on:
- 004-poll-data-model
updated_at: '2026-03-16T09:18:35.900Z'
transitions:
- status: archived
at: '2026-03-16T09:18:35.900Z'
---
# Role & Permission System
> **Status**: 📦 Archived · **Priority**: High · **Created**: 2026-03-16 · **Tags**: auth, roles
## Overview
Each poll has a role-based permission system. The owner assigns roles to users they discover or invite. Roles control what actions a user can perform on a poll.
## Design
### Roles & Permissions
| Action | Viewer | Participant | Moderator | Owner |
|---|---|---|---|---|
| View poll & results | ✅ | ✅ | ✅ | ✅ |
| Add options | ❌ | ✅ | ✅ | ✅ |
| Vote | ❌ | ✅ | ✅ | ✅ |
| Add/remove users | ❌ | ❌ | ✅ | ✅ |
| Start/stop poll | ❌ | ❌ | ✅ | ✅ |
| Delete poll | ❌ | ❌ | ❌ | ✅ |
### Implementation
- Owner is implicit (poll.ownerId === userId)
- Roles stored in `poll.roles[]` array
- Role changes are broadcast to all connected peers
- Moderators can invite users by peer ID (discovered via spec 007) or by sharing a poll link
- Permission checks happen both client-side (UI) and on message receipt (owner validates)
### Invite Flow
1. Owner/moderator discovers a user (see spec 007) or has their peer ID
2. Assigns them a role → updates `poll.roles[]`
3. When that user connects, they receive the poll state including their role
4. Users without a role who connect via link get `viewer` by default
## Plan
- [ ] Implement role assignment data model
- [ ] Create permission check utility (`canVote()`, `canModerate()`, etc.)
- [ ] Build user management UI in poll detail page
- [ ] Implement role change broadcast over PeerJS
- [ ] Owner-side validation of incoming messages against roles
## Test
- [ ] Viewer cannot vote or add options
- [ ] Participant can vote and add options
- [ ] Moderator can add/remove users and start/stop poll
- [ ] Only owner can delete
- [ ] Unknown users connecting via link get viewer role

View File

@@ -0,0 +1,65 @@
---
status: archived
created: '2026-03-16'
tags:
- p2p
- discovery
priority: medium
created_at: '2026-03-16T07:51:50.076Z'
depends_on:
- 002-p2p-networking
- 003-user-identity-profiles
- 012-lightweight-server
updated_at: '2026-03-16T09:31:19.812Z'
transitions:
- status: archived
at: '2026-03-16T09:31:19.812Z'
---
# Peer Discovery by Tags
> **Status**: 📦 Archived · **Priority**: Medium · **Created**: 2026-03-16 · **Tags**: p2p, discovery
## Overview
Enable poll owners to discover other users to invite, based on user tags (location, interests, expertise). This is P2P—there's no central user directory. Discovery works by asking connected peers for introductions.
## Design
### Discovery Mechanism
1. **Direct invite**: Share a poll link or paste a peer ID manually
2. **Directory server**: Lightweight server where users can register their profile for discoverability
- Users opt-in to being listed (toggle in profile)
- Server stores: peer ID, name, tags, `discoverable` flag
- Query endpoint: `GET /api/users?tag=location:Berlin&tag=expertise:UX`
- Minimal server—just a thin REST API over a key-value store (e.g., Cloudflare Workers + KV, or a simple SQLite API)
3. **Peer-chain discovery** (secondary): Ask connected peers "who do you know matching these tags?"
- Supplements the directory for users who are connected but not listed
### Privacy Controls
- Users opt-in to being discoverable (setting in profile)
- Directory only stores public profile data (name, tags)—no private keys, no bio
- Users can remove themselves from directory at any time
## Plan
- [ ] Build lightweight directory server (REST API + KV store)
- [ ] Add `discoverable` toggle to user profile
- [ ] Implement directory registration (opt-in publish profile)
- [ ] Implement directory search (query by tags)
- [ ] Build discovery UI (search by tags, browse results)
- [ ] Implement "invite from discovery" flow
- [ ] Implement peer-chain discovery as fallback
## Test
- [ ] Discovery request returns matching peers from connected contacts
- [ ] Non-discoverable users are not shared
- [ ] Discovered peer can be invited to a poll
## Notes
- **DECIDED**: Adding a lightweight directory server for discoverability
- Directory server can be reused for poll snapshot storage (see spec 009)

View File

@@ -0,0 +1,74 @@
---
status: archived
created: '2026-03-16'
tags:
- ui
- mobile
priority: high
created_at: '2026-03-16T07:51:51.869Z'
related:
- 005-poll-creation-management
- 008-voting-system
- 009-public-sharing
updated_at: '2026-03-16T09:07:18.408Z'
transitions:
- status: archived
at: '2026-03-16T09:07:18.408Z'
---
# Mobile-First UI Design
> **Status**: 📦 Archived · **Priority**: High · **Created**: 2026-03-16 · **Tags**: ui, mobile
## Overview
Design all UI mobile-first. The primary use case is people voting on their phones. Desktop is a secondary concern—layouts should scale up, not be shoehorned down.
## Design
### Principles
- Touch targets ≥ 44px
- Single-column layout on mobile; expand on larger screens
- Bottom navigation bar (thumb-friendly)
- Minimal chrome—content first
- System font stack for performance
### Key Screens
1. **Home / Poll list**: Cards showing poll title, status, vote count
2. **Create poll**: Simple form, large inputs, toggle for anonymity
3. **Poll detail**: Results visualization, vote buttons, participant list
4. **Profile**: Edit name, bio, tags
5. **Poll management** (owner/mod): User list, role controls, start/stop
### Navigation
- Bottom tab bar: Home, Create (+), Profile
- Poll detail accessed by tapping a poll card
- Management accessed via gear icon within poll detail
### Styling
- Tailwind CSS with mobile breakpoints as default
- Dark mode support (respects `prefers-color-scheme`)
- CSS transitions for state changes (vote submitted, poll status change)
## Plan
- [ ] Design bottom tab navigation component
- [ ] Build poll list (home) with card layout
- [ ] Build poll creation form (mobile-optimized)
- [ ] Build poll detail view with results visualization
- [ ] Build profile edit page with tag management
- [ ] Build poll management panel (users, roles, lifecycle)
- [ ] Add dark mode toggle / system preference detection
- [ ] Test on various mobile viewport sizes
## Test
- [ ] All touch targets meet 44px minimum
- [ ] Layout works on 320px428px width (small to large phones)
- [ ] No horizontal scroll on any page
- [ ] Dark mode renders correctly
- [ ] Navigation is accessible via keyboard/screen reader