This repository demonstrates a minimal full-stack application that combines a FastAPI backend with a Svelte (Vite) frontend. It showcases common features such as authentication with JWT, a SQL database (SQLite) managed through SQLAlchemy, and a fully reactive CRUD interface.
.
├── backend
│ ├── app
│ │ ├── auth.py
│ │ ├── crud.py
│ │ ├── database.py
│ │ ├── main.py
│ │ ├── models.py
│ │ └── schemas.py
│ └── requirements.txt
├── frontend
│ ├── index.html
│ ├── package.json
│ ├── src
│ │ ├── App.svelte
│ │ ├── app.css
│ │ ├── lib
│ │ │ └── api.js
│ │ ├── main.js
│ │ └── stores
│ │ └── auth.js
│ ├── svelte.config.js
│ ├── tsconfig.base.json
│ ├── tsconfig.json
│ └── vite.config.js
└── README.md
The backend exposes:
Python version: The backend is tested with Python 3.11. Ensure your virtual environment uses this interpreter to avoid compatibility issues.
cd backend
python3.11 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --reload
The API will be available at http://127.0.0.1:8000
. Visit http://127.0.0.1:8000/docs
for the interactive Swagger UI.
The Svelte frontend contains registration/login forms, displays the authenticated user's profile, and allows creating, updating, and deleting personal items. It communicates with the backend through a small Axios client and stores the JWT token in localStorage
.
cd frontend
npm install
npm run dev
By default Vite runs on http://127.0.0.1:5173
. A development proxy forwards /api
requests to the FastAPI server running on http://localhost:8000
.
npm run dev
.backend/app.db
).# Register
http POST :8000/auth/register [email protected] password=secret123
# Login to get an access token
http --form POST :8000/auth/token [email protected] password=secret123
# Use the token for authenticated requests
http GET :8000/items "Authorization:Bearer <token>"
Replace the HTTPie commands with curl
if you prefer.