Short URL Generator is a backend project developed using FastAPI and MongoDB. It provides a service for generating short and unique aliases (short links) for long URLs. Users can generate short links, set custom aliases, and manage their URLs through a simple and efficient API.
- Generate a short and unique alias for a given long URL.
- Optionally set a custom alias for the URL.
- URLs can be set to expire after a specified timeframe.
- User authentication and authorization using OAuth2 with Google Sign-In.
- Users can create short URLs and manage their own URLs.
- Secure storage of user details and URLs in the MongoDB database.
- Fast and efficient API endpoints for creating and deleting URLs.
- Data validation using Pydantic models.
- Simple and easy-to-understand code structure.
Make sure you have Python and MongoDB installed on your system.
- Clone the repository:
git clone https://github.com/abhishek7kalra/short-url-generator.git
- Navigate to the project directory:
cd short-url-generator
- Install the required dependencies:
pip install -r requirements.txt
- Set up the environment variables:
Create a .env
file in the root directory and add the following variables:
MONGO_HOST=<mongodb_host>
MONGO_PORT=<mongodb_port>
MONGO_DB_NAME=<mongodb_database_name>
MONGO_USERNAME=<mongodb_username>
MONGO_PASSWORD=<mongodb_password>
JWT_SECRET=<jwt_secret_key>
GOOGLE_CLIENT_ID=<google_client_id>
Make sure to replace <mongodb_host>
, <mongodb_port>
, <mongodb_database_name>
, <mongodb_username>
, <mongodb_password>
, <jwt_secret_key>
, and <google_client_id>
with your actual values.
- Start the application:
uvicorn main:app --reload
You can now access the API endpoints at http://localhost:8000
.
POST /createUrl
- Create a short URLDELETE /deleteUrl/{url_id}
- Delete a short URLPOST /signup
- Create a new userPOST /login
- Authenticate a userGET /profile
- Retrieve user profile
For detailed API documentation, visit http://localhost:8000/docs
or http://localhost:8000/redoc
.
Contributions are welcome! If you find any bugs, create an issue or submit a pull request with your proposed changes.
This project is licensed under the MIT License.
- FastAPI - Modern, fast, web framework for building APIs with Python 3.7+.
- MongoDB - NoSQL database for storing user data and URLs.
- Pydantic - Data validation and parsing using Python type annotations.
- Python JWT - Library for encoding and decoding JSON Web Tokens (JWTs).
- Passlib - Password hashing and verification library.
"Short URL Generator" is an open-source project developed by Abhishek Kalra.