Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# frontend
VITE_API_URL=
VITE_SENTRY_DSN=
SENTRY_AUTH_TOKEN=
SENTRY_ORG=
SENTRY_PROJECT=

# backend
POSTGRES_USER=
POSTGRES_PASSWORD=
POSTGRES_DB=
POSTGRES_PORT=
BETTER_AUTH_URL=
BETTER_AUTH_SECRET=
DISCORD_CLIENT_ID=
DISCORD_CLIENT_SECRET=
10 changes: 10 additions & 0 deletions .github/workflows/deploy-backend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ jobs:
- name: Inject hyperdrive id
run: |
sed -i 's|"id": ""|"id": "${{ secrets.CLOUDFLARE_HYPERDRIVE_ID }}"|' ./products/backend/wrangler.jsonc
# Inject BetterAuth url and secret in ./products/backend/wrangler.toml
- name: Inject BetterAuth url and secret
run: |
sed -i 's|"BETTER_AUTH_URL": "dummy"|"BETTER_AUTH_URL": "${{ secrets.BETTER_AUTH_URL }}"|' ./products/backend/wrangler.jsonc
sed -i 's|"BETTER_AUTH_SECRET": "dummy"|"BETTER_AUTH_SECRET": "${{ secrets.BETTER_AUTH_SECRET }}"|' ./products/backend/wrangler.jsonc
# Inject Discord client id and secret in ./products/backend/wrangler.toml
- name: Inject Discord client id and secret
run: |
sed -i 's|"DISCORD_CLIENT_ID": "dummy"|"DISCORD_CLIENT_ID": "${{ secrets.DISCORD_CLIENT_ID }}"|' ./products/backend/wrangler.jsonc
sed -i 's|"DISCORD_CLIENT_SECRET": "dummy"|"DISCORD_CLIENT_SECRET": "${{ secrets.DISCORD_CLIENT_SECRET }}"|' ./products/backend/wrangler.jsonc
# Build & Deploy Backend to Cloudflare Workers
- name: Build & Deploy Backend to Cloudflare Workers
uses: cloudflare/wrangler-action@v3
Expand Down
4 changes: 0 additions & 4 deletions .github/workflows/deploy-frontend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,6 @@ jobs:
- name: Build
env:
VITE_API_URL: ${{ secrets.VITE_API_URL }}
VITE_SENTRY_DSN: ${{ secrets.VITE_SENTRY_DSN }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
run: nix develop --command bash -c "pnpm i && pnpm run build"
# Deploy Frontend to Cloudflare Workers
- name: Deploy Frontend to Cloudflare Workers
Expand Down
37 changes: 0 additions & 37 deletions .github/workflows/deploy-notify.yaml

This file was deleted.

4 changes: 0 additions & 4 deletions .github/workflows/preview-frontend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ jobs:
id: build
env:
VITE_API_URL: ${{ secrets.VITE_API_URL }}
VITE_SENTRY_DSN: ${{ secrets.VITE_SENTRY_DSN }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
run: nix develop --command bash -c "pnpm i && pnpm run frontend:build"
# Deploy Preview to Cloudflare Workers
# Ref: https://zenn.dev/lalalatotoro/articles/b8fa632b53d332
Expand Down
44 changes: 44 additions & 0 deletions AI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
以下のような、特定のグループで発生する、まとめ払いによる借金の管理を行うアプリケーションを作成しようと考えている。このアプリでは、ユーザ2人の関係にしか着目しないので、グループを越えて、何円返すべきか (または、何円返してもらうべきか) を表示したいと考えている。
(例)
- user
- α
- β
- γ
- group
- A
- B

groupAにおいて
α -100円借りる-> β
β -200円借りる-> γ

groupBにおいて
β -100円借りる-> α
β -200円借りる-> γ

αの表示
- β: 0円
- γ: 0円

βの表示
- α: 0円
- γ: -400円

γの表示
- α: 0円
- β: +400円

要件は以下の通りです。
1. ユーザは複数のグループに所属できる。
2. 各グループ内での借金情報を記録できる。
3. ユーザ同士の借金情報をグループを越えて集計できる。
4. 各ユーザの画面で、他のユーザに対する借金情報を表示できる。
5. グループ内での借金情報の追加、編集、削除ができる。
6. グループ内での借金情報の削除は論理削除で、削除した人、削除日時も記録する。
7. better authを利用するため、better authのUser TableがこのアプリのUser Tableとして機能する。
8. データベースはPostgreSQL、ORMはdrizzleを使用する。
9. フロントエンドは Vite + React + @tanstack/react-query、バックエンドはhonoで実装する。
10. APIはRESTfulに設計する。
11. 各APIの型は、openapi.jsonを共有することで達成している。特にフロントエンドは、opeanapi-react-queryで生成したコードを利用する。

現状の実証状況と、このレポジトリ内の各READMEにある設計指針を確認した上で、適切なDB構造を提案してください。
62 changes: 9 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ sudo docker compose up -d
4. 以下のコマンドを実行

```sh
pnpm i && pnpm run setup:generate && pnpm run backend:generate && pnpm run backend:migrate
pnpm i && pnpm run setup:generate && pnpm run backend:drizzle:generate && pnpm run backend:migrate
```

## docker-compose の操作 (基本操作のみ掲載)
Expand Down Expand Up @@ -191,18 +191,6 @@ pnpm run backend:migrate
#### [Coverage Report](https://pay-crew.github.io/pay-crew2/coverage/validator/)
- https://pay-crew.github.io/pay-crew2/coverage/validator/

### Notify (products/notify)

- TypeScript
- Cloudflare Workers
- Discord Webhook

#### [Source Code](https://github.com/Pay-Crew/pay-crew2/tree/dev/products/notify/)
- https://github.com/Pay-Crew/pay-crew2/tree/dev/products/notify/

#### [Details](https://github.com/Pay-Crew/pay-crew2/tree/dev/products/notify/README.md)
- https://github.com/Pay-Crew/pay-crew2/tree/dev/products/notify/README.md

### Database

- development
Expand Down Expand Up @@ -263,12 +251,8 @@ graph LR;
db[("Database (PostgreSQL)")]
drizzle["Drizzle (ORM)"]
hono["Hono (Web API)"]
discord["Discord Webhook"]
slack["Slack Webhook"]
frontend["Vite + React"]
idp{{"Identity Provider (Google, GitHub, etc.)"}}
server(["Server (Discord)"])
workspace(["Workspace (Slack)"])
user["User"]

subgraph "Docker"
Expand All @@ -279,27 +263,15 @@ graph LR;
drizzle
drizzle <--> hono
end
subgraph "Notify (Localhost)"
discord
slack
end
hono --> discord
discord --fetch--> hono
hono --> slack
slack --fetch--> hono
hono <--> frontend
hono <--with session--> frontend
subgraph "Frontend (Localhost)"
frontend
end
idp <-.authentication.-> user
idp <--check token--> hono
idp --.add authentication info.--> hono
frontend -.redirect.-> idp
user <--with token--> frontend
user -.without token.-> frontend
discord --notification--> server
slack --notification--> workspace
server --notification--> user
workspace --notification--> user
user <--with session--> frontend
user -.without session.-> frontend
```

## システム構成図 ~ 本番環境 ~
Expand All @@ -310,12 +282,8 @@ graph LR;
hyperdrive(("Hyperdrive"))
drizzle["Drizzle (ORM)"]
hono["Hono (Web API)"]
discord["Discord Webhook"]
slack["Slack Webhook"]
frontend["Vite + React"]
idp{{"Identity Provider (Google, GitHub, etc.)"}}
server(["Server (Discord)"])
workspace(["Workspace (Slack)"])
user["User"]

db <--> hyperdrive
Expand All @@ -324,27 +292,15 @@ graph LR;
drizzle
drizzle <--> hono
end
subgraph "Notify (Cloudflare Workers)"
discord
slack
end
hono --> discord
discord --polling--> hono
hono --> slack
slack --polling--> hono
hono <--> frontend
hono <--with session--> frontend
subgraph "Frontend (Cloudflare Workers)"
frontend
end
idp <-.authentication.-> user
idp <--check token--> hono
idp --.add authentication info.--> hono
frontend -.redirect.-> idp
user <--with token--> frontend
user -.without token.-> frontend
discord --notification--> server
slack --notification--> workspace
server --notification--> user
workspace --notification--> user
user <--with session--> frontend
user -.without session.-> frontend
```

## ER図
Expand Down
4 changes: 4 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
openssl
cacert
];
shellHook = ''
export NIX_SSL_CERT_FILE="${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"
export SSL_CERT_FILE="$NIX_SSL_CERT_FILE"
'';
};
}
);
Expand Down
11 changes: 4 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@
"coverage": "turbo run coverage",
"backend:dev": "pnpm -C products/backend dev",
"backend:wrangler": "pnpm -C products/backend wrangler",
"backend:generate": "pnpm -C products/backend generate",
"backend:drizzle:generate": "pnpm -C products/backend drizzle:generate",
"backend:better-auth:generate": "pnpm -C products/backend better-auth:generate",
"backend:migrate": "pnpm -C products/backend migrate",
"backend:openapi": "pnpm -C products/backend openapi",
"backend:studio": "pnpm -C products/backend studio",
"backend:test": "pnpm -C products/backend test",
"backend:coverage": "pnpm -C products/backend coverage",
"backend:ui": "pnpm -C products/backend ui",
"frontend:dev": "pnpm -C products/frontend dev",
"frontend:wrangler": "pnpm -C products/notify wrangler",
"frontend:wrangler": "pnpm -C products/frontend wrangler",
"frontend:build": "pnpm -C products/frontend build",
"frontend:preview": "pnpm -C products/frontend preview",
"frontend:openapi": "pnpm -C products/frontend openapi",
Expand All @@ -27,8 +28,6 @@
"frontend:coverage": "pnpm -C products/frontend coverage",
"frontend:ui": "pnpm -C products/frontend ui",
"frontend:lint": "pnpm -C products/frontend lint",
"notify:dev": "pnpm -C products/notify dev",
"notify:wrangler": "pnpm -C products/notify wrangler",
"validator:test": "pnpm -C packages/validator test",
"validator:coverage": "pnpm -C packages/validator coverage",
"validator:ui": "pnpm -C packages/validator ui",
Expand Down Expand Up @@ -78,15 +77,12 @@
},
"devDependencies": {
"@astrojs/check": "catalog:docs",
"@cloudflare/vitest-pool-workers": "catalog:notify",
"@cloudflare/workers-types": "catalog:backend",
"@eslint/js": "catalog:frontend",
"@hono/zod-openapi": "catalog:backend",
"@hookform/error-message": "catalog:frontend",
"@hookform/resolvers": "catalog:frontend",
"@scalar/hono-api-reference": "catalog:backend",
"@sentry/react": "catalog:frontend",
"@sentry/vite-plugin": "catalog:frontend",
"@tanstack/react-query": "^5.90.5",
"@types/pg": "catalog:backend",
"@types/react": "catalog:frontend",
Expand All @@ -95,6 +91,7 @@
"@vitest/coverage-v8": "catalog:",
"@vitest/ui": "catalog:",
"astro": "catalog:docs",
"better-auth": "catalog:",
"dotenv": "catalog:setup",
"dotenv-caster": "catalog:setup",
"drizzle-kit": "catalog:backend",
Expand Down
Loading