Giter Site home page Giter Site logo

huzaifamk / go-clean-arch-project-1 Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 23.11 MB

One of my first self-made practice project following "Uncle Bob" Martin's Clean Architecture principles. I also did database integration with MySQL, the only thing left is frontend which is a future goal!

License: GNU General Public License v3.0

Go 100.00%

go-clean-arch-project-1's Introduction

Golang Clean Architecture Sample Project

This project is still in development, and I will add more features in the future. It is made by following CLean Architecture rules by Uncle Bob, and I also added some of my own rules to make it more readable and maintainable. This is written in Golang, and I used Echo Framework as the web framework, and MySQL as the database. I also added some middlewares to make it more secure and more readable. I also added some unit tests to make sure that the code is working as expected.

How to run

  1. Clone this repository
  2. Create a database named books.sql in your MySQL database [Name is changeable]
  3. Import the books.sql file in the database
  4. Change the database configuration in config.json file
  5. Run the project using go run main.go or refer to Makefile for more commands

API Documentation

Get All Books

Request

GET /books

curl -i -H 'Accept: application/json' http://localhost:8080/books

Response

    HTTP/1.1 200 OK
    Date: Sun, 20 Jun 2021 15:00:00 GMT
    Content-Type: application/json
    Content-Length: 2
    
        [
            {
                "id": 1,
                "title": "Book Title",
                "author": "Book Author"
            }
        ]

Get Book by ID

Request

GET /books/:id

curl -i -H 'Accept: application/json' http://localhost:8080/books/1

Response

HTTP/1.1 200 OK
Date: Sun, 20 Jun 2021 15:00:00 GMT
Content-Type: application/json
Content-Length: 2

[]

Create a Book

Request

POST /books

curl -i -H 'Accept: application/json' -d 'title=Book Title&author=Book Author' http://localhost:8080/books

Response

    HTTP/1.1 201 Created
    Date: Sun, 20 Jun 2021 15:00:00 GMT
    Content-Type: application/json
    Content-Length: 2

    [
        {
            "id": 1,
            "title": "Book Title",
            "author": "Book Author"
        }
    ]

Update a Book

Request

PUT /books/:id

curl -i -H 'Accept: application/json' -d 'title=Book Title&author=Book Author' http://localhost:8080/books/1

Response

    HTTP/1.1 200 OK
    Date: Sun, 20 Jun 2021 15:00:00 GMT
    Content-Type: application/json
    Content-Length: 2

    [
        {
            "id": 1,
            "title": "Book Title",
            "author": "Book Author"
        }
    ]

Delete a Book

Request

DELETE /books/:id

curl -i -H 'Accept: application/json' -X DELETE http://localhost:8080/books/1

Response

    HTTP/1.1 204 No Content
    Date: Sun, 20 Jun 2021 15:00:00 GMT

License

MIT

Author

[Huzaifa M.]

go-clean-arch-project-1's People

Contributors

hmkxe avatar huzaifamk avatar

Stargazers

 avatar  avatar

Watchers

 avatar

go-clean-arch-project-1's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.