๐Ÿ“ฆ sglkc / 01-monorepo

๐Ÿ“„ README.md ยท 132 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132<div align="center">
  <h1>Zero One News API</h1>
</div>

## About

Zero One Group News API made using Go, Echo, PostgreSQL, and documented by Swagger.

## Documentation

For generated Swagger JSON and additional documentations, see `/docs` directory.

<details>
  <summary>Entity Relationship Diagram</summary>

  ![ERD](docs/erd.png?raw=true)

</details>

<details>
  <summary>Swagger</summary>

  ![Screenshot](docs/swagger.png?raw=true)

</details>

<details>
  <summary>Endpoints</summary>

  ```mermaid
flowchart TD
    Root["/api"] --> Version["/v1"]
    Version --> Articles["/articles"] & Topics["/topics"]
    Topics --> TopicsGet["GET"] & TopicsPost["POST"] & TopicId["/:topic_id"]
    TopicId --> TopicIdGet["GET"] & TopicIdPatch["PUT"] & TopicIdDelete["DELETE"] & TopicArticles["/articles"]
    TopicArticles --> TopicArticlesGet["GET"]
    Articles --> ArticlesGet["GET"] & ArticlesPost["POST"] & ArticleId["/:article_id"]
    ArticleId --> ArticleIdGet["GET"] & ArticleIdPatch["PUT"] & ArticleIdDelete["DELETE"] & ArticleTopics["/topics"]
    ArticleTopics --> ArticleTopicsGet["GET"] & ArticleTopicsPut["PUT"] & ArticleTopicsId["/:topic_id"]
    ArticleTopicsId --> ArticleTopicsIdPost["POST"] & ArticleTopicsIdDelete["DELETE"]

     Root:::Sky
     Root:::Aqua
     Version:::Sky
     Version:::Aqua
     Articles:::Aqua
     Articles:::Sky
     Topics:::Aqua
     Topics:::Sky
     TopicId:::Rose
     TopicArticles:::Peach
     ArticleId:::Rose
     ArticleTopics:::Peach
     ArticleTopicsId:::Ash
    classDef Aqua stroke-width:1px, stroke-dasharray:none, stroke:#46EDC8, fill:#DEFFF8, color:#378E7A
    classDef Sky stroke-width:1px, stroke-dasharray:none, stroke:#374D7C, fill:#E2EBFF, color:#374D7C
    classDef Rose stroke-width:1px, stroke-dasharray:none, stroke:#FF5978, fill:#FFDFE5, color:#8E2236
    classDef Peach stroke-width:1px, stroke-dasharray:none, stroke:#FBB35A, fill:#FFEFDB, color:#8F632D
    classDef Ash stroke-width:1px, stroke-dasharray:none, stroke:#999999, fill:#EEEEEE, color:#000000
  ```

</details>

## Prerequisites

- PostgreSQL
- Docker
- Moon
- Go
- pnpm

## Development

1. Clone the repository

```sh
git clone https://github.com/sglkc/01-monorepo.git
cd 01-monorepo
```

2. Install dependencies with pnpm

```sh
pnpm install
```

5. Copy and set environment variables

```sh
cp .env.example .env
```

3. Run local development server

```sh
pnpm compose:up       # Start local development server
pnpm compose:down     # Stop local development server
pnpm compose:cleanup  # Remove all local development server data
```

4. Install Go dependencies

```sh
moon run tidy
```

5. Migrate database

```sh
moon zog-news:migration-up
```

6. Run on development mode

```sh
moon zog-news:dev
```

7. Open documentation endpoint at `/swagger/index.html`

## Testing

```sh
moon zog-news:test
```

## Building

```sh
moon zog-news:build
```