Skip to content

Commit

Permalink
Copy from 2023
Browse files Browse the repository at this point in the history
  • Loading branch information
cocodrips committed Aug 23, 2023
1 parent 78cf69c commit 30fbc0b
Show file tree
Hide file tree
Showing 28 changed files with 390 additions and 242 deletions.
25 changes: 14 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Build@Mercari Training Program 2022
# Build@Mercari Training Program 2023

This is @<your github id>'s build training repository.

Expand All @@ -23,16 +23,19 @@ The following icons indicate pointers for

## Tasks

- [ ] **STEP1** Git ([JA](document/step1.ja.md)/[EN](document/step1.en.md))
- [ ] **STEP2** Setup environment ([JA](document/step2.ja.md)
/[EN](document/step2.en.md))
- [ ] **STEP3** Develop API ([JA](document/step3.ja.md)
/[EN](document/step3.en.md))
- [ ] **STEP4** Docker ([JA](document/step4.ja.md)/[EN](document/step4.en.md))
- [ ] **STEP5** (Stretch) Frontend ([JA](document/step5.ja.md)
/[EN](document/step5.en.md))
- [ ] **STEP6** (Stretch) Run on docker-compose ([JA](document/step6.ja.md)
/[EN](document/step6.en.md))
- [ ] **STEP1** Git ([JA](document/01-git.ja.md)/[EN](document/01-git.en.md))
- [ ] **STEP2** Setup environment ([JA](document/02-local-env.ja.md)
/[EN](document/02-local-env.en.md))
- [ ] **STEP3** Develop API ([JA](document/03-api.ja.md)
/[EN](document/03-api.en.md))
- [ ] **STEP4** Database ([JA](document/04-database.ja.md)/[EN](document/04-database.en.md))
- [ ] **STEP5** Docker ([JA](document/05-docker.ja.md)/[EN](document/05-docker.en.md))
- [ ] **STEP6** Continuous Integration(CI) ([JA](document/06-ci.ja.md)
/[EN](document/06-ci.en.md))
- [ ] **STEP7** (Stretch) Frontend ([JA](document/07-frontend.ja.md)
/[EN](document/07-frontend.en.md))
- [ ] **STEP8** (Stretch) Run on docker-compose ([JA](document/08-docker-compose.ja.md)
/[EN](document/08-docker-compose.en.md))

### Other documents

Expand Down
Binary file added data/workflow-enable.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 16 additions & 11 deletions document/step1.en.md → document/01-git.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,19 @@
In this step, we will learn how to use Git and Github.

**:book: Reference**
* [Git basics](https://www.atlassian.com/git)
* [GitHub Ultimate: Master Git and GitHub - Beginner to Expert](https://www.udemy.com/course/github-ultimate/)

* (JA)[Gitを使ったバージョン管理](https://backlog.com/ja/git-tutorial/intro/01/)
* (JA)[Udemy Business - Git:はじめてのGitとGitHub](https://mercari.udemy.com/course/intro_git/)

## Fork this **mercari-build-training-2022** repository
* (EN)[Git basics](https://www.atlassian.com/git)
* (EN)[Udemy Business - GitHub Ultimate: Master Git and GitHub - Beginner to Expert](https://mercari.udemy.com/course/github-ultimate/)

* Fork [mercari-build-training-2022](https://github.com/mercari-build/mercari-build-training-2022)
* You will see be able to see `https://github.com/<your github id>/mercari-build-training-2022` if successful.


## Fork this **mercari-build-training-2023** repository

* Fork [mercari-build-training-2023](https://github.com/mercari-build/mercari-build-training-2023)
* You will see be able to see `https://github.com/<your github id>/mercari-build-training-2023` if successful.


## Install Git
Expand All @@ -30,24 +35,24 @@ In this step, we will learn how to use Git and Github.

## Use basic commands in Git

1. **Clone** `https://github.com/<your github id>/mercari-build-training-2022` onto your local using the following command.
1. **Clone** `https://github.com/<your github id>/mercari-build-training-2023` onto your local using the following command.
```shell
$ cd <your working space>
$ git clone https://github.com/<your github id>/mercari-build-training-2022
$ git clone https://github.com/<your github id>/mercari-build-training-2023
```

**:bangbang: Caution**

Please definitely run the following command after cloning repository.
```
cd mercari-build-training-2022
cd mercari-build-training-2023
git config --local core.hooksPath .githooks/
```
This is required to use githooks in mercari-build-training-2022 repository.
This is required to use githooks in mercari-build-training-2023 repository.

2. Make a new branch named `first-pull-request` and **checkout** into this branch
```shell
$ cd <your working space>/mercari-build-training-2022
$ cd <your working space>/mercari-build-training-2023
$ git branch first-pull-request
$ git checkout first-pull-request
```
Expand Down Expand Up @@ -90,4 +95,4 @@ Check if you understand the following concepts.

### Next

[STEP2: Building local environmentSTEP2: Building local environment](step2.en.md)
[STEP2: Building local environment](02-local-env.en.md)
23 changes: 13 additions & 10 deletions document/step1.ja.md → document/01-git.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@
このステップではGitとGithubの使い方を学びます。

**:book: Reference**
* [Gitを使ったバージョン管理](https://backlog.com/ja/git-tutorial/intro/01/)
* [Udemy - Git & Github基礎講座](https://www.udemy.com/course/git-github-a/)

## **mercari-build-training-2022** リポジトリをフォークする
* (JA)[Gitを使ったバージョン管理](https://backlog.com/ja/git-tutorial/intro/01/)
* (JA)[Udemy Business - Git:はじめてのGitとGitHub](https://mercari.udemy.com/course/intro_git/)

* [mercari-build-training-2022](https://github.com/mercari-build/mercari-build-training-2022)
* (EN)[Git basics](https://www.atlassian.com/git)
* (EN)[Udemy Business - GitHub Ultimate: Master Git and GitHub - Beginner to Expert](https://mercari.udemy.com/course/github-ultimate/)
## **mercari-build-training-2023** リポジトリをフォークする

* [mercari-build-training-2023](https://github.com/mercari-build/mercari-build-training-2023)
をあなたのGithubにForkします。
* Forkに成功すると `https://github.com/<your github id>/mercari-build-training-2022`
* Forkに成功すると `https://github.com/<your github id>/mercari-build-training-2023`
というようなリポジトリができます。

## Gitをインストールする
Expand All @@ -30,25 +33,25 @@

## Gitの基本コマンドを使う

1. `https://github.com/<your github id>/mercari-build-training-2022`**clone**
1. `https://github.com/<your github id>/mercari-build-training-2023`**clone**
します。 cloneすると、github上のリポジトリを自分のローカルにDownloadできます。
```shell
$ cd <your working space>
$ git clone https://github.com/<your github id>/mercari-build-training-2022
$ git clone https://github.com/<your github id>/mercari-build-training-2023
```

**:bangbang: 注意**

cloneができたら必ず以下のコマンドを実行してください。
```shell
$ cd mercari-build-training-2022
$ cd mercari-build-training-2023
$ git config --local core.hooksPath .githooks/
```
これは mercari-build-training-2022 が githooks という機能を使うために必要なものです。

2. `first-pull-request`というブランチを作り、そのブランチに**checkout**します
```shell
$ cd <your working space>/mercari-build-training-2022
$ cd <your working space>/mercari-build-training-2023
$ git branch first-pull-request
$ git checkout first-pull-request
```
Expand Down Expand Up @@ -90,4 +93,4 @@ $ git config --local core.hooksPath .githooks/
---
### Next

[STEP2: 環境構築](step2.ja.md)
[STEP2: 環境構築](02-local-env.ja.md)
12 changes: 8 additions & 4 deletions document/step2.en.md → document/02-local-env.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ If the version does not correspond to the Python version you installed, double c

### 3. Install dependencies

In Go, dependent libraries are managed in a file called `go.mod`.
In Go, dependent libraries are managed in a file called `go.mod`.
You can install the dependencies by running the following command.

```shell
Expand Down Expand Up @@ -97,12 +97,16 @@ If successful, you can access the local host `http://127.0.0.1:9000` on our brow

The following resources are useful to dive deeper into building environments and Linux.

* [An Introduction to Linux Basics](https://www.digitalocean.com/community/tutorials/an-introduction-to-linux-basics)
* [Linux Mastery: Master the Linux Command Line in 11.5 Hours](https://www.udemy.com/course/linux-mastery/)
* (JA)[book - [試して理解]Linuxのしくみ ~実験と図解で学ぶOSとハードウェアの基礎知識](https://www.amazon.co.jp/dp/477419607X/ref=cm_sw_r_tw_dp_178K0A3YTGA97XRH318R)
* (JA)[Udemy Business - もう絶対に忘れない Linux コマンド【Linux 100本ノック+名前の由来+丁寧な解説で、長期記憶に焼き付けろ!](https://mercari.udemy.com/course/linux100test/)
* ↑わかりやすい講座だと思い貼ってますが、コマンドの暗記は特にしなくていいです

* (EN)[An Introduction to Linux Basics](https://www.digitalocean.com/community/tutorials/an-introduction-to-linux-basics)
* (EN)[Udemy Business - Linux Mastery: Master the Linux Command Line in 11.5 Hours](https://mercari.udemy.com/course/linux-mastery/)
* You do NOT have to memorize the commands!

---

### Next

[STEP3: Make a listing API](step3.en.md)
[STEP3: Make a listing API](03-api.en.md)
10 changes: 7 additions & 3 deletions document/step2.ja.md → document/02-local-env.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,15 @@ $ go run app/main.go

環境構築の仕方やlinuxについてさらにしっかり学ぶためには以下の教材がおすすめです。

* [book - [試して理解]Linuxのしくみ ~実験と図解で学ぶOSとハードウェアの基礎知識](https://www.amazon.co.jp/dp/477419607X/ref=cm_sw_r_tw_dp_178K0A3YTGA97XRH318R)
* [Udemy - もう絶対に忘れない Linux コマンド【Linux 100本ノック+名前の由来+丁寧な解説で、長期記憶に焼き付けろ!](https://www.udemy.com/course/linux100test/)
* (JA)[book - [試して理解]Linuxのしくみ ~実験と図解で学ぶOSとハードウェアの基礎知識](https://www.amazon.co.jp/dp/477419607X/ref=cm_sw_r_tw_dp_178K0A3YTGA97XRH318R)
* (JA)[Udemy Business - もう絶対に忘れない Linux コマンド【Linux 100本ノック+名前の由来+丁寧な解説で、長期記憶に焼き付けろ!](https://mercari.udemy.com/course/linux100test/)
* ↑わかりやすい講座だと思い貼ってますが、コマンドの暗記は特にしなくていいです

* (EN)[An Introduction to Linux Basics](https://www.digitalocean.com/community/tutorials/an-introduction-to-linux-basics)
* (EN)[Udemy Business - Linux Mastery: Master the Linux Command Line in 11.5 Hours](https://mercari.udemy.com/course/linux-mastery/)
* You do NOT have to memorize the commands!

---
### Next

[STEP3: 出品APIを作る](step3.ja.md)
[STEP3: 出品APIを作る](03-api.ja.md)
81 changes: 10 additions & 71 deletions document/step3.en.md → document/03-api.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

**:book: Reference**

* (JA) [Udemy -【基礎からわかる!】Webアプリケーションの仕組み](https://www.udemy.com/course/tobach_01_webapp_structure/)
* (JA) [Udemy Business - REST WebAPI サービス 設計](https://mercari.udemy.com/course/rest-webapi-development/)
* (JA) [HTTP レスポンスステータスコード](https://developer.mozilla.org/ja/docs/Web/HTTP/Status)
* (JA) [HTTP リクエストメソッド](https://developer.mozilla.org/ja/docs/Web/HTTP/Methods)
* (JA) [APIとは?意味やメリット、使い方を世界一わかりやすく解説](https://www.sejuku.net/blog/7087)

* (EN) [API and Web Service Introduction](https://www.udemy.com/course/api-and-web-service-introduction/)
* (EN) [Udemy Business - API and Web Service Introduction](https://mercari.udemy.com/course/api-and-web-service-introduction/)
* (EN) [HTTP response status codes](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status)
* (EN) [HTTP request methods](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods)

Expand Down Expand Up @@ -91,49 +91,13 @@ $ curl -X GET 'http://127.0.0.1:9000/items'
{"items": [{"name": "jacket", "category": "fashion"}, ...]}
```

## 4. Write into a database

In the previous step, we saved data into `items.json`. We will move this into a database.
We will use a database called **SQLite**.

**:book: Reference**

* (JA)[SQLite入門](https://www.dbonline.jp/sqlite/)
* (JA)[Udemy -【SQLiteで学ぶ】ゼロから始めるデータベースとSQL超入門](https://www.udemy.com/course/basic_database_sqlite/)
* (JA)[Udemy - はじめてのSQLserver データベース SQL未経験者〜初心者向けコース](https://www.udemy.com/course/sqlserver-for-beginner/)
* (EN)[https://www.sqlitetutorial.net/](https://www.sqlitetutorial.net/)
* (EN)[Udemy - Intro To SQLite Databases for Python Programming](https://www.udemy.com/course/using-sqlite3-databases-with-python/)

Install SQlite, and make a database file called `mercari.sqlite3`. Open this file and make a table called `items`. Define the items table as follows and save the schema into `db/items.db`.

* id: int (Identifier unique for each item)
* name: string (Name of the item)
* category: string (Category of the item)

Change the endpoints `GET /items` and `POST /items` such that items are saved into the database and can be returned based on GET request. Add `mercari.sqlite3` to your `.gitignore` such that it is not commited. `items.db` shoud be commited.

**:beginner: Points**

* What are the advantages of saving into a databse such as SQLite instead of saving into a single JSON file?

## 5. Search for an item

Make an endpoint to return a list of items that include a specified keyword called `GET /search`.

```shell
# Request a list of items containing string "jacket"
$ curl -X GET 'http://127.0.0.1:9000/search?keyword=jacket'
# Expected response for a list of items with name containing "jacket"
{"items": [{"name": "jacket", "category": "fashion"}, ...]}
```

## 6. Add an image to an item
## 4. Add an image to an item

Change the endpoints `GET /items` and `POST /items` such that items can have images while listing.

* Make a directory called `images`
* Hash the image using sha256, and save it with the name `<hash>.jpg`
* Modify items table such that the image file can be saved as a string
* Modify items such that the image file can be saved as a string

```shell
# POST the jpg file
Expand All @@ -144,21 +108,18 @@ curl -X POST \
-F 'image=@images/local_image.jpg'
```

```json
{"items": [{"name": "jacket", "category": "fashion", "image_filename": "510824dfd4caed183a7a7cc2be80f24a5f5048e15b3b5338556d5bbd3f7bc267.jpg"}, ...]}
```

Items table example:

| id | name | category | image_filename |
| :--- | :----- | :------- | :------------------------------------------------------------------- |
| 1 | jacket | fashion | 510824dfd4caed183a7a7cc2be80f24a5f5048e15b3b5338556d5bbd3f7bc267.jpg |
| 2 | ... | | |

**:beginner: Point**

* What is hashing?
* What other hashing functions are out there except for sha256?


## 7. Return item details
## 5. Return item details

Make an endpoint `GET /items/<item_id>` to return item details.

Expand All @@ -167,29 +128,7 @@ $ curl -X GET 'http://127.0.0.1:9000/items/1'
{"name": "jacket", "category": "fashion", "image": "..."}
```

## 8. (Optional) Move the category information to a separate table

Modify the database as follows. This allows changes in the category names and you will not have to change all categories in the items table when they do. Since `GET items` should still return the name of the category, join these two tables when returning responses.

**items table**

| id | name | category_id | image_filename |
| :--- | :----- | :---------- | :------------------------------------------------------------------- |
| 1 | jacket | 1 | 510824dfd4caed183a7a7cc2be80f24a5f5048e15b3b5338556d5bbd3f7bc267.jpg |
| 2 | ... | | |

**category table**

| id | name |
| :--- | :------ |
| 1 | fashion |
| ... | |

**:beginner: Points**
* What is database **normalization**?


## 9. (Optional) Understand Loggers
## 6. (Optional) Understand Loggers
Open `http://127.0.0.1:9000/image/no_image.jpg` on your browser.
This returns an image called `no image` but the debug log is not displayed on your console.
```
Expand All @@ -215,4 +154,4 @@ Check if you understand the following concepts.

### Next

[STEP4: Run the application in a virtual environment](step4.en.md)
[STEP4: Database](04-database.en.md)
Loading

0 comments on commit 30fbc0b

Please sign in to comment.