ATRF is a three-part local app for crawling relevant pages from a submitted URL, extracting page content, and generating an AI-assisted editorial link placement suggestion. It now includes account authentication, plan-based authorization, and monthly analysis limits.
- Frontend: React + Vite
- API server: Node.js + Express
- Auth, billing, and usage tracking: JWT + MongoDB + Stripe
- AI service: FastAPI + LangChain + Gemini
- Crawling: Playwright
ATRF/
|- frontend/ # React client
|- backend/ # Express API + FastAPI service code
| |- controllers/
| |- routes/
| |- services/
| | |- ai.py # FastAPI AI service
| | |- crawlerService.js
| | |- extractorService.js
| |- .env.sample
| |- requirements.txt
|- README.md
Install these before starting:
- Node.js 18+ and npm
- Python 3.10+ and pip
- A Gemini API key
git clone <your-repo-url>
cd ATRFcd frontend
npm install
cd ..cd backend
npm install
cd ..The crawler uses Playwright with Chromium, so install the browser once after backend dependencies are installed.
cd backend
npx playwright install chromium
cd ..python -m venv .venv
.\.venv\Scripts\Activate.ps1python3 -m venv .venv
source .venv/bin/activateWith the virtual environment activated:
pip install -r backend/requirements.txtCreate the backend environment file from the sample:
Copy-Item backend/.env.sample backend/.envcp backend/.env.sample backend/.envThen update backend/.env:
GEMINI_API_KEY=your_actual_gemini_api_key
MONGODB_URI=your_actual_mongodb_uri
MONGODB_DB_NAME=your_database_name
JWT_SECRET=your_long_random_secret
STRIPE_SECRET_KEY=your_stripe_secret_key
STRIPE_PRICE_ID=your_stripe_price_id
STRIPE_WEBHOOK_SECRET=your_stripe_webhook_secret
FRONTEND_URL=http://localhost:5173Frontend env config is optional for local development because Vite already proxies /api to http://localhost:5000.
If you want to point the frontend to a custom API base URL, create frontend/.env from frontend/.env.example and set:
VITE_API_BASE_URL=Leave it empty for the default local setup.
You need 3 terminals running at the same time.
Activate the virtual environment first, then run the AI service from the backend folder:
cd backend
uvicorn services.ai:app --host 127.0.0.1 --port 8000 --reloadcd backend
npm run devThis starts the backend at http://localhost:5000.
cd frontend
npm run devThis starts the frontend at http://localhost:5173.
Visit:
http://localhost:5173
- A user signs up or logs in from the React frontend.
- The Node backend verifies the JWT and loads the user plan from MongoDB.
- Free users can run 3 analyses per month. Pro users can run 100 analyses per month.
- The frontend sends the protected form input to the Node backend.
- The Node backend crawls matching internal pages from the submitted URL.
- The backend extracts title and paragraph content from each crawled page.
- The backend forwards the extracted data to the FastAPI service.
- The FastAPI service uses Gemini to return the best matching editorial-link scenario.
- The backend increments the user's monthly analysis usage after a successful run.
- The frontend displays the selected scenario, crawled page links, and the updated remaining quota.
POST /api/auth/register: Create a user account and return a JWTPOST /api/auth/login: Sign in and return a JWTGET /api/auth/me: Return the authenticated user profile, plan, and remaining monthly analysesPOST /api/extract: Protected route that checks plan limits before running analysisPOST /api/billing/create-checkout-session: Protected Stripe checkout session for the Pro planGET /api/billing/checkout-session/:sessionId: Confirms a successful Stripe checkout and upgrades the user to ProPOST /api/billing/webhook: Optional Stripe webhook endpoint for automatic subscription sync
- Free plan: 3 analyses per month
- Pro plan: 100 analyses per month
- Usage resets automatically when the current month changes
- Upgrading to Pro keeps the same account and increases the current monthly limit to 100
- Frontend:
5173 - Node backend:
5000 - FastAPI AI service:
8000
- Node backend:
http://localhost:5000/health - FastAPI AI service:
http://127.0.0.1:8000/healthAi
Check these first:
- The FastAPI service is running on port
8000 - The backend is running on port
5000 backend/.envcontains a validGEMINI_API_KEY
Run:
cd backend
npx playwright install chromiumMake sure your virtual environment is activated and then reinstall:
pip install -r backend/requirements.txtMake sure:
npm run devis running infrontend/npm run devis running inbackend/frontend/vite.config.jsstill proxies/apitohttp://localhost:5000
Check these:
STRIPE_SECRET_KEYandSTRIPE_PRICE_IDare valid inbackend/.envFRONTEND_URLmatches the URL where the React app is running- If you use webhooks locally,
STRIPE_WEBHOOK_SECRETmatches your Stripe CLI forwarding secret