Table of Contents
- 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
- 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
- Clone the repo
git clone https://github.com/eslam5464/Url-Shortener.git
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
- Add the previous environment variables to your project
- Create a new virtual environment Official python website documentation
- Activate the virtual environment
- 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
- Add the environment variables from above in the shell
- Change directory to project root directory and run dockerfile
docker-compose -f docker-compose-local.yml -p url-shortener up -d --build backend
- You should see the web interface at http://localhost:8000 or the port and host that you specified in the environment variables.*
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!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See the file LICENSE
for more information.
Project Link: GitHub
Social: LinkedIn