Skip to content
Draft
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
39 changes: 39 additions & 0 deletions prompt-dojo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# dependencies
/node_modules
/.pnp
.pnp.*
.yarn/*
!.yarn/patches
!.yarn/plugins
!.yarn/releases
!.yarn/versions

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*
.pnpm-debug.log*

# env files
.env*.local

# database
/data/

# typescript
*.tsbuildinfo
next-env.d.ts
5 changes: 5 additions & 0 deletions prompt-dojo/AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
<!-- BEGIN:nextjs-agent-rules -->
# This is NOT the Next.js you know

This version has breaking changes — APIs, conventions, and file structure may all differ from your training data. Read the relevant guide in `node_modules/next/dist/docs/` before writing any code. Heed deprecation notices.
<!-- END:nextjs-agent-rules -->
1 change: 1 addition & 0 deletions prompt-dojo/CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@AGENTS.md
49 changes: 49 additions & 0 deletions prompt-dojo/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# syntax=docker/dockerfile:1

FROM node:20-bookworm-slim AS base
WORKDIR /app

FROM base AS deps
RUN apt-get update && apt-get install -y --no-install-recommends \
python3 make g++ \
&& rm -rf /var/lib/apt/lists/*
COPY package.json package-lock.json ./
RUN npm ci

FROM base AS builder
COPY --from=deps /app/node_modules ./node_modules
COPY . .
ENV NEXT_TELEMETRY_DISABLED=1
RUN npm run build

FROM base AS runner
ENV NODE_ENV=production
ENV NEXT_TELEMETRY_DISABLED=1
ENV PORT=3000
ENV HOSTNAME=0.0.0.0

RUN apt-get update && apt-get install -y --no-install-recommends \
libsqlite3-0 \
&& rm -rf /var/lib/apt/lists/*

RUN addgroup --system --gid 1001 nodejs \
&& adduser --system --uid 1001 --ingroup nodejs nextjs

RUN mkdir -p /app/data && chown -R nextjs:nodejs /app/data

COPY --from=builder /app/public ./public
COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./
COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static
COPY --from=deps --chown=nextjs:nodejs /app/node_modules/better-sqlite3 ./node_modules/better-sqlite3
COPY --from=deps --chown=nextjs:nodejs /app/node_modules/bindings ./node_modules/bindings
COPY --from=deps --chown=nextjs:nodejs /app/node_modules/file-uri-to-path ./node_modules/file-uri-to-path

USER nextjs
EXPOSE 3000

VOLUME ["/app/data"]

HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
CMD node -e "fetch('http://127.0.0.1:3000/api/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"

CMD ["node", "server.js"]
39 changes: 39 additions & 0 deletions prompt-dojo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# プロンプ道場

プロンプトを書いて、自動構造チェック・LLM評価・みんなの星評価でスキルアップする公開Webサービス。

## 機能(Phase 3 まで)

- 課題へのプロンプト投稿・自動採点・LLM採点
- 星評価・コメント(返信スレッド)・通報
- ユーザー課題投稿(承認制)・AI課題生成
- Google / GitHub / Apple OAuth・メール会員登録
- Webプッシュ通知
- ランキング・履歴・管理画面・広告枠

## 開発

```bash
npm install
npm run dev
```

## 環境変数(主要)

| 変数 | 説明 |
|------|------|
| `ADMIN_PASSWORD` | 管理画面パスワード |
| `AUTH_SECRET` | NextAuth シークレット |
| `OPENAI_API_KEY` | LLM採点・課題生成 |
| `GITHUB_CLIENT_ID` / `SECRET` | GitHub OAuth |
| `VAPID_PUBLIC_KEY` / `PRIVATE_KEY` | Webプッシュ |

詳細は [REQUIREMENTS.md](./REQUIREMENTS.md)

## 本番

```bash
npm run build && npm run start:prod
```

Render: [`render.yaml`](./render.yaml)
54 changes: 54 additions & 0 deletions prompt-dojo/REQUIREMENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# プロンプ道場 要件定義 v8.0

## 概要

プロンプトを書いて、自動構造チェック・LLM評価・コミュニティの星評価でスキルアップする公開Webサービス。

## 確定事項(Phase 1〜8)

| 項目 | 内容 |
|------|------|
| サイト名 | **プロンプ道場** / Prompt Dojo |
| 評価方式 | ルールベース + LLM + 星評価 + コメント(最大5段階スレッド) |
| 認証 | ニックネーム / Google・GitHub・Apple OAuth / メール+パスワード(確認メール必須) |
| パスワード | リセットメールによる再設定 |
| 課題管理 | 管理者CRUD + ユーザー投稿(承認制) + AI課題生成 |
| 課題分類 | カテゴリ(4種) + 自由タグ + フィルタ |
| 多言語 | 日本語 / 英語(next-intl、`/ja/` `/en/`) |
| API エラー / 成功 | `errorCode` / `messageCode` + クライアント翻訳 |
| プッシュ通知 | Web Push(VAPID)+ ネイティブ FCM(Capacitor) |
| プッシュ i18n | 受信者 `preferred_locale` + `/{locale}/` URL |
| ディープリンク | Universal Links / App Links(`.well-known`)+ `prompt-dojo://` |
| オフライン書込 | IndexedDB キュー + `online` イベント + Background Sync |
| LLM | 評価・課題生成が locale に応じた言語で出力 |
| ネイティブシェル | Capacitor WebView(`mobile/`) |

## 環境変数

```
# 既存(認証・LLM・VAPID・SMTP 等)は v7.0 参照

# Phase 8: ネイティブ FCM(任意 — 未設定時は Web Push のみ)
FIREBASE_PROJECT_ID=...
FIREBASE_CLIENT_EMAIL=...
FIREBASE_PRIVATE_KEY=... # 改行は \n エスケープ

APP_BASE_URL=https://your-domain.example
NEXT_PUBLIC_APP_BASE_URL=https://your-domain.example
```

## Phase 8 実装サマリー

- `push-messages.ts` — プッシュ文言・URL の locale 対応
- `device_tokens` テーブル + `/api/push/register-device` + `firebase-admin` FCM 送信
- `NativePushRegistrar` + Capacitor push/app プラグイン
- `capacitor-deeplink.ts` + `.well-known`(AASA / assetlinks)
- Background Sync(`sw.js` + `registerBackgroundSync()`)
- LLM evaluator / challenge generator の locale 対応

## スコープ外(Phase 9 候補)

- React Native / Expo ネイティブ UI
- 課題コンテンツ DB 多言語カラム(seed 英訳)
- ネイティブプッシュ購読解除 UI
- CI 署名済み APK/IPA ビルド
18 changes: 18 additions & 0 deletions prompt-dojo/eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { defineConfig, globalIgnores } from "eslint/config";
import nextVitals from "eslint-config-next/core-web-vitals";
import nextTs from "eslint-config-next/typescript";

const eslintConfig = defineConfig([
...nextVitals,
...nextTs,
// Override default ignores of eslint-config-next.
globalIgnores([
// Default ignores of eslint-config-next:
".next/**",
"out/**",
"build/**",
"next-env.d.ts",
]),
]);

export default eslintConfig;
Loading