This repository contains a personal reading library application. It consists of a backend API that extracts and stores link metadata (title, summary, tags, images, scheduled reading times) and a frontend single-page application for browsing and managing saved links.
-
Backend: FastAPI (Python). Responsibilities:
- Connects to MongoDB to store links and user accounts
- Provides authenticated REST endpoints for links, tags, and stats
- Accepts Telegram webhook payloads to add links automatically
- Handles authentication using JWT
-
Frontend: React + Vite + TypeScript. Responsibilities:
- Provides a responsive UI to list, search, filter, schedule, and mark links as read or favorite
- Handles user login and stores access tokens in local storage
- Calls the backend API to read and modify data
-
Data store: MongoDB (Atlas or self-hosted)
my-elibrary/
backend/ # FastAPI app, database, models, scraper
frontend/ # Vite + React frontend
Dockerfile
docker-compose.yml
README.md
Backend (required)
MONGODB_URL— MongoDB connection URIDB_NAME— database nameSECRET_KEY— JWT signing secretALGORITHM— JWT algorithm (default:HS256)ACCESS_TOKEN_EXPIRE_MINUTES— default:1440
Optional (backend)
ADMIN_USERNAMEandADMIN_PASSWORD— used to create/update a default admin account on startupTELEGRAM_BOT_TOKEN— for Telegram webhook integrationALLOWED_ORIGINS— comma-separated list of allowed CORS origins (e.g.,https://reading-library.vercel.app,http://localhost:5173)
Frontend
VITE_API_BASE— base URL for the backend API (must include protocol, e.g.,https://reading-library.onrender.com)
Placeholders are provided in backend/.env.example and frontend/.env.example. Do not commit real secrets to the repo.
GET /health— health checkPOST /api/auth/login— returns access tokenGET /api/links— list links with pagination and filtersGET /api/links/{id}— single linkPATCH /api/links/{id}— update linkDELETE /api/links/{id}— delete linkGET /api/tags— all tagsGET /api/stats— library statisticsPOST /webhooks/telegram— endpoint for Telegram webhook messages
When the backend is running you can visit /docs for the interactive OpenAPI docs.
Backend
- Copy
backend/.env.exampletobackend/.envand fill required values. - Install dependencies and run:
cd backend
python -m venv .venv
# activate the venv, then:
pip install -r requirements.txt
uvicorn main:app --host 0.0.0.0 --port 8000
Frontend
- Set
VITE_API_BASEinfrontend/.envor in your environment. - Install dependencies and run:
cd frontend
npm install
npm run dev
Backend on Render (recommended)
- Set environment variables in Render's dashboard and mark secrets.
- Ensure
ALLOWED_ORIGINSincludes your frontend host. - Start command:
gunicorn main:app -k uvicorn.workers.UvicornWorker --bind 0.0.0.0:$PORT --workers 1
Frontend on Vercel
- Set the project root to
frontendand addVITE_API_BASEto Vercel environment variables. - Build command:
npm run build, output directory:dist.
- If the frontend is blank after deployment, verify static files are served with correct MIME types and that Vercel's
vercel.jsoncontains a filesystem handle before the SPA fallback. - If browser requests are blocked by CORS, ensure
ALLOWED_ORIGINSon the backend includes the frontend domain. - If login fails, confirm
ADMIN_USERNAMEandADMIN_PASSWORDare set on the backend and that the backend has been restarted so the admin account is created.
- Add tests, CI checks, and automated deploys.
- Consider adding a small admin setup script and monitoring for production.
If you want, I can add a render.yaml for the backend or a small debug endpoint to verify CORS headers. Let me know which you'd like.