-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from kstm-su/feat/add-docs
ドキュメントの充実
- Loading branch information
Showing
34 changed files
with
508 additions
and
150 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Backend Lint | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
paths: | ||
- 'member-portal-backend/**' | ||
|
||
permissions: | ||
statuses: write | ||
contents: read | ||
pull-requests: write | ||
|
||
|
||
jobs: | ||
golangci: | ||
name: lint | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Set commit status as pending | ||
uses: myrotvorets/set-commit-status-action@master | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
status: pending | ||
context: Check pull request (Backend) | ||
|
||
- uses: actions/checkout@v4 | ||
|
||
- uses: actions/setup-go@v5 | ||
with: | ||
go-version: stable | ||
|
||
- name: golangci-lint | ||
uses: golangci/golangci-lint-action@v6 | ||
with: | ||
working-directory: member-portal-backend | ||
version: v1.60 | ||
|
||
- name: Set final commit status | ||
uses: myrotvorets/set-commit-status-action@master | ||
if: always() | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
status: ${{ job.status }} | ||
context: Check pull request (Backend) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,7 @@ | |
docs/docs/swagger | ||
docs/site | ||
|
||
.idea | ||
.idea | ||
|
||
member-portal-backend/app/** | ||
member-portal-backend/app-local/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# コンフィグの設定について | ||
|
||
```yaml | ||
database: | ||
type: sqlite | ||
sqlite: | ||
path: /app/data/db.sqlite3 | ||
file: | ||
base: /app/data | ||
jwt: | ||
issuer: localhost | ||
key: | ||
private_key: private.pem | ||
public_key: public.pem | ||
key_id: key | ||
realm: localhost | ||
password: | ||
algorithm: argon2 | ||
pepper: <random_pepper> #自動で生成されるため、設定不要 | ||
server: | ||
host: localhost | ||
port: 8080 | ||
``` | ||
## database | ||
postgresqlを利用する場合、以下のように設定を変更してください。 | ||
```yaml | ||
database: | ||
type: postgres | ||
postgres: | ||
host: db | ||
port: 5432 | ||
user: <user> | ||
password: <password> | ||
``` | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# 実装機能 | ||
|
||
- [x] OAuth2認可 | ||
- [x] 認可コード取得 | ||
- [x] アクセストークン取得 | ||
- [x] リフレッシュトークン取得 | ||
- [ ] トークン削除 | ||
- [ ] トークン情報取得 | ||
- [ ] トークン有効性確認 | ||
- [ ] クライアント作成 | ||
- [ ] OpenID Connect認証 | ||
- [x] クライアント情報取得 | ||
- [ ] ユーザー情報取得 | ||
- [ ] ユーザー情報更新 | ||
- [ ] ユーザー情報取得API | ||
- [x] プロフィール取得(OIDC クライアント情報取得と同一) | ||
- [ ] ユーザー情報更新 | ||
- [ ] 新規ユーザー登録 | ||
- [ ] ユーザーリスト取得 | ||
- [ ] お知らせ取得 | ||
- [ ] お知らせ更新 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# バックエンドについて | ||
|
||
## バックエンドの概要 | ||
|
||
バックエンドはGo言語で実装されています。 | ||
OAuth2およびOpenID Connectを使用して認可・認証を行い、ユーザー情報を渡すAPIを提供します。 | ||
|
||
## 起動方法 | ||
|
||
### Dockerでの起動方法 | ||
#### Localでビルドする場合 | ||
|
||
1. Dockerfileのあるディレクトリに移動 | ||
2. `docker build -t <image_name> .` を実行(image_nameは自由に設定) | ||
3. `docker run -p 3001:8080 -d <image_name>` を実行 | ||
4. `http://localhost:3001` にアクセス | ||
|
||
#### GitHub container registryからpullする場合 | ||
1. `docker pull ghcr.io/kstm-su/member-portal/backend:latest` を実行 | ||
2. `docker run -p 3001:8080 -d ghcr.io/kstm-su/member-portal/backend:latest` を実行 | ||
3. `http://localhost:3001` にアクセス | ||
|
||
### Goでローカルで起動する場合 | ||
1. `cd member-portal-backend` でディレクトリに移動 | ||
2. `go run main.go` を実行 | ||
3. `http://localhost:8080` にアクセス | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# 技術スタック | ||
|
||
## 採用ライブラリ | ||
|
||
Web framework: [echo](https://echo.labstack.com/) <br> | ||
採用理由: openapi-generatorを利用することを想定し、親和性の高いechoを採用。 | ||
|
||
ORM: [gorm](https://gorm.io/) <br> | ||
採用理由: GitHubのスター数が多く、開発者が多いため。 | ||
|
||
Command line tool: [cobra](https://cobra.dev/) <br> | ||
採用理由: サブコマンドの実装が容易であるため また、k8sでも採用されているため、 | ||
|
||
Config: [viper](https://github.com/spf13/viper) <br> | ||
採用理由: cli toolとして採用した、cobraとの親和性が高いため、 | ||
|
||
## 依存ソフトウェア | ||
|
||
Language: [Go](https://golang.org/) <br> | ||
採用理由: 本プロジェクトの言語として採用。 | ||
|
||
Linter & Formatter: [golangci-lint](https://golangci-lint.run/) <br> | ||
採用理由: GitHubのスター数が多く、開発者が多いため。また、複数のlinterを統合しているため。 | ||
|
||
Database: [PostgreSQL](https://www.postgresql.org/) [Optional]<br> | ||
採用理由: 慣習的に利用されるため。 また、ORMのgormが対応しているため。 (ConfigでSQLite3を利用することも可能) | ||
|
||
Secret Manager(検討中): [Hashicorp Vault](https://www.vaultproject.io/) <br> | ||
採用理由: シークレット管理のため<br> | ||
利用場面: パスワードハッシュ化時のpepperの管理および、OAuth2クライアントのシークレット管理の際に利用のため。<br> | ||
その他の候補: [Cyber Ark conjur](https://www.conjur.org/), [Infisical](https://infisical.com/) | ||
|
||
Object storage: [MinIO](https://min.io/) [Optional]<br> | ||
採用理由: S3互換のため。 | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# 当ドキュメントについて | ||
|
||
このドキュメントは、[MkDocs-material](https://squidfunk.github.io/mkdocs-material/)を使用して作成されました。 | ||
|
||
## 目的 | ||
|
||
今後の開発の参入障壁を低くするために、どのような技術スタックを利用し、何を目的としているかを示すため。 | ||
|
||
## 編集するには | ||
`docs/docs`にドキュメントの本体が配置されているため、そちらを編集してください。<br> | ||
また、新たにファイルを追加する場合は、`mkdocs.yml`にある`nav`に追加してください。 | ||
|
||
## 表示方法 | ||
|
||
### ローカルでの表示 | ||
|
||
以下のコマンドを実行することで、ローカルでの表示が可能です。 | ||
|
||
#### 事前準備 | ||
|
||
```bash | ||
pip install mkdocs-material | ||
``` | ||
|
||
#### Linux | ||
|
||
```bash | ||
cd docs | ||
./start.sh | ||
``` | ||
|
||
#### Windows | ||
|
||
`docs/docs`に`swagger`をコピーしたのち、以下のコマンドを実行してください。 | ||
|
||
```bash | ||
cd docs | ||
mkdocs serve | ||
``` | ||
|
||
### GitHub Pagesでの表示 | ||
|
||
GitHub Pagesでの表示は、[こちら](https://kstm-su.github.io/member-portal/)からご覧いただけます。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# APIドキュメントについて | ||
|
||
## 目的 | ||
OpenAPIを利用してAPIドキュメントを作成することで、フロントエンドとバックエンドの実装を隠蔽し、APIの定義をインターフェースとして利用することにより、開発効率を向上させる。 | ||
|
||
## 仕様 | ||
- OpenAPI 3.0.0 | ||
- ファイル形式: YAML | ||
- ファイル名: documentation.yaml | ||
- ファイルの配置場所: /swagger | ||
|
||
## ファイル構成 | ||
`/components`: OpenAPIのコンポーネントを定義する <br> | ||
`/paths`: APIのエンドポイントを定義する <br> | ||
`documentation.yaml`: OpenAPIの定義を記述するファイル | ||
|
||
## APIドキュメントの確認方法 | ||
### Github Pagesで確認する方法 | ||
masterブランチのAPIドキュメントについては[こちら](/member-portal/redoc/index.html)で確認できます。 | ||
|
||
### ローカルで確認する方法 | ||
1. `cd swagger`で`swagger`ディレクトリに移動します | ||
2. `npx @redocly/cli preview-docs documentation.yml`を実行します | ||
3. `http://localhost:8080/`にアクセス |
Oops, something went wrong.