# Browser Agent An AI agent that autonomously browses websites to complete a task from a natural-language prompt — plans a starting point (search or a named site), observes the page, clicks/types/scrolls, and reports back a final result. `phase1-agent-loop/` is the original standalone prototype, kept only for reference. The actual app is `phase2-monorepo/`. ## Tech stack TypeScript · Bun · Playwright · OpenAI · Next.js · Express · PostgreSQL · Prisma · Turborepo ## Project structure ``` phase2-monorepo/ apps/ web/ Next.js UI api/ Express API packages/ agent-core/ the browser/LLM loop (Playwright + OpenAI) db/ Prisma schema + client ``` ## Setup 1. **Install dependencies** (from `phase2-monorepo/`): ``` bun install bunx playwright install chromium ``` 2. **Environment variables** — set these in each package's `.env` (`.env.example` files are provided): | File | Key | |---|---| | `packages/agent-core/.env` | `OPENAI_API_KEY` | | `packages/db/.env` | `DATABASE_URL` | | `apps/api/.env` | `OPENAI_API_KEY`, `DATABASE_URL` | | `apps/web/.env.local` | `NEXT_PUBLIC_API_URL` (defaults to `http://localhost:4000`) | 3. **Start the database** — pick one: **Option A — Docker** (from `phase2-monorepo/`): ``` docker compose -f ops/dev.docker-compose.yml up -d ``` Starts Postgres on `localhost:5432` → `DATABASE_URL=postgresql://user:password@localhost:5432/browser_agent`. **Option B — Hosted** (e.g. [neon.tech](https://neon.tech) or any Postgres provider): create a database and use its connection string as `DATABASE_URL`. Then, from `packages/db/`: ``` bunx prisma generate bunx prisma migrate dev ``` ## Run ``` # terminal 1 cd phase2-monorepo/apps/api bun run dev # terminal 2 cd phase2-monorepo/apps/web bun run dev ``` Open **http://localhost:3000**. The API runs on **http://localhost:4000**. > Both `dev` scripts run under Node (not Bun) — Playwright's browser-control transport doesn't work under Bun on Windows. ## Assignment link [AI Hackathon S30 3.0 — 18 Aug](https://brindle-goal-102.notion.site/AI-Hackathon-S30-3-18-Aug-3c046b36b2e980a8890eff3a07ed65a5) ## Demo video [Browser Agent — Demo Walkthrough](https://drive.google.com/file/d/1EU5WRId3RgwPABsvL_ipufQrlJtgI_yT/view?usp=sharing)