https://github.com/yudwig/echo-clean-api
A sample REST API based on clean architecture using GO framework echo.
https://github.com/yudwig/echo-clean-api
clean-architecture echo echo-framework go golang ishell
Last synced: 8 months ago
JSON representation
A sample REST API based on clean architecture using GO framework echo.
- Host: GitHub
- URL: https://github.com/yudwig/echo-clean-api
- Owner: yudwig
- License: mit
- Created: 2021-06-28T08:56:07.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2021-06-28T11:07:08.000Z (almost 5 years ago)
- Last Synced: 2025-02-17T11:14:37.308Z (over 1 year ago)
- Topics: clean-architecture, echo, echo-framework, go, golang, ishell
- Language: Go
- Homepage:
- Size: 60.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# echo-clean-api
A sample REST API based on clean architecture using GO framework echo.
## Features
echo-clean-api is demonstration of CRUD API for a simple user management system.
To test API also includes simple REPL CLI client tool.
## How to run
#### DB migration
By default, app uses local mysql DB which dns is "root@tcp(127.0.0.1:3306)/echo". So first, create database 'echo' before migration.
After that, run migration command.
```sh
go run main.go migrate
```
#### Run server
Run echo server on "localhost:8000" by this command.
```sh
go run main.go server
```
#### Run client shell
Run API client tool by this command.
```sh
go run main.go client
```
When started shell, command list are displayed as follows.
```sh
% go run main.go client
Client shell start.
Commands:
clear clear the screen
create create user. input: > create {name}
delete delete user. input: > delete {id}
exit exit the program
get get user list. input: > get
help display help
update update user name. input: > update {id} {name}
>>>
```
## Directory structure
The application has the following directory structure.
```
app
├── adapter
│ ├── controller
│ ├── interactor
│ ├── presenter
│ └── repository
├── core
│ ├── domain
│ │ └── entity
│ │ └── user
│ ├── presentation
│ │ └── response
│ └── usecase
└── driver
├── client
├── db
│ ├── mockdb
│ ├── rdb
│ └── seed
├── echo
│ ├── routes
│ └── server
└── log
```
Based on the clean architecture, it has the following dependency directions.
```
┌────────┐ ┌─────────┐ ┌────────┐
│ driver │ ───> │ adapter │ ───> │ core │
└────────┘ └─────────┘ └────────┘
```