A fast, secure URL shortening service built with FastAPI and Next.js.
- Shorten long URLs with custom aliases
- Set expiration dates for URLs
- Multi-level caching (Redis + in-memory)
- Rate limiting and security headers
- Responsive web interface
- URL management with pagination
- Python 3.8+
- Node.js 18+
- PostgreSQL
- Redis
cd backend
pip install -r requirements.txt
cp .env.example .env
# Edit .env with your database credentials
alembic upgrade head
uvicorn app.main:app --reloadBackend runs on http://localhost:8000
cd frontend
npm install
npm run devFrontend runs on http://localhost:3000
curl -X POST "http://localhost:8000/api/v1/urls/create" \
-H "Content-Type: application/json" \
-d '{
"original_url": "https://example.com/very/long/url",
"custom_alias": "my-link",
"expires_in_days": 30
}'curl "http://localhost:8000/abc123"
# Redirects to original URLDATABASE_URL=postgresql://user:pass@localhost:5432/url_shortener_db
REDIS_URL=redis://localhost:6379/0
SECRET_KEY=your-secret-key-here
BASE_URL=http://localhost:8000
CORS_ORIGINS=http://localhost:3000
Backend: FastAPI, PostgreSQL, Redis, SQLAlchemy
Frontend: Next.js 16, React 19, TypeScript, Tailwind CSS