{"id":17473719,"url":"https://github.com/thanhhaudev/go-graphql","last_synced_at":"2025-04-22T10:44:35.179Z","repository":{"id":258089702,"uuid":"870025624","full_name":"thanhhaudev/go-graphql","owner":"thanhhaudev","description":"📚 Simple GraphQL project written in Go","archived":false,"fork":false,"pushed_at":"2024-10-29T09:52:38.000Z","size":86,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-10-29T11:53:45.447Z","etag":null,"topics":["go","golang","gorm","gqlgen","graphql","learning-by-doing","practice-project","sample-project","self-learning"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thanhhaudev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-10-09T10:07:10.000Z","updated_at":"2024-10-29T10:20:11.000Z","dependencies_parsed_at":"2024-11-07T05:30:00.838Z","dependency_job_id":null,"html_url":"https://github.com/thanhhaudev/go-graphql","commit_stats":{"total_commits":31,"total_committers":2,"mean_commits":15.5,"dds":0.06451612903225812,"last_synced_commit":"8f61651671a81dff24f7b6fd0b918a87a2ecfc00"},"previous_names":["thanhhaudev/go-graphql"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thanhhaudev%2Fgo-graphql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thanhhaudev%2Fgo-graphql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thanhhaudev%2Fgo-graphql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thanhhaudev%2Fgo-graphql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thanhhaudev","download_url":"https://codeload.github.com/thanhhaudev/go-graphql/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249259146,"owners_count":21239422,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","gorm","gqlgen","graphql","learning-by-doing","practice-project","sample-project","self-learning"],"created_at":"2024-10-18T18:06:42.383Z","updated_at":"2025-04-16T16:31:50.075Z","avatar_url":"https://github.com/thanhhaudev.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Simple GraphQL Library Management System\n\nThis project is a **Simple Library Management System** built with **Golang** and **gqlgen**. It provides a GraphQL API for managing books, authors, and borrowers, along with borrowing and returning books.\n\n## Features\n\n- **Book Management**: Create, update, and retrieve book information.\n- **Author Management**: Manage author records.\n- **Borrower Management**: Handle borrower data.\n- **Borrowing System**: Track book borrowing and returning status.\n\n## Database Schema\n\nThe system's database schema is as follows:\n\n```plaintext\n+--------------------+         +--------------------+        +--------------------+\n|      authors       |         |     authors_books  |        |       books        |\n+--------------------+         +--------------------+        +--------------------+\n| id                 |\u003c-------\u003e| author_id          |\u003c------\u003e| id                 |\n| name               |         | book_id            |        | title              |\n| created_at         |         |                    |        | description        |\n| updated_at         |         +--------------------+        | quantity           |\n| deleted_at         |                                       | rating             |\n+--------------------+                                       | publish_at         |\n                                                             | created_at         |\n                                                             | updated_at         |\n                                                             | deleted_at         |\n                                                             +--------------------+\n                                                                       |\n                                                                       |\n                                                                       |\n                                                             +---------v---------+\n                                                             |   borrower_books   |\n+--------------------+                                       +--------------------+\n|     borrowers      |                                       | id                 |\n+--------------------+                                       | borrower_id        |\n| id                 |\u003c-------------------------------------\u003e| book_id            |\n| name               |                                       | borrowed_at        |\n| address            |                                       | returned_at        |\n| tel_number         |                                       | due_date           |\n| birth_date         |                                       | status             |\n| created_at         |                                       | quantity           |\n| updated_at         |                                       | created_at         |\n| deleted_at         |                                       | updated_at         |\n+--------------------+                                       | deleted_at         |\n                                                             +--------------------+\n```\n\n## Technologies Used\n\n- **Go**: Primary programming language for the backend.\n- **GORM**: Object-Relational Mapping (ORM) library for Go.\n- **gqlgen**: Library for generating GraphQL server code in Go.\n\n## Getting Started\n\n### Prerequisites\n\n| Requirement                                                | Version       |\n|------------------------------------------------------------|---------------|\n| [Docker Compose](https://docs.docker.com/compose/install/) | Latest        |\n\n### Installation\n\n1. **Clone the repository**:\n    ```sh\n    git clone https://github.com/thanhhaudev/go-graphql.git\n    cd go-graphql\n    ```\n\n2. **Build and start the Docker containers**:\n    ```sh\n    make build\n    make run\n    ```\n\n3. **Migrate the database schema**:\n    ```sh\n    make migrate\n    ```\n\n4. **Seed the database with sample data**:\n    ```sh\n    make seed\n    ```\n\n### Running the Application\n\n1. Ensure the Docker containers are running:\n    ```sh\n    make run \u0026\u0026 make logs\n    ```\n\n2. Access the GraphQL playground at `http://localhost:8080/`.\n\n3. To stop the Docker containers:\n    ```sh\n    make stop\n    ```\n\n## Usage Examples\n\n### GraphQL Queries and Mutations\n- **Get all Books**:\n    ```graphql\n    query {\n        books {\n            id\n            title\n            authors {\n                id\n                name\n            }\n        }\n    }\n    ```\n\n- **Get a Book by ID**:\n    ```graphql\n    query {\n        book(id: 1) {\n            id\n            title\n            authors {\n                id\n                name\n            }\n        }\n    }\n    ```\n\n- **Get all Authors**:\n    ```graphql\n    query {\n        authors {\n            id\n            name\n            books {\n                id\n                title\n            }\n        }\n    }\n    ```\n\n- **Get all Borrowers**:\n    ```graphql\n    query {\n        borrowers {\n            id\n            name\n            books {\n                id\n                title\n            }\n        }\n    }\n    ```\n\n- **Create a Book**:\n    ```graphql\n    mutation {\n        createBook(\n            input: {title: \"Title\", authorIds: [1, 2], publishAt: \"2024-09-30T07:00:00.000Z\", quantity: 100, rating: 4.2}\n        ) {\n            id\n            title\n            createdAt\n        }\n    }\n    ```\n\n- **Borrow a Book**:\n    ```graphql\n    mutation {\n        borrowBook(\n            input: {bookId: 1, borrowerId: 1, quantity: 5, dueDate: \"2024-09-30T07:00:00.000Z\"}\n        ) {\n            name\n            books {\n                title\n            }\n        }\n    }\n    ```\n\n- **Return a Book**:\n    ```graphql\n    mutation {\n        returnBook(input: {bookId: 2, borrowerId: 1}) {\n            name\n            books {\n                id\n                title\n            }\n        }\n    }\n    ```\n\n## Contributing\n\nContributions are welcome! To contribute:\n1. Fork the repository.\n2. Create a new branch for your feature or bug fix.\n3. Make your changes and test them.\n4. Submit a pull request.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthanhhaudev%2Fgo-graphql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthanhhaudev%2Fgo-graphql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthanhhaudev%2Fgo-graphql/lists"}