Note
This is a learning project and is not intended for any other use. Please use it only for educational purposes.
LeetLink is a URL redirection service that simplifies access to LeetCode problem descriptions. It leverages a Redis database to store and retrieve problem slugs based on problem IDs.
- URL Redirection: Seamlessly redirects users to LeetCode problem description pages using problem IDs.
- Redis Integration: Efficient storage and retrieval of problem slugs with Redis.
- Automated Updates: Periodically fetches and updates problem data from LeetCode's API using a cron job.
- Live Development: Supports live reloading during development with
air
. - Dockerized Deployment: Easily deployable with Docker and Docker Compose.
- Docker and Docker Compose installed.
- Go (version 1.23 or higher) installed if running locally without Docker.
- Redis server running and accessible.
-
Clone the repository:
git clone https://github.com/Ankitz007/leetlink.git cd leetlink
-
Create a
.env
file by copying the example:cp .env.example .env
-
Update the
.env
file with your Redis credentials and a secret for the cron job. -
Build and start the Docker container:
docker-compose up -d leetlink
-
Access the application at http://localhost:8080.
- Method:
GET
- Query Parameter:
problem_id
(required) - Description: Redirects to the LeetCode problem description page based on the provided problem ID.
- Method:
POST
- Headers:
Authorization: Bearer <CRON_SECRET>
- Description: Fetches and updates problem data from LeetCode's API.
LeetLink can be deployed using Vercel. The vercel.json
file is pre-configured to handle API routes and serve a custom 404 page.
The vercel.json
file includes a cron job configuration to run the /api/cron
endpoint daily at 12:50 PM UTC. Ensure the CRON_SECRET
in your .env
file matches the secret used in the cron job.