Newer
Older
geekbrain_io_web / README.md
# Geekbrain.io Portfolio

FastAPI portfolio website with steampunk design.

## Prerequisites

- Docker & Docker Compose
- MariaDB server accessible from NAS (10.0.0.16:3306)
- Nginx Proxy Manager (NPM) installed and configured

## Initial Setup

### 1. Configure Database

On your MariaDB server, run the `docker/init-db.sql` script (or manually):

```sql
CREATE DATABASE geekbrain_portfolio CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'geekbrain_app'@'%' IDENTIFIED BY 'YOUR_STRONG_PASSWORD';
GRANT SELECT, INSERT, UPDATE, DELETE ON geekbrain_portfolio.* TO 'geekbrain_app'@'%';
FLUSH PRIVILEGES;
```

### 2. Environment Configuration

Copy `.env.example` to `.env` and fill in all required values:

- `DATABASE_URL`: `mysql+aiomysql://geekbrain_app:[email protected]:3306/geekbrain_portfolio`
- `SMTP_USER`: your Gmail address
- `SMTP_PASSWORD`: Gmail app password (not your regular password)
- `RECAPTCHA_SITE_KEY` & `RECAPTCHA_SECRET`: from Google reCAPTCHA v2 setup
- `GITBUCKET_URL`: your GitBucket API endpoint (default provided)

### 3. Deploy with Docker

From the project root:

```bash
docker-compose -f docker/docker-compose.yml up -d
```

The app will be available on http://localhost:8000

### 4. Configure Nginx Proxy Manager

Add a new Proxy Host:

- **Domain names:** `portfolio.geekbrain.io` (or your desired domain)
- **Scheme:** http
- **Hostname/IP:** IP_of_your_NAS (or `host.docker.internal` if NPM runs on same host)
- **Port:** 8000
- **Enable SSL:** Yes (Let's Encrypt)
- **WebSockets:** No (not needed)

Save and wait for SSL certificate to be issued.

## Development

Run locally without Docker:

```bash
uvicorn app.main:app --reload
```

Then visit http://localhost:8000

## Testing

Run all tests:

```bash
pytest tests/ -v
```

## Project Structure

See `docs/superpowers/specs/2025-03-21-geekbrain-portfolio-design.md` for full specification and architecture.

## Notes

- GitBucket API is cached for 5 minutes (configurable via `CACHE_TTL`)
- Contact form includes reCAPTCHA v2 and stores submissions in the database
- Email notifications are sent via Gmail SMTP
- All assets are in `app/static/`, templates in `app/templates/`

## License

Proprietary - Geekbrain.io