qrmaster.net

This commit is contained in:
Timo Knuth
2025-12-09 22:22:36 +01:00
parent 424c61a176
commit 8c5e2fa58e
37 changed files with 549 additions and 915 deletions

View File

@@ -42,43 +42,53 @@ A production-ready SaaS application for creating and managing QR codes with adva
Run database in Docker, app on host machine:
1. Clone the repository:
```bash
git clone https://github.com/yourusername/qr-master.git
cd qr-master
```
2. Install dependencies:
```bash
npm install
```
3. Copy and configure environment:
```bash
cp env.example .env
```
Edit `.env` and set:
- `NEXTAUTH_SECRET` (generate: `openssl rand -base64 32`)
- `IP_SALT` (generate: `openssl rand -base64 32`)
- (Optional) Google OAuth credentials
- `NEXTAUTH_SECRET` (generate: `openssl rand -base64 32`)
- `IP_SALT` (generate: `openssl rand -base64 32`)
- (Optional) Google OAuth credentials
4. Start database services:
```bash
npm run docker:dev
```
5. Run database migrations and seed:
```bash
npx prisma migrate dev
npm run db:seed
```
> **Note**: If you get migration errors, you can reset the database:
>
> ```bash
> npx prisma migrate reset
> ```
>
> This will drop the database, recreate it, run all migrations, and seed data.
6. Start development server:
```bash
npm run dev
```
@@ -94,6 +104,7 @@ npm run dev
Run everything in Docker:
1. Clone and setup:
```bash
git clone https://github.com/yourusername/qr-master.git
cd qr-master
@@ -102,11 +113,13 @@ cp env.example .env
```
2. Build and start:
```bash
npm run docker:prod
```
3. Run migrations:
```bash
docker-compose exec web npx prisma migrate deploy
```
@@ -158,6 +171,7 @@ npm run docker:backup # Backup database to SQL file
### Local Development (without Docker)
1. Install dependencies:
```bash
npm install
```
@@ -165,17 +179,20 @@ npm install
2. Set up PostgreSQL and Redis locally
3. Configure `.env` with local database URL:
```env
DATABASE_URL=postgresql://postgres:postgres@localhost:5435/qrmaster?schema=public
```
4. Run migrations and seed:
```bash
npx prisma migrate dev
npm run db:seed
```
5. Start dev server:
```bash
npm run dev
```
@@ -194,6 +211,7 @@ npm run db:seed # Then seed manually
```
This is useful when:
- Schema has changed significantly
- You have migration conflicts
- You want to start fresh with clean data
@@ -224,11 +242,13 @@ qr-master/
## API Endpoints
### Authentication
- `POST /api/auth/signin` - Sign in with credentials
- `POST /api/auth/signout` - Sign out
- `GET /api/auth/session` - Get current session
### QR Codes
- `GET /api/qrs` - List all QR codes
- `POST /api/qrs` - Create a new QR code (dynamic or static)
- `POST /api/qrs/static` - Create a static QR code
@@ -238,9 +258,11 @@ qr-master/
- `DELETE /api/qrs/delete-all` - Delete all user's QR codes
### Analytics
- `GET /api/analytics/summary` - Get analytics summary for a QR code
### User & Settings
- `GET /api/user/plan` - Get current user plan
- `GET /api/user/stats` - Get user statistics
- `POST /api/user/password` - Update password
@@ -248,31 +270,33 @@ qr-master/
- `DELETE /api/user/delete` - Delete account
### Stripe Payments
- `POST /api/stripe/checkout` - Create checkout session
- `POST /api/stripe/portal` - Create customer portal session
- `POST /api/stripe/webhook` - Handle Stripe webhooks
- `POST /api/stripe/cancel-subscription` - Cancel subscription
### Public Redirect
- `GET /r/[slug]` - Redirect and track QR code scan
## Environment Variables
| Variable | Description | Required | Default |
|----------|-------------|----------|---------|
| `DATABASE_URL` | PostgreSQL connection string | Yes | `postgresql://postgres:postgres@localhost:5435/qrmaster?schema=public` |
| `NEXTAUTH_URL` | Application URL | Yes | `http://localhost:3050` |
| `NEXTAUTH_SECRET` | Secret for JWT encryption | Yes | Generate with `openssl rand -base64 32` |
| `IP_SALT` | Salt for IP hashing (privacy) | Yes | Generate with `openssl rand -base64 32` |
| `GOOGLE_CLIENT_ID` | Google OAuth client ID | No | - |
| `GOOGLE_CLIENT_SECRET` | Google OAuth client secret | No | - |
| `STRIPE_SECRET_KEY` | Stripe secret key | No | - |
| `STRIPE_WEBHOOK_SECRET` | Stripe webhook signing secret | No | - |
| `NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY` | Stripe public key | No | - |
| `NEXT_PUBLIC_INDEXABLE` | Allow search engine indexing | No | `false` (set to `true` in production) |
| `REDIS_URL` | Redis connection string | No | `redis://redis:6379` |
| `NEXT_PUBLIC_POSTHOG_KEY` | PostHog analytics key | No | - |
| `NEXT_PUBLIC_POSTHOG_HOST` | PostHog host URL | No | - |
| Variable | Description | Required | Default |
| ------------------------------------ | ----------------------------- | -------- | ---------------------------------------------------------------------- |
| `DATABASE_URL` | PostgreSQL connection string | Yes | `postgresql://postgres:postgres@localhost:5435/qrmaster?schema=public` |
| `NEXTAUTH_URL` | Application URL | Yes | `http://localhost:3050` |
| `NEXTAUTH_SECRET` | Secret for JWT encryption | Yes | Generate with `openssl rand -base64 32` |
| `IP_SALT` | Salt for IP hashing (privacy) | Yes | Generate with `openssl rand -base64 32` |
| `GOOGLE_CLIENT_ID` | Google OAuth client ID | No | - |
| `GOOGLE_CLIENT_SECRET` | Google OAuth client secret | No | - |
| `STRIPE_SECRET_KEY` | Stripe secret key | No | - |
| `STRIPE_WEBHOOK_SECRET` | Stripe webhook signing secret | No | - |
| `NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY` | Stripe public key | No | - |
| `NEXT_PUBLIC_INDEXABLE` | Allow search engine indexing | No | `false` (set to `true` in production) |
| `REDIS_URL` | Redis connection string | No | `redis://redis:6379` |
| `NEXT_PUBLIC_POSTHOG_KEY` | PostHog analytics key | No | - |
| `NEXT_PUBLIC_POSTHOG_HOST` | PostHog host URL | No | - |
**Note**: Copy `env.example` to `.env` and update the values before starting.
@@ -356,12 +380,14 @@ For detailed deployment instructions, see [DOCKER_SETUP.md](DOCKER_SETUP.md).
### Database Issues
**Problem**: Migration errors or schema conflicts
```bash
# Solution: Reset the database
npx prisma migrate reset
```
**Problem**: "Error: P1001: Can't reach database server"
```bash
# Check if Docker containers are running
docker ps
@@ -372,12 +398,14 @@ npm run docker:dev
```
**Problem**: Prisma Client out of sync
```bash
# Regenerate Prisma Client
npx prisma generate
```
**Problem**: Need to start completely fresh
```bash
# Stop all Docker containers
npm run docker:dev:stop
@@ -394,6 +422,7 @@ npm run db:seed
### Port Already in Use
If port 3050 is already in use:
```bash
# Find and kill the process (Windows)
netstat -ano | findstr :3050
@@ -406,12 +435,14 @@ taskkill /PID <PID> /F
### Docker Issues
**Problem**: Permission denied errors
```bash
# Windows: Run PowerShell as Administrator
# Linux/Mac: Use sudo for docker commands
```
**Problem**: Out of disk space
```bash
# Clean up Docker
docker system prune -a
@@ -431,7 +462,7 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
## Support
For support, email support@qrmaster.com or open an issue on GitHub.
For support, email support@qrmaster.net or open an issue on GitHub.
## Acknowledgments
@@ -441,4 +472,4 @@ For support, email support@qrmaster.com or open an issue on GitHub.
---
Built with ❤️ by QR Master Team
Built with ❤️ by QR Master Team