# Belgian Bitcoin Embassy

A Nostr-powered community website for Belgium's monthly Bitcoin meetup.

## Tech Stack

- **Frontend**: Next.js 14 (App Router), TypeScript, Tailwind CSS, Shadcn/ui
- **Backend**: Express.js, TypeScript, Prisma ORM
- **Database**: SQLite (default), PostgreSQL supported
- **Auth**: Nostr login (NIP-07), JWT sessions

## Quick Start

### 1. Clone and install

```bash
# Install backend dependencies
cd backend
npm install

# Install frontend dependencies
cd ../frontend
npm install
```

### 2. Configure environment

```bash
# From project root
cp .env.example backend/.env
cp .env.example frontend/.env.local
```

Edit `backend/.env` with your admin pubkeys and a secure JWT secret.

### 3. Set up database

```bash
cd backend
npx prisma generate
npx prisma db push
npx prisma db seed
```

### 4. Run development servers

```bash
# Terminal 1: Backend
cd backend
npm run dev

# Terminal 2: Frontend
cd frontend
npm run dev
```

- Frontend: http://localhost:3000
- Backend API: http://localhost:4000/api

## Project Structure

```
/frontend          Next.js application
  /app             App Router pages
  /components      React components
  /lib             Utilities and API client
  /hooks           Custom React hooks

/backend           Express API server
  /src             Source code
    /api           Route handlers
    /services      Business logic
    /middleware     Auth middleware
  /prisma          Database schema and migrations

/context           Design specs (reference only)
```

## API Endpoints

| Method | Path | Description |
|--------|------|-------------|
| POST | /api/auth/challenge | Get auth challenge |
| POST | /api/auth/verify | Verify Nostr signature |
| GET | /api/posts | List blog posts |
| GET | /api/posts/:slug | Get post by slug |
| POST | /api/posts/import | Import Nostr post |
| PATCH | /api/posts/:id | Update post |
| GET | /api/meetups | List meetups |
| POST | /api/meetups | Create meetup |
| PATCH | /api/meetups/:id | Update meetup |
| POST | /api/moderation/hide | Hide content |
| POST | /api/moderation/block | Block pubkey |
| GET | /api/users | List users |
| POST | /api/users/promote | Promote user |
| GET | /api/categories | List categories |
| POST | /api/categories | Create category |

## Roles

- **Admin**: Full access. Defined by pubkeys in `.env`
- **Moderator**: Content moderation. Assigned by admins via dashboard.

## License

MIT
