- Node.js (v20+)
- PostgreSQL
- Redis
- Clone the repository:
git clone https://github.com/Samudomingos/brev.ly.git
cd brevly- Install dependencies:
# Install server dependencies
cd server
pnpm install
# Install web dependencies
cd ../web
pnpm install- Configure environment variables:
Server (.env file in server/ directory):
# Database
DATABASE_URL=postgresql://postgres:docker@host.docker.internal:5432/brevly
REDIS_URL=redis://host.docker.internal:6379
# Cloudflare
CLOUDFLARE_ACCOUNT_ID=your_account_id
CLOUDFLARE_PUBLIC_URL=your_public_url
AWS_ACCESS_KEY_ID=your_access_key
AWS_SECRET_ACCESS_KEY=your_secret_key
AWS_BUCKET_NAME=your_bucket_name
Web (.env file in web/ directory):
VITE_API_URL=http://localhost:3333
- Start the database (using Docker):
cd server
docker-compose up -d- Run migrations:
cd server
pnpm prisma generate
pnpm prisma migrate deploy- Start the development servers:
Server:
cd server
pnpm devWeb:
cd web
pnpm dev- Access the application:
- Frontend: http://localhost:5173
- API: http://localhost:3333
POST /links- Create a new shortened URLPOST /links/exports- Export links to CSVGET /links- Get all linksGET /links/:shortUrl- Access Link by Short UrlDELETE /links/:linkId- Delete a link
Build and run the frontend application:
cd web
pnpm build
pnpm startBuild and run the backend application:
cd server
pnpm build
pnpm start:prodThe server includes a Dockerfile for containerized deployment:
cd server
docker build -t brevly-server .
docker run -p 3333:3333 --env-file .env brevly-server