URL Shortener application built with Fastify (Backend) and React (Frontend).
git clone <your-repo-url>
cd brev-lycd server
# Install dependencies
pnpm install
# Copy environment variables
cp .env.example .env
# Run setup script (starts Docker PostgreSQL and runs migrations)
chmod +x setup-dev.sh
./setup-dev.sh
# Start the development server
pnpm devThe backend will be running at:
- API: http://localhost:3000
- API Docs: http://localhost:3000/docs
Open a new terminal:
cd web
# Install dependencies
pnpm install
# Copy environment variables
cp .env.example .env
# Start the development server
pnpm devThe frontend will be running at: http://localhost:5173
brev-ly/
βββ server/ # Backend (Fastify + PostgreSQL + Drizzle ORM)
βββ web/ # Frontend (React + Vite)
βββ README.md
cd server
docker-compose up -d postgrescd server
pnpm run db:migratedocker exec -it server-postgres-1 psql -U postgres -d brevly
# Password: brevlypasscd server
docker-compose downPORT=3000
NODE_ENV=development
HOST=127.0.0.1
DATABASE_URL=postgresql://postgres:brevlypass@localhost:5432/brevly
CLOUDFLARE_ACCOUNT_ID=your_account_id
CLOUDFLARE_ACCESS_KEY_ID=your_access_key
CLOUDFLARE_SECRET_ACCESS_KEY=your_secret_key
CLOUDFLARE_BUCKET=your_bucket_name
CLOUDFLARE_PUBLIC_URL=your_public_urlVITE_API_URL=http://localhost:3000/links- β Create shortened URLs
- β Delete URLs
- β List all URLs
- β Track access counts (hits)
- β Export links to CSV
- β CSV storage on Cloudflare R2 (CDN)
- β Redirect to original URL via short URL
pnpm dev # Start development server with hot reload
pnpm build # Build for production
pnpm start # Start production server
pnpm test # Run tests
pnpm db:generate # Generate new migration
pnpm db:migrate # Apply migrations
pnpm db:push # Push schema changes
pnpm db:studio # Open Drizzle Studiopnpm dev # Start development server
pnpm build # Build for production
pnpm preview # Preview production buildRun the entire stack with Docker:
cd server
docker-compose up --buildThis will start:
- PostgreSQL on port 5432
- Backend on port 3000
- Frontend on port 8080
curl -X POST http://localhost:3000/api/links \
-H "Content-Type: application/json" \
-d '{"originalUrl": "https://google.com", "shortUrl": "google"}'curl http://localhost:3000/api/linkscurl -L http://localhost:3000/googleIf ports 3000 or 5173 are already in use, you can change them in the respective .env files.
Make sure Docker is running and PostgreSQL container is up:
docker ps | grep postgresRun migrations manually:
cd server
pnpm run db:migrate@felipprodrigues
ISC


