70 lines
1.7 KiB
Markdown
70 lines
1.7 KiB
Markdown
# Daily Form
|
||
|
||
Shared daily check-in form. Answers are global (no per-session state). Auto-snapshots to MongoDB at 10:00 AM Riga time.
|
||
|
||
## Setup
|
||
|
||
### 1. MongoDB Atlas (free)
|
||
|
||
1. Go to https://cloud.mongodb.com → create account → create a free M0 cluster
|
||
2. Create a database user (Database Access → Add New User)
|
||
3. Allow access from anywhere (Network Access → Add IP Address → `0.0.0.0/0`)
|
||
4. Get connection string (Connect → Drivers) — looks like:
|
||
`mongodb+srv://user:pass@cluster.mongodb.net/`
|
||
|
||
### 2. Configure
|
||
|
||
```bash
|
||
cp .env.example .env
|
||
# Edit .env and paste your MongoDB URI
|
||
```
|
||
|
||
### 3. Run on saturn
|
||
|
||
```bash
|
||
# Copy files to saturn
|
||
scp -r . armandins@saturn:/opt/dailyform
|
||
|
||
# SSH in
|
||
ssh armandins@saturn
|
||
cd /opt/dailyform
|
||
|
||
docker compose up -d
|
||
```
|
||
|
||
Then add to Nginx Proxy Manager pointing to port 5000.
|
||
|
||
### 4. Editing questions
|
||
|
||
Edit `questions.yaml` and restart the container:
|
||
|
||
```bash
|
||
docker compose restart
|
||
```
|
||
|
||
The `questions.yaml` is mounted as a read-only volume so you edit it on the host, no rebuild needed.
|
||
|
||
## Question types
|
||
|
||
| Type | Description | Extra fields |
|
||
|---|---|---|
|
||
| `yesno` | Yes / No buttons | — |
|
||
| `scale` | Slider | `min`, `max`, `step` |
|
||
| `number` | Number input | `min`, `max` |
|
||
| `duration` | H : MM input (stored as minutes) | — |
|
||
| `counter` | Big − / + buttons | `min`, `max`, `step` |
|
||
| `text` | Single line | — |
|
||
| `textarea` | Multi-line | — |
|
||
| `choice` | Single select pills | `options: [...]` |
|
||
| `multichoice` | Multi select pills | `options: [...]` |
|
||
|
||
## Snapshots
|
||
|
||
Snapshots are stored in the `snapshots` MongoDB collection. View last 30:
|
||
|
||
```
|
||
GET /api/snapshots
|
||
```
|
||
|
||
Or browse directly in MongoDB Atlas UI → Collections → `dailyform` → `snapshots`.
|