# LinksMatch — Backend + Real-time Messaging

Production-ready FastAPI backend for the LinksMatch golf partner matching app.

## Features
- User profiles & golf stats
- Course listings
- Match requests (pending → confirmed)
- Real-time messaging via WebSockets
- SQLite database (auto-seeded)
- REST + WebSocket API

## Quick Start

```bash
cd links-match
chmod +x run.sh
./run.sh
```

Then open `frontend/index.html` in your browser.

The frontend will talk to `http://localhost:8787`.

## API Endpoints

- `GET /users` — All golfers
- `GET /users/{id}` — Single profile
- `GET /courses` — Featured courses
- `GET /matches?user_id=1` — User's matches
- `POST /matches?user_id=1` — Send match request
- `POST /matches/{id}/confirm` — Confirm a match
- `GET /messages/{other_user_id}` — Chat history
- `POST /messages` — Send message (also broadcasts via WS)

**WebSocket**: `ws://localhost:8787/ws/{user_id}`

## Real-time Chat
Open the frontend, go to the **Messages** tab, click any partner. 
Messages are saved to DB + delivered instantly to the other user via WebSocket (if they are connected).

## Database
- File: `links_match.db` (created in `backend/` on first run)
- Tables: users, courses, matches, messages
- 5 seed users + 3 seed courses

## Switching Demo Users
In the live frontend, click **"Switch User"** in the top right to test messaging between different accounts (e.g. Alex ↔ Morgan).

## Tech Stack
- FastAPI + Uvicorn
- SQLAlchemy + SQLite
- Native WebSockets
- Pydantic schemas

## Next Steps (Production)
- Replace SQLite with Postgres
- Add auth (JWT / sessions)
- Add image upload for avatars
- Add real course booking integration
- Deploy with Docker + reverse proxy

---

Generated by Hermes Agent (web-designer profile) on top of the 20 premium frontend mocks.