Skip to content

abhishek7kalra/Short-URL-Generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Short URL Generator

Short URL Generator

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.

Features

  • 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.

Installation

Make sure you have Python and MongoDB installed on your system.

  1. Clone the repository:
git clone https://github.com/abhishek7kalra/short-url-generator.git
  1. Navigate to the project directory:
cd short-url-generator
  1. Install the required dependencies:
pip install -r requirements.txt
  1. 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.

  1. Start the application:
uvicorn main:app --reload

You can now access the API endpoints at http://localhost:8000.

API Endpoints

  • POST /createUrl - Create a short URL
  • DELETE /deleteUrl/{url_id} - Delete a short URL
  • POST /signup - Create a new user
  • POST /login - Authenticate a user
  • GET /profile - Retrieve user profile

For detailed API documentation, visit http://localhost:8000/docs or http://localhost:8000/redoc.

Contributing

Contributions are welcome! If you find any bugs, create an issue or submit a pull request with your proposed changes.

License

This project is licensed under the MIT License.

Acknowledgements

  • 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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published