Posimai Project — マスターアーキテクチャドキュメント
最終更新: 2026-04-20
対象: Claude Code / Cursor / Gemini / 全 AI エージェント
このドキュメントはプロジェクトの現状を一元管理します。実装の前に必ず読んでください。
0. ビジネス体制(確定)
- Eiji: 共同経営者。VPS・DNS(soar-enrich.com)・Cloudflare 管理・対外窓口・代表。VPS は mai も自由に操作可。
- mai: プロダクト開発担当。アプリ設計・実装・AI 活用。
- インフラ・ドメイン共用は設計通り。
1. 全体構成図(2026-04-06 確定)
╔══════════════════════════════════════════════════════════╗
║ mai の開発環境(Windows 11 PC) ║
║ VS Code / Claude Code CLI ║
╚══════════════════════════════════════════════════════════╝
│ git push(gitea + github の2リモート同時)
│ ※ Gitea 廃止は検討中・現状維持
▼
╔══════════════════════════════════════════════════════════╗
║ コード管理 ║
║ GitHub(正)← Vercel 自動デプロイトリガー ║
║ Gitea(NAS)← バックアップのみ・確認先にしない ║
╚══════════════════════════════════════════════════════════╝
│ GitHub push → Vercel 自動デプロイ
▼
╔══════════════════════════════════════════════════════════╗
║ フロントエンド(Vercel / CDN) ║
║ posimai.soar-enrich.com → posimai-dashboard ║
║ *.posimai.soar-enrich.com → Vercel(ワイルドカード設定済)║
║ 全 30 本前後の PWA(静的/Next 混在) ║
╚══════════════════════════════════════════════════════════╝
│ https://api.soar-enrich.com/brain/api/...
▼
╔══════════════════════════════════════════════════════════╗
║ バックエンド本番(VPS)85.131.245.239 ║
║ Ubuntu 25.04 / AMD EPYC 4コア / 5.8GB RAM ║
║ ║
║ Nginx: api.soar-enrich.com → :8090 ║
║ posimai-api(Node.js / Express / :8090) ║
║ PostgreSQL 16(posimai_brain DB) ║
║ VOICEVOX(:50021)稼働済み ║
╚══════════════════════════════════════════════════════════╝
╔══════════════════════════════════════════════════════════╗
║ Ubuntu PC(100.77.11.43 / Tailscale) ║
║ ・posimai-dev(:3333)ブラウザターミナル + Station ║
║ ・Station(HDMI 全画面監視) ║
║ ・Openbox + Chromium kiosk ║
╚══════════════════════════════════════════════════════════╝
╔══════════════════════════════════════════════════════════╗
║ Synology NAS(100.76.7.3 / Tailscale のみ) ║
║ ・Gitea(:3000)git バックアップ ║
║ ・Uptime Kuma(:3002)死活監視 ║
║ ・旧 API / PostgreSQL 15(停止可能・保留中) ║
║ ・Ubuntu PC → NAS rsync バックアップ(毎日3時) ║
╚══════════════════════════════════════════════════════════╝
╔══════════════════════════════════════════════════════════╗
║ 外部サービス ║
║ Resend(Magic Link メール / noreply@soar-enrich.com) ║
║ Stripe(テストモード稼働中 / 月額¥500) ║
║ Gemini API(VPS 経由・gemini-2.5-flash 固定) ║
║ Google Places API(Maps アプリ・フロント直接・要改善) ║
╚══════════════════════════════════════════════════════════╝
2. VPS PostgreSQL — テーブルとデータの実体
| テーブル |
何が入っているか |
AIが関与するか |
users |
ユーザー情報・plan(free/premium)・Stripe ID |
なし |
auth_sessions |
JWTセッション |
なし |
articles |
Brain保存記事・AI要約(summaryカラム)・全文・トピック |
Gemini が要約生成・VPS に永続保存 |
journal_posts |
Journal投稿・タグ |
タグはGeminiが提案(その場限り) |
reading_history |
読んだURL・タイトル・ドメイン |
なし |
habit_habits / habit_log |
習慣定義・達成ログ |
なし |
pulse_log |
気分・エネルギー・集中度・メモ |
なし |
lens_history |
写真EXIFデータ・サムネイル |
なし |
together_groups/members/shares/reactions/comments |
Together全データ(2026-04-06 Supabaseから移行済み) |
投稿にAI要約あり |
Supabase は撤退済み(2026-04-06)。 Together を VPS PostgreSQL に完全移行。
3. データ保存先(確定)
| 保存先 |
対象 |
状態 |
| VPS PostgreSQL |
brain・journal・together・reading_history・habit・pulse・認証 |
稼働中 |
| localStorage(永続・移行しない) |
veil設定・timer設定 |
確定 |
| localStorage(将来VPS移行予定) |
habit・pulse(VPSにテーブルは存在済み) |
商用化フェーズで移行 |
| データなし(都度処理) |
diff・clean・think・digest・brief・feed・timer |
— |
4. アプリ間パイプライン(設計)
Feed(発見)
↓ 記事クリック
Reader(読む)→ reading_history に記録(2026-04-06 対応済み)
↓ 保存ボタン
Brain(保存・AI要約)→ articles に記録
↓ 気づきをメモ
Think / Journal(内省)→ journal_posts
↓ 週次バッチ(未実装)
Digest(まとめ)→ user_activity から集計して生成
Brief(音声)→ Digest の内容を VOICEVOX で読み上げ
↓ 公開したいものだけ
Together(共有)→ together_shares
Pulse/Habit は横断的に記録され、Rewind(振り返り)アプリの材料になる(将来)。
未実装・改善が必要なもの
| 課題 |
内容 |
優先度 |
user_activity テーブル |
アプリ横断の行動ログ基盤。Digestの週次集計に必要 |
中 |
| habit/pulse → VPS移行 |
テーブルはVPSに存在。アプリ側をAPI呼び出しに変えるだけ |
中(premium機能として) |
| Together に Brain/Journal 連携 |
source_type / source_id カラム追加で Brain記事を直接共有可能 |
低 |
Digest /api/digest/weekly 実装 |
user_activityから週次サマリー生成 |
低 |
| Google Places API → VPS経由化 |
Mapsアプリのキーがフロントに露出している |
低(急がない) |
5. 認証フロー(確定・全て稼働中)
Magic Link(Resend メール → JWT)
Google OAuth → VPS → JWT → /auth/verify?type=oauth
GitHub OAuth → VPS → JWT → /auth/verify?type=oauth
WebAuthn / Passkey(rpID: posimai.soar-enrich.com)
JWT: { userId, sid, plan }
plan = "free" or "premium"(Stripe決済後にDB更新)
/auth/session/verify → { ok, userId, plan, purchased }
Supabase Auth は不採用。完全 VPS 自前認証。
X-API-Key・?init_key= の旧認証体系は一部アプリが依存しているため変更禁止。
6. 販売フロー(テストモード稼働中)
posimai-store(LP)
→ Stripe Payment Link(月額¥500・1日無料トライアル)
→ Stripe Webhook → VPS → users.plan = "premium"
→ JWT に plan: "premium" が入る
→ 各アプリで purchased フラグで機能出し分け可能
本番切り替え待ち: Storeデザイン確定 → 特商法記入 → Stripe本番切り替え
7. アプリ一覧(代表・2026-04-20 追記)
| アプリ |
バックエンド |
備考 |
| posimai-dashboard |
— |
Next.js / メインダッシュボード |
| posimai-brain |
VPS API |
記事保存・AI要約 |
| posimai-feed |
Vercel Serverless + RSS |
フィード(キー不要) |
| posimai-reader |
VPS API |
記事リーダー(reading_history連携済み) |
| posimai-journal |
VPS API |
CMS / Geminiタグ提案 |
| posimai-together |
VPS API |
共有(Supabaseから移行済み) |
| posimai-brief |
VPS TTS |
VOICEVOX音声 |
| posimai-daily |
VPS API |
ブリーフィング |
| posimai-habit |
localStorage → VPS(予定) |
習慣管理 |
| posimai-pulse |
localStorage → VPS(予定) |
気分記録 |
| posimai-think |
Gemini直接 |
AI思考整理 |
| posimai-digest |
Gemini直接 |
テキスト要約 |
| posimai-maps |
Google Places API(フロント直接) |
要VPS化 |
| posimai-tech-events |
VPS経由RSS |
ITイベント |
| posimai-atlas |
VPS API |
インフラ構成図 |
| posimai-site |
VPS API |
公開ホームページ |
| posimai-lens |
— |
EXIF表示(処理のみ) |
| posimai-diff |
— |
テキスト差分(処理のみ) |
| posimai-clean |
— |
テキストクリーナー(処理のみ) |
| posimai-timer |
— |
タイマー(localStorage) |
| posimai-veil |
— |
アプリランチャー |
| posimai-ambient |
open-meteo |
常時表示 |
| posimai-roadmap |
— |
ロードマップ |
| posimai-widget-dl |
— |
ウィジェット |
| posimai-events |
VPS API |
イベント情報(モック・Beta) |
| posimai-hotels |
— |
ホテル価格(モック・Beta) |
| posimai-analytics |
— |
Next.js / RFM分析 |
| posimai-guard |
Gemini API |
AI コードセキュリティスキャン |
| posimai-store |
Stripe / VPS |
アプリ販売 LP |
| posimai-log |
— |
開発ログビューワー(scribe 連携) |
| posimai-boki |
— |
簿記2級 学習 PWA(localStorage) |
| posimai-sc |
— |
支援士試験 学習 PWA(localStorage・非公式補助) |
8. デプロイパイプライン
# フロントエンド(全アプリ共通)
git add . && git commit -m "feat/fix/chore: ..." && npm run deploy
# = git push gitea main && git push github main → Vercel 自動デプロイ
# VPS バックエンド(server.js 変更時)
bash deploy-server.sh
# Ubuntu PC(posimai-dev/station 変更時)
npm run deploy:dev # git push + scp + systemctl restart
vercel --prod 直接実行: 禁止
- VPS DBバックアップ: 毎日4時自動実行・7日分保持・正常稼働確認済み(2026-04-06)
9. 残タスク(優先順)
商用化直結(maiの決定が必要)
| タスク |
状態 |
| どのアプリにpremium機能を実装するか決める |
未決定・最重要 |
| Storeデザイン確定(A/B/C/D) |
Eiji意見待ち |
| 特商法ページ記入(事業者名・住所等) |
mai手動作業 |
| Stripe本番モード切り替え |
デザイン確定後 |
AIが対応可能(maiの決定後)
| タスク |
工数 |
| 各アプリへのpremiumフラグ実装 |
1アプリ30分 |
| habit/pulse → VPS API移行 |
各2時間 |
| user_activityテーブル追加 |
2時間 |
保留・検討中
| 項目 |
状態 |
| Giteaをdeployから外す |
検討中(廃止メリットあり・決定待ち) |
| Uptime Kuma → Ubuntu PC移設 + UptimeRobot追加 |
検討中 |
| Synology 旧コンテナ停止 |
保留 |
10. 設計判断ログ
| 日付 |
決定事項 |
| 2026-03-25 |
バックエンドを Synology → VPS に移行完了 |
| 2026-03-26 |
API URL を api.soar-enrich.com に分離完了 |
| 2026-03-29 |
Supabase Auth を不採用。VPS 自前認証を正規方針に確定 |
| 2026-04-04 |
Google OAuth + GitHub OAuth 実装完了 |
| 2026-04-04 |
Stripe Webhook 実装完了・テスト決済確認済み |
| 2026-04-06 |
Together を Supabase → VPS PostgreSQL に完全移行(61件) |
| 2026-04-06 |
*.posimai.soar-enrich.com ワイルドカード DNS 設定済み確認 |
| 2026-04-06 |
Reader reading_history を localStorage → VPS に修正済み |
| 2026-04-06 |
WebSocket認証・SSRF blocklist・Feed POST認証・e.message修正済み |
11. 絶対に守るルール(全 AI 共通)
- デプロイは
npm run deploy のみ(vercel --prod 禁止)
- 絵文字禁止(コード・UI・コミット全て)
- Lucide @0.344.0 固定(
@latest 禁止)
- デザイントークン外の色直接使用禁止(
var(--accent) を使う)
git push origin 禁止(gitea と github の2リモートのみ)
- Gemini モデルは
gemini-2.5-flash 固定
- このファイルを変更したら「最終更新」日付を更新する