Files
redefined-designs/README.md
T
2026-08-13 22:35:38 +00:00

124 lines
3.7 KiB
Markdown
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Redefined Designs
One-of-a-kind item storefront. React + TypeScript + antd frontend (Vite), Express + TypeScript backend, Postgres, PayPal checkout, customer accounts with GDPR-style consent handling, and an authentik-gated admin panel.
## Project layout
backend/ Express + TypeScript API, Postgres access, PayPal integration
frontend/ React + TypeScript + antd storefront and admin UI (Vite)
## Prerequisites
- Node.js 20+
- Docker (for a local, disposable Postgres instance)
- npm
## Clone
```bash
git clone https://gitea.bermudalamb.synology.me/bermudalamb/redefined-designs.git
cd redefined-designs
```
## Running locally
### 1. Start a local Postgres instance
The backend needs Postgres to talk to during local development. `backend/docker-compose.test.yml` spins up a throwaway, tmpfs-backed instance — no data persists between restarts, which is fine for local dev and tests.
```bash
cd backend
npm run db:test:up
```
This starts Postgres on `localhost:55432`, database `redefined_test`.
### 2. Load the schema
```bash
docker exec -i redefined-designs-test-db psql -U redefined_test -d redefined_test < init.sql
```
### 3. Configure environment variables
```bash
export PGHOST=localhost
export PGPORT=55432
export PGUSER=redefined_test
export PGPASSWORD=redefined_test
export PGDATABASE=redefined_test
export PORT=3000
export DEMO_MODE=true
export UPLOADS_DIR=/tmp/redefined-uploads
mkdir -p /tmp/redefined-uploads
```
`DEMO_MODE=true` enables a "Buy Now (Demo)" button on the storefront that completes a purchase without needing real PayPal credentials — useful for local development and for the Playwright tests below. To exercise real PayPal checkout locally, also set `PAYPAL_CLIENT_ID`, `PAYPAL_CLIENT_SECRET`, and `PAYPAL_ENV=sandbox`.
### 4. Run the backend
```bash
npm install
npm run dev
```
Runs on `http://localhost:3000` with hot reload.
### 5. Run the frontend
```bash
cd ../frontend
npm install
npm run dev
```
Runs on `http://localhost:5173` and proxies `/api`, `/uploads`, `/webhooks` to the backend on port 3000.
### 6. Open it
- Storefront: http://localhost:5173
- Admin: http://localhost:5173/admin
Note: locally, `/admin` is directly reachable with no login gate — the authentik SSO protection only exists in the deployed environment (Nginx Proxy Manager + authentik forward-auth), not in local dev.
## Running tests
### Backend unit tests
No database required.
```bash
cd backend
npm run test:unit
```
### Backend integration tests
Exercises the real Express app against a real (disposable) Postgres instance via `supertest`.
```bash
cd backend
npm run db:test:up
npm run test:integration
npm run db:test:down # when finished
```
### Frontend Playwright e2e tests
Needs the backend running against a database with the schema loaded (steps 14 above), since these tests drive real registration/login/purchase flows through a live API.
```bash
cd frontend
npm install
npx playwright install --with-deps # first time only — installs browser binaries
npm run test:e2e
```
## CI
Gitea Actions runs a SonarQube static analysis scan on every push to `main` and on pull requests — see `.gitea/workflows/sonarqube.yml`. It currently runs TypeScript build checks for both `backend` and `frontend`; wiring the Jest/Playwright suites into that same workflow is a natural next step once a CI-side Postgres service is added to the workflow definition.
## Production deployment
Production runs as a single Docker image (multi-stage build — the frontend is built to static files and served directly by the backend), deployed via Portainer behind Nginx Proxy Manager, with authentik forward-auth gating `/admin`. That infrastructure is homelab-specific and documented separately outside this repo.