mirror of
https://github.com/Tony0410/quietthanks.git
synced 2026-05-25 05:41:38 +08:00
- Add users and sessions tables to database schema - Add bcryptjs for password hashing - Create auth API routes (login, register, logout, me) - Add AuthProvider context for client-side auth state - Update all API routes to require authentication and filter by userId - Create login and register pages - Add AppShell component for authenticated layout - Update all pages to use AppShell and show user info - Each user now has their own private entries and tags Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
169 lines
4.2 KiB
Markdown
169 lines
4.2 KiB
Markdown
# Quiet Thanks
|
|
|
|
A calm, private gratitude and mood log. No streaks, no gamification—just a simple way to reflect on what you're grateful for.
|
|
|
|
## Features
|
|
|
|
- **User accounts**: Each user has their own private entries and tags
|
|
- **Quick check-in**: One prompt, optional mood, optional tags. Entry capture takes 10-20 seconds.
|
|
- **Autosave**: No save button needed. Your entry saves automatically as you type.
|
|
- **Timeline**: View all entries in reverse chronological order with filters.
|
|
- **Weekly reflection**: See your entry count and top tags from the past 7 days.
|
|
- **Export**: Download all entries as Markdown or JSON.
|
|
- **Dark mode**: Calm, minimal interface with soft colors.
|
|
- **Self-hosted**: Your data stays on your server.
|
|
|
|
## Quick Start
|
|
|
|
### Docker (Recommended)
|
|
|
|
```bash
|
|
docker compose up -d
|
|
```
|
|
|
|
The app will be available at `http://localhost:6124`.
|
|
|
|
1. Navigate to the app and click "Create one" to register
|
|
2. Enter your email, password, and optional name
|
|
3. Start logging your gratitude!
|
|
|
|
### Manual Setup
|
|
|
|
1. Install dependencies:
|
|
```bash
|
|
npm install
|
|
```
|
|
|
|
2. Generate and run database migrations:
|
|
```bash
|
|
npm run db:generate
|
|
npm run db:migrate
|
|
```
|
|
|
|
3. Start the development server:
|
|
```bash
|
|
npm run dev
|
|
```
|
|
|
|
4. Open `http://localhost:3000` in your browser.
|
|
|
|
## Development
|
|
|
|
```bash
|
|
# Install dependencies
|
|
npm install
|
|
|
|
# Generate database migrations after schema changes
|
|
npm run db:generate
|
|
|
|
# Run migrations
|
|
npm run db:migrate
|
|
|
|
# Start dev server
|
|
npm run dev
|
|
|
|
# Build for production
|
|
npm run build
|
|
|
|
# Start production server
|
|
npm start
|
|
|
|
# View database with Drizzle Studio
|
|
npm run db:studio
|
|
```
|
|
|
|
## Database
|
|
|
|
- **Location**: `./data/quietthanks.db` (SQLite)
|
|
- **Environment variable**: `DATABASE_PATH` to customize location
|
|
- **Migrations**: Stored in `./drizzle/`
|
|
|
|
The database is created automatically when you run migrations. In Docker, the `./data` directory is mounted as a volume to persist data.
|
|
|
|
### Schema
|
|
|
|
- **users**: User accounts with email and password hash
|
|
- **sessions**: Session tokens for authentication (30-day expiry)
|
|
- **entries**: Main gratitude entries with date, text, optional mood (1-5), rough day flag, and timestamps
|
|
- **tags**: Normalized tag names per user
|
|
- **entry_tags**: Junction table linking entries to tags
|
|
|
|
## Authentication
|
|
|
|
- Session-based authentication with HTTP-only cookies
|
|
- Passwords are hashed with bcrypt
|
|
- Sessions expire after 30 days
|
|
- Each user can only see their own entries and tags
|
|
|
|
## Export
|
|
|
|
Navigate to `/export` or use the Export tab to download your data:
|
|
|
|
- **Markdown**: Human-readable format, grouped by date, includes mood and tags
|
|
- **JSON**: Full data export with all fields and timestamps
|
|
|
|
Exports include all entries for the logged-in user.
|
|
|
|
## Configuration
|
|
|
|
### App Name
|
|
|
|
Change the app name by editing `src/lib/constants.ts`:
|
|
|
|
```typescript
|
|
export const APP_NAME = "My Gratitude Log";
|
|
```
|
|
|
|
### Port
|
|
|
|
In `docker-compose.yml`, change the port mapping:
|
|
|
|
```yaml
|
|
ports:
|
|
- "8080:3000" # Change 8080 to your desired port
|
|
```
|
|
|
|
## Tech Stack
|
|
|
|
- **Framework**: Next.js 16 with App Router
|
|
- **Language**: TypeScript
|
|
- **Styling**: Tailwind CSS 4
|
|
- **Database**: SQLite with Drizzle ORM
|
|
- **Authentication**: bcryptjs for password hashing
|
|
- **Icons**: Lucide React
|
|
|
|
## API Routes
|
|
|
|
### Authentication
|
|
- `POST /api/auth/register` - Create new account
|
|
- `POST /api/auth/login` - Sign in
|
|
- `POST /api/auth/logout` - Sign out
|
|
- `GET /api/auth/me` - Get current user
|
|
|
|
### Entries
|
|
- `GET /api/entries` - List entries (with optional filters)
|
|
- `POST /api/entries` - Create or update entry for a date
|
|
- `GET /api/entries/[id]` - Get single entry
|
|
- `PATCH /api/entries/[id]` - Update entry
|
|
- `DELETE /api/entries/[id]` - Delete entry
|
|
|
|
### Tags
|
|
- `GET /api/tags` - Get recent/search tags
|
|
|
|
### Export
|
|
- `POST /api/export` - Export all entries (markdown or json)
|
|
|
|
## Future Extension Points
|
|
|
|
These features are not implemented but the architecture supports them:
|
|
|
|
- **Cloud sync**: Add a sync service to enable cross-device access
|
|
- **LLM summaries**: Integrate with an LLM API to generate monthly reflections
|
|
- **Notifications**: Add push notifications for daily reminders
|
|
- **Import**: Add an import endpoint to restore from JSON exports
|
|
- **OAuth**: Add social login providers
|
|
|
|
## License
|
|
|
|
MIT
|