Add local scrape database mode and schema
This commit is contained in:
@@ -65,15 +65,28 @@ This project replaces the Excel/VBA workflow named `Catalog maker - 20` with a N
|
||||
|
||||
## Database architecture
|
||||
|
||||
There are two selectable data sources:
|
||||
There are three selectable data sources:
|
||||
|
||||
### Live DB
|
||||
### Local 9bplus DB
|
||||
|
||||
- Uses the imported local MariaDB database named `9bplus`.
|
||||
- This is the only database allowed to receive explicit catalog writes.
|
||||
- Writes remain disabled unless the user enables the local permission switches.
|
||||
|
||||
### Live 9bplus DB
|
||||
|
||||
- Uses the existing 9b-plus API endpoint configured in `config/local.json`.
|
||||
- Credentials are secret and must stay server-side.
|
||||
- Must remain read-only.
|
||||
|
||||
### Local DB
|
||||
### Local scrape DB
|
||||
|
||||
- Uses the separate local MariaDB database named `catalog_scrape`.
|
||||
- Stores scraper source configuration, scrape runs, discovered products and assets.
|
||||
- It must never be used as a fallback for catalog reads. When selected in the UI, existing catalog reads continue using Local 9bplus DB until dedicated scrape-storage endpoints are added.
|
||||
- The schema is versioned in `sql/local-scrape-db.sql` and can be created with `npm run db:create-scrape`.
|
||||
|
||||
### Local MariaDB connection
|
||||
|
||||
- MariaDB is installed locally as service `MariaDB`.
|
||||
- Host: `localhost` / `127.0.0.1`.
|
||||
@@ -86,12 +99,13 @@ There are two selectable data sources:
|
||||
|
||||
## Database safety behavior
|
||||
|
||||
- The UI has `Local DB` and `Live DB` settings.
|
||||
- The UI has `Local 9bplus DB`, `Live 9bplus DB` and `Local scrape DB` settings.
|
||||
- The UI sends the selected mode using the `X-Database-Mode` request header.
|
||||
- Backend data API routes reject a Local DB request when MariaDB is not configured instead of silently using the endpoint.
|
||||
- Backend data API routes reject a Live DB request when the project is configured only for MariaDB.
|
||||
- Static HTML/CSS/JS files must remain available even when a database is not configured.
|
||||
- The top status shows the selected source, connection state, permissions and execution mode.
|
||||
- Selecting Live 9bplus DB or Local scrape DB disables catalog write permissions in the UI.
|
||||
|
||||
## Important current files
|
||||
|
||||
|
||||
Reference in New Issue
Block a user