This guide shows how to run the FastAPI backend and the React (React Router + Vite) frontend.
- Python: 3.11+ recommended
- Node.js: 18+ (20+ recommended) and npm
- PostgreSQL: reachable instance (local or remote)
Set environment variables for the backend (defaults shown). Create a .env
file or set in your shell:
DB_USER=postgres
DB_PASSWORD=your_password_here
DB_HOST=localhost
DB_PORT=5432
DB_NAME=postgres
DB_SCHEMA=local
Note: The code reads env vars directly via os.getenv
. If you want .env
auto-loading, add from dotenv import load_dotenv; load_dotenv()
early in config.py
.
- Ensure the database exists and is reachable.
- Create the schema if it does not exist:
CREATE SCHEMA IF NOT EXISTS local;
- Create the table used by the app (if not using migrations):
CREATE TABLE IF NOT EXISTS local.local_testing (
id integer PRIMARY KEY,
value integer NULL
);
- Create and activate a virtual environment:
python -m venv .venv
# Windows PowerShell
. .venv/Scripts/Activate.ps1
# macOS/Linux
source .venv/bin/activate
- Change into the backend directory and install dependencies:
cd backend-proj
pip install -r requirements.txt
- Run the server (default on http://127.0.0.1:8000):
uvicorn main:app --reload
- API Endpoints:
GET /grabTableRecords
POST /insertTableRecord
PUT /updateTableRecord
DELETE /deleteTableRecord/{id}
From the ui-proj
directory:
cd ui-proj
npm install
Development (runs Vite dev server, typically http://localhost:5173):
npm run dev
Production build and serve SSR output:
npm run build
npm start
The backend allows origins http://localhost:5173
and http://localhost:3000
. If your frontend runs elsewhere, update origins
in backend-proj/main.py
accordingly.
- Postgres auth errors: verify
DB_*
variables and that thelocal
schema exists. - Missing table: run the SQL in Database Preparation, or add SQLAlchemy migrations.
- Port conflicts: change dev server ports (
vite
oruvicorn --port
) and updateorigins
.