Supabase was integrated to store articles, article editor is standardized editor using react component
This commit is contained in:
@@ -1,12 +1,14 @@
|
||||
# Alex Herlan Portfolio
|
||||
|
||||
A custom React and FastAPI portfolio built from Alex Herlan's résumé. The interface uses hand-written CSS—no Tailwind or component library—and all profile, career, skills, and journal content is loaded from JSON through the API.
|
||||
A custom React and FastAPI portfolio built from Alex Herlan's résumé. The interface uses hand-written CSS—no Tailwind or component library. Profile, career, and skill content comes from JSON; journal articles use Supabase through FastAPI with a local JSON fallback.
|
||||
|
||||
## Project structure
|
||||
|
||||
```text
|
||||
backend/
|
||||
data/ JSON content store
|
||||
data/ Local content and article fallback
|
||||
supabase/schema.sql Supabase articles table and security setup
|
||||
seed_supabase.py One-time migration for the ten starter articles
|
||||
main.py FastAPI routes, SMTP delivery, and production serving
|
||||
requirements.txt
|
||||
frontend/
|
||||
@@ -29,7 +31,7 @@ pip install -r backend\requirements.txt
|
||||
Start FastAPI:
|
||||
|
||||
```powershell
|
||||
uvicorn backend.main:app --reload --port 8000
|
||||
uvicorn backend.main:app --reload --port 8000 --env-file backend\.env
|
||||
```
|
||||
|
||||
In a second terminal, start React:
|
||||
@@ -56,7 +58,7 @@ If SMTP is unavailable, the API returns a clear delivery error and the page keep
|
||||
|
||||
## Journal publisher
|
||||
|
||||
Open `http://localhost:5173/blog/manage` and sign in with the journal admin password. Publishing writes the new article directly to `backend/data/posts.json`; no database is involved.
|
||||
Open `http://localhost:5173/blog/manage` and sign in with the journal admin password. The writing room uses Tiptap for headings, bold and italic text, lists, undo/redo, and inline font sizes. Publishing writes to Supabase when it is configured, or to `backend/data/posts.json` during local fallback mode.
|
||||
|
||||
Set unique production values in `backend/.env`:
|
||||
|
||||
@@ -67,6 +69,28 @@ JOURNAL_TOKEN_SECRET=replace-with-a-long-random-secret
|
||||
|
||||
The login endpoint returns a signed session that expires after four hours. The password remains server-side and the browser stores only the temporary token.
|
||||
|
||||
## Supabase article storage
|
||||
|
||||
The runtime backend needs two values from **Supabase Dashboard → Settings → API Keys**:
|
||||
|
||||
```dotenv
|
||||
SUPABASE_URL=https://your-project-ref.supabase.co
|
||||
SUPABASE_SECRET_KEY=sb_secret_replace_me
|
||||
SUPABASE_ARTICLES_TABLE=articles
|
||||
```
|
||||
|
||||
Use the new `sb_secret_...` key when available. It bypasses Row Level Security and must stay only in `backend/.env`; never add it to React or commit it. The older `service_role` key is accepted as a compatibility fallback through `SUPABASE_SERVICE_ROLE_KEY`.
|
||||
|
||||
To connect a project without creating anything manually in the Supabase console:
|
||||
|
||||
1. Add the URL, secret key, project ref, and scoped access token to `backend/.env`.
|
||||
2. Run `bash scripts/setup_supabase.sh` from the repository root.
|
||||
3. Restart FastAPI.
|
||||
|
||||
The Bash command applies `backend/supabase/schema.sql` through the Management API and imports all ten starter articles. Use `bash scripts/setup_supabase.sh --schema-only` when you want the table without seed data.
|
||||
|
||||
The access token must be project-scoped with **Database: Read-write** permission. Supabase recommends scoped access tokens for agents and automation because their reach can be limited to one project. Do not paste database passwords, access tokens, or secret keys into chat.
|
||||
|
||||
## Content API
|
||||
|
||||
- `GET /api/profile`
|
||||
@@ -80,7 +104,7 @@ The login endpoint returns a signed session that expires after four hours. The p
|
||||
- `GET /api/resume`
|
||||
- `POST /api/contact`
|
||||
|
||||
Edit the files in `backend/data` to update portfolio content. No database is required.
|
||||
Edit the files in `backend/data` to update profile, career, and skill content. The health endpoint reports `articles: supabase` when the remote journal store is connected and `articles: json-fallback` otherwise.
|
||||
|
||||
## Production build
|
||||
|
||||
|
||||
Reference in New Issue
Block a user