BaseMax/ShortenerLaravelGraphQL

Repository files navigation

URL Shortener Laravel GraphQL

ShortenerLaravelGraphQL is a GraphQL-based web service developed using PHP 8.2 and Laravel 10. This project aims to provide a URL shortening service with a GraphQL API interface, making it easy to create short links and retrieve original URLs using GraphQL queries.

  • URL shortening: Generate short URLs from long URLs.
  • URL redirection: Redirect short URLs to their original long URLs.
  • GraphQL API: Intuitive API for creating short links and retrieving original URLs.

Before you begin, ensure you have met the following requirements:

  • PHP 8.2 installed on your system.
  • Composer installed to manage PHP dependencies.
  • Laravel 10 installed globally or within the project.

Clone this repository to your local machine:

git clone https://.com/BaseMax/ShortenerLaravelGraphQL.git

Navigate to the project directory:

cd ShortenerLaravelGraphQL

Install the required dependencies using Composer:

composer install

Copy the .env.example file and rename it to .env:

cp .env.example .env

Generate the application key:

php artisan key:generate

Configure your database connection in the .env file.

Run database migrations:

php artisan migrate

Start the Laravel development server:

php artisan serve

Visit http://localhost:8000 in your web browser to access the GraphQL playground.

ShortenerLaravelGraphQL provides a GraphQL API endpoint for creating short links and redirecting to the original URLs. You can interact with the API using a GraphQL client or the built-in GraphQL playground.

Query/MutationDescriptionExamples
allLinksGet a list of all short links.{ allLinks { id, short_code, original_url } }
linkGet details of a specific short link.{ link(id: "abc123") { id, short_code, original_url } }
redirectLinkRedirect a short link to its original URL.(N/A)
createShortLinkCreate a new short link.{ createShortLink(url: "https://www.example.com") { id, short_code, original_url } }
updateShortLinkUpdate details of an existing short link.{ updateShortLink(id: "abc123", original_url: "https://newurl.com") { id, short_code, original_url } }
deleteShortLinkDelete a short link.{ deleteShortLink(id: "abc123") }
allUsersGet a list of all users.{ allUsers { id, username, email } }
userGet details of a specific user.{ user(id: "user123") { id, username, email } }
createUserCreate a new user.{ createUser(username: "newuser", email: "[email protected]") { id, username, email } }
updateUserUpdate details of an existing user.{ updateUser(id: "user123", email: "[email protected]") { id, username, email } }
deleteUserDelete a user.{ deleteUser(id: "user123") }
linkVisitStatsGet statistics for visits to a short link.{ linkVisitStats(shortCode: "abc123") { total_visits, unique_visits } }
userLinkStatsGet statistics for a user's short links.{ userLinkStats(userId: "user123") { total_links, total_visits } }
topVisitedLinksGet a list of top visited short links.{ topVisitedLinks(limit: 10) { id, short_code, original_url, total_visits } }
searchLinksSearch for short links based on criteria.{ searchLinks(keyword: "example", limit: 5) { id, short_code, original_url } }
createUserSessionCreate a new user session.{ createUserSession(userId: "user123") { id, token, created_at } }
deleteUserSessionDelete a user session.{ deleteUserSession(sessionId: "sess123") }
createBookmarkCreate a bookmark for a user.{ createBookmark(userId: "user123", linkId: "abc123") { id, user_id, link_id } }
deleteBookmarkDelete a user's bookmark.{ deleteBookmark(userId: "user123", linkId: "abc123") }
likeLinkLike a short link.{ likeLink(userId: "user123", linkId: "abc123") { id, user_id, link_id } }
unlikeLinkRemove a like from a short link.{ unlikeLink(userId: "user123", linkId: "abc123") }
addCommentAdd a comment to a short link.{ addComment(userId: "user123", linkId: "abc123", text: "Great link!") { id, user_id, link_id, text } }
updateCommentUpdate a comment on a short link.{ updateComment(commentId: "comm123", text: "Updated comment.") { id, user_id, link_id, text } }
deleteCommentDelete a comment from a short link.{ deleteComment(commentId: "comm123") }
rateLinkRate a short link.{ rateLink(userId: "user123", linkId: "abc123", rating: 4) { id, user_id, link_id, rating } }
updateRatingUpdate a user's rating for a short link.{ updateRating(userId: "user123", linkId: "abc123", rating: 5) { id, user_id, link_id, rating } }
deleteRatingDelete a user's rating for a short link.{ deleteRating(userId: "user123", linkId: "abc123") }
flagLinkFlag a short link for review.{ flagLink(userId: "user123", linkId: "abc123", reason: "Inappropriate content") { id, user_id, link_id, reason } }
unflagLinkRemove a flag from a short link.{ unflagLink(userId: "user123", linkId: "abc123") }
reportLinkReport an issue with a short link.{ reportLink(userId: "user123", linkId: "abc123", issue: "Broken link") { id, user_id, link_id, issue } }
createCategoryCreate a new category for short links.{ createCategory(name: "News") { id, name } }
updateCategoryUpdate details of an existing category.{ updateCategory(categoryId: "cat123", name: "Updated Category") { id, name } }
deleteCategoryDelete a category.{ deleteCategory(categoryId: "cat123") }
addLinkToCategoryAdd a short link to a category.{ addLinkToCategory(categoryId: "cat123", linkId: "abc123") { id, category_id, link_id } }
removeLinkFromCategoryRemove a short link from a category.{ removeLinkFromCategory(categoryId: "cat123", linkId: "abc123") }
searchCategoriesSearch for categories based on criteria.{ searchCategories(keyword: "news", limit: 3) { id, name } }
createTagCreate a new tag for short links.{ createTag(name: "technology") { id, name } }
updateTagUpdate details of an existing tag.{ updateTag(tagId: "tag123", name: "Updated Tag") { id, name } }
deleteTagDelete a tag.{ deleteTag(tagId: "tag123") }
addTagToLinkAdd a tag to a short link.{ addTagToLink(tagId: "tag123", linkId: "abc123") { id, tag_id, link_id } }
removeTagFromLinkRemove a tag from a short link.{ removeTagFromLink(tagId: "tag123", linkId: "abc123") }
searchTagsSearch for tags based on criteria.{ searchTags(keyword: "tech", limit: 2) { id, name } }
createReportCreate a new report for a short link.{ createReport(userId: "user123", linkId: "abc123", issue: "Spam") { id, user_id, link_id, issue } }
updateReportUpdate details of an existing report.{ updateReport(reportId: "rep123", issue: "Inaccurate information") { id, user_id, link_id, issue } }
deleteReportDelete a report.{ deleteReport(reportId: "rep123") }
approveLinkApprove a flagged short link.{ approveLink(linkId: "abc123") }
rejectLinkReject a flagged short link.{ rejectLink(linkId: "abc123", reason: "Low quality content") }
createNotificationCreate a new notification for a user.{ createNotification(userId: "user123", message: "New update!") { id, message, created_at } }
markAsReadMark a notification as read for a user.{ markAsRead(notificationId: "notif123") }
deleteNotificationDelete a notification for a user.{ deleteNotification(notificationId: "notif123") }
createSubscriptionCreate a subscription for updates.{ createSubscription(userId: "user123") { id, user_id, created_at } }
cancelSubscriptionCancel a subscription for a user.{ cancelSubscription(userId: "user123") }
updateSettingsUpdate user-specific settings.{ updateSettings(userId: "user123", theme: "dark") }
resetPasswordInitiate the password reset process.{ resetPassword(email: "[email protected]") }
changePasswordChange the user's password.{ changePassword(userId: "user123", newPassword: "newpass123") }
  • id (Primary Key)
  • username (Unique)
  • email (Unique)
  • password
  • created_at
  • updated_at
  • id (Primary Key)
  • user_id (Foreign Key to users)
  • short_code (Unique)
  • original_url
  • total_visits
  • created_at
  • updated_at
  • id (Primary Key)
  • user_id (Foreign Key to users)
  • link_id (Foreign Key to links)
  • created_at
  • updated_at
  • id (Primary Key)
  • user_id (Foreign Key to users)
  • link_id (Foreign Key to links)
  • text
  • created_at
  • updated_at
  • id (Primary Key)
  • user_id (Foreign Key to users)
  • link_id (Foreign Key to links)
  • rating
  • created_at
  • updated_at
  • id (Primary Key)
  • user_id (Foreign Key to users)
  • link_id (Foreign Key to links)
  • reason
  • created_at
  • updated_at
  • id (Primary Key)
  • user_id (Foreign Key to users)
  • link_id (Foreign Key to links)
  • issue
  • created_at
  • updated_at
  • id (Primary Key)
  • name (Unique)
  • created_at
  • updated_at
  • id (Primary Key)
  • category_id (Foreign Key to categories)
  • link_id (Foreign Key to links)
  • id (Primary Key)
  • name (Unique)
  • created_at
  • updated_at
  • id (Primary Key)
  • tag_id (Foreign Key to tags)
  • link_id (Foreign Key to links)
  • id (Primary Key)
  • user_id (Foreign Key to users)
  • message
  • read (Boolean)
  • created_at
  • updated_at
  • id (Primary Key)
  • user_id (Foreign Key to users)
  • token
  • created_at
  • updated_at
  • id (Primary Key)
  • user_id (Foreign Key to users)
  • link_id (Foreign Key to links)
  • id (Primary Key)
  • user_id (Foreign Key to users)
  • created_at
  • updated_at

Screenshot from 2023-08-15 10-08-58

Screenshot from 2023-08-15 10-11-15

Screenshot from 2023-08-15 10-18-52

Screenshot from 2023-08-15 10-24-51

Screenshot from 2023-08-15 10-40-05

Screenshot from 2023-08-15 10-52-07

Screenshot from 2023-08-15 10-54-11

Screenshot from 2023-08-15 10-55-29

Screenshot from 2023-08-15 11-08-10

Screenshot from 2023-08-15 11-09-46

Screenshot from 2023-08-15 11-26-31

Screenshot from 2023-08-15 11-56-28

Screenshot from 2023-08-15 11-56-51

Screenshot from 2023-08-15 12-33-33

Screenshot from 2023-08-15 12-34-01

Screenshot from 2023-08-15 12-48-41

Screenshot from 2023-08-15 12-49-14

Screenshot from 2023-08-15 12-50-06

Screenshot from 2023-08-15 12-50-33

Screenshot from 2023-08-15 13-13-36

Screenshot from 2023-08-15 13-13-56

Screenshot from 2023-08-15 13-14-28

Screenshot from 2023-08-15 15-38-34

Screenshot from 2023-08-15 15-41-12

Screenshot from 2023-08-15 16-05-48

Screenshot from 2023-08-15 16-25-35

Screenshot from 2023-08-15 16-28-03

Screenshot from 2023-08-15 17-05-20

Screenshot from 2023-08-15 17-07-17

Screenshot from 2023-08-15 17-24-16

Screenshot from 2023-08-15 17-51-41

Screenshot from 2023-08-15 18-11-27

Screenshot from 2023-08-15 18-26-36

Screenshot from 2023-08-15 18-32-04

Screenshot from 2023-08-15 18-33-24

Screenshot from 2023-08-15 20-11-57

Contributions are welcome! If you'd like to contribute to ShortenerLaravelGraphQL, please follow these steps:

  • Fork the repository.
  • Create a new branch for your feature or bug fix.
  • Make your changes and commit them.
  • Push your changes to your fork.
  • Submit a pull request to the main branch of the original repository.

This project is licensed under the GPL-3.0 License.

Copyright 2023, Max Base

About

ShortenerLaravelGraphQL is a GraphQL-based web service developed using PHP 8.2 and Laravel 10. This project aims to provide a URL shortening service with a GraphQL API interface, making it easy to create short links and retrieve original URLs using GraphQL queries.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •