A complete client-server book library application:
- Backend Server: FastAPI + SQLAlchemy + SQLite + MongoDB event logging
- Frontend Client: Vue 3 + Vite + Vue Router + Bootstrap 5 (separate app)
- Communication: HTTP API with JWT bearer auth
The backend and frontend run as independent services and can be started separately or together.
- Client (
frontend/) handles UI and user interaction (routes:/,/sign-in,/dashboard,/catalog,/discover; shared state insrc/composables/useLibrary.js). - Server (
app/) handles authentication, authorization, business logic, and persistence. - Database Layer: SQLite for core records, MongoDB for optional event logs.
POST /auth/register- Register a user.POST /auth/token- Login and get access token.GET /users/me- Get current user profile.
GET /books- List books (admin: all books, user: own books).POST /books- Add a new book.GET /books/{book_id}- Get one book.PUT /books/{book_id}- Update a book.DELETE /books/{book_id}- Delete a book.GET /books/external/search?q=harry+potter&provider=google- Search external providers.
GET /admin/users- List all users (admin only).
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
cp .env.example .env
uvicorn app.main:app --reloadBackend runs on http://127.0.0.1:8000
- Swagger UI: http://127.0.0.1:8000/docs
- Root endpoint: http://127.0.0.1:8000/
cd frontend
cp .env.example .env
npm install
npm run devFrontend runs on http://127.0.0.1:5173. Sign in is required for dashboard, catalog, and discover pages (JWT stored in localStorage).
cp .env.example .env
docker compose up --build- Backend API: http://localhost:8000
- Frontend client: http://localhost:5173
- MongoDB:
localhost:27017
VITE_API_BASE_URL(default:http://127.0.0.1:8000)
An admin user is auto-created on startup:
- Username:
admin - Password: set from
.env(BOOTSTRAP_ADMIN_PASSWORD)
Change this pattern for production.
Load sample rows into the SQLite database defined by SQLITE_DATABASE_URL in .env (same hashing and models as the API):
source .venv/bin/activate
python -m scripts.seed_dummy_dataThe script is idempotent: existing usernames are skipped; books already present for that owner (same title and ISBN) are skipped.
Demo users (passwords are for local development only):
| Username | Password | Role |
|---|---|---|
alice |
alice123 |
user |
bob |
bob12345 |
user |
carol |
carol123 |
user |
Books seeded (two per user):
- alice: Clean Code (Martin); The Pragmatic Programmer (Thomas & Hunt).
- bob: Design Patterns (GoF); Atomic Habits (Clear).
- carol: Project Hail Mary (Weir); The Midnight Library (Haig).
Implementation: scripts/seed_dummy_data.py.
- Register with
/auth/register(or use default admin). - Login via
/auth/tokenusing form data (username,password). - Copy
access_tokenand authorize withBearer <token>.
pytest -qcd frontend
npm run build- SQLite is used for primary CRUD records.
- MongoDB is used for book event logs (
book_eventscollection). - CORS is enabled for frontend origins on port
5173. - For production deployment, use secure secrets and managed database services.