This is a URL shortening service implemented using FastAPI, Python, PostgreSQL, and Docker.
This URL shortening service allows users to shorten long URLs into concise, easy-to-share short links. It is built on the FastAPI framework, uses PostgreSQL as the database, and is containerized with Docker for easy deployment.
- Shorten long URLs into short links.
- Retrieve original URLs using short links.
- FastAPI-based RESTful API.
- PostgreSQL database for persistent storage.
- Docker support for containerized deployment.
Make sure you have the following installed on your system:
- Docker
- Docker Compose
- Python 3.8 or higher
-
Clone the repository:
git clone https://github.com/aoamusat/urlshort.git cd urlshort
-
Install the project dependencies:
pip install -r requirements.txt
-
Run database migrations:
alembic upgrade head
-
Set environment variables:
export DATABASE_URL=postgresql://user:password@host/db export BASE_URL=URL # Optional
uvicorn main:app --reload --port 80
Visit http://localhost/docs in your browser to access the Swagger documentation.
Use the API documentation to interact with the service. Shorten long URLs and retrieve original URLs using the provided API endpoints.
The API documentation is available at http://localhost/docs.
The service can be containerized using Docker. Use the provided Dockerfile for deployment.
# Build the Docker image
docker build -t url-shortener .
Alternatively, you can pull the Docker image from the Docker public repository
docker pull akeemamusat511/urlshorter:latest
Feel free to contribute to the project. Fork the repository, make your changes, and submit a pull request.
This project is licensed under the MIT License.