A robust URL shortening service built with FastAPI and PostgreSQL, featuring rate limiting and efficient URL management.
- URL Shortening: Convert long URLs into short, unique codes.
- Redirection: Seamlessly redirect short URLs to their original destinations.
- Rate Limiting: Protect the service from abuse with IP-based rate limiting.
- Database: Persistent storage using PostgreSQL via SQLAlchemy 2.0.
- Node.js (v16 or higher)
- NPM (v8 or higher)
- Python (v3.9+)
- PostgreSQL (running locally or remotely)
-
Navigate to the backend directory:
cd URLShortner -
Install Python dependencies:
pip install -r requirements.txt
-
Set up the database:
- Ensure PostgreSQL is running.
- Create a database (e.g.,
urlshortener). - Run the initialization script:
python init_db.py
-
Run the development server:
python main.py
The API will be available at
http://localhost:8000.
-
Navigate to the frontend directory:
cd snipurl-main -
Install Node.js dependencies:
npm install
-
Start the development server:
npm run start
The application will be available at
http://localhost:3000.
Use the "Create Short URL" form on the homepage:
- Enter the long URL you want to shorten.
- Click "Create".
- The shortened URL will appear below.
Simply paste the short URL into your browser's address bar. You will be automatically redirected to the original long URL.
- Framework: FastAPI
- ORM: SQLAlchemy 2.0
- Database: PostgreSQL
- Runtime: Uvicorn ASGI server
- Validation: Pydantic
- Framework: React
- Language: JavaScript (ES6+)
- Styling: Custom CSS
- Build Tool: Vite