Skip to content

Simple web application to shorten URLs locally or on a server

License

Notifications You must be signed in to change notification settings

eslam5464/Url-Shortener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MIT License LinkedIn Github

Table of Contents
  1. About The Project
  2. Getting Started
  3. Contributing
  4. License
  5. Contact

About The Project

  • The project aims to build a URL shortener service that takes long URLs and generates shortened versions, making them easier to share
  • Users can input long URLs, and the system will generate a unique short URL for each input

Sample image

Sample image

Technologies Used

Python FastApi PostgreSQL Redis Jinja HTML CSS JavaScript

  • Python: The primary programming language for backend development.
  • FastAPI: To create the web service and handle HTTP requests/responses.
  • PostgreSQL: As the primary database to store information about original URLs and their corresponding short URLs.
  • Redis: To cache frequently accessed URLs for faster retrieval and better performance and use it for the api limiter to limit requests.
  • Jinja2 Template Engine: To render HTML templates for the frontend interface.
  • HTML/CSS/JavaScript: For the frontend interface.

Note: each of the above icons redirects to its official documentation

(back to top)

Getting Started

Prerequisites

Installation

  1. Clone the repo
    git clone https://github.com/eslam5464/Url-Shortener.git
Environment variables
BACKEND_HOST=127.0.0.1
BACKEND_PORT=8000

CORS_ORIGIN=["*"]

ALLOWED_HOSTS=["*"]

POSTGRES_DB=main-database
POSTGRES_DB_SCHEMA=url-shortener
POSTGRES_HOST=localhost
POSTGRES_PASSWORD=change-this
POSTGRES_PORT=5432
POSTGRES_USER=postgres

REDIS_HOST=localhost
REDIS_USER=
REDIS_PASS=change-this
REDIS_PORT=6379

Local

  1. Add the previous environment variables to your project
  2. Create a new virtual environment Official python website documentation
  3. Activate the virtual environment
  4. Change the directory to 'backend' folder e.g. cd backend, and then run the following commands
pip install poetry poetry-plugin-export
poetry config virtualenvs.create false
poetry export --without-hashes -f requirements.txt -o requirements.txt
pip install --upgrade pip
pip install -r requirements.txt
python main.py

Docker

  1. Add the environment variables from above in the shell
  2. Change directory to project root directory and run dockerfile
docker-compose -f docker-compose-local.yml -p url-shortener up -d --build backend
  1. You should see the web interface at http://localhost:8000 or the port and host that you specified in the environment variables.*

(back to top)

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See the file LICENSE for more information.

(back to top)

Contact

Project Link: GitHub

Social: LinkedIn

(back to top)

About

Simple web application to shorten URLs locally or on a server

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published