feat(desktop): SaaS [3.5] 로컬 모드 = entry point (빅뱅 Phase 1.5)

비즈니스 모델 수정:
- 무료 로컬 모드 = 사용자 onboarding funnel 입구 (킬러 피처, 회원가입 0)
- 유료 클라우드 SaaS = 수익화 (OAuth 로그인 + pro + premium 모델 + sync)
- 이전 세션 SaaS [2] OAuth 강제 게이트 철회

db/index.ts:
- LOCAL_USER_ID = '_local' 상수 export
- openLocal() 헬퍼 — userData/users/_local/d3ro.db
- isLocalMode() 헬퍼

bootstrap.ts:
- database step 복원 (critical). openLocal() 호출로 앱 시작 시
  로컬 DB 자동 오픈 — 로그인 없이 즉시 메인 UI 진입 가능

CloudSyncService._onSignOut():
- closeCurrent() 후 openLocal() 호출 — 로그아웃 시 로컬 모드 DB로 복귀
- 앱은 계속 로컬 모드로 동작 (entry point 철학)

App.tsx:
- AuthGate 상태머신 제거 (loading/login-required/authenticated/legacy)
- LoginScreen import 제거, 항상 AppLayout 렌더
- LoginScreen.tsx 파일은 유지 (추후 Welcome 화면 재활용 가능)

검증:
- desktop tsc --noEmit ✅
- desktop build ✅
- dev 런타임: [bootstrap] local database opened → Main window shown
- users/_local/d3ro.db 파일 생성 확인
This commit is contained in:
윤찬 2026-04-11 10:08:35 +09:00
parent 816f527592
commit 1a01cea33c
5 changed files with 102 additions and 91 deletions

View file

@ -21,6 +21,16 @@ const logger = getLogger('database')
// 모듈 상태
// ─────────────────────────────────────────────────────────────
/**
* 로컬(익명) 모드 user id. OAuth 로그인 없이 동작하는 무료 로컬 모드의
* 데이터 디렉토리 식별자. `userData/users/_local/d3ro.db`에 저장된다.
*
* 비즈니스 모델 관점:
* - `_local`: 무료 익명 사용자 entry point (킬러 피처 — 회원가입 0, 로컬 STT/LLM)
* - 실제 uuid: OAuth 로그인 후 클라우드 sync + premium 기능 (유료 SaaS 수익화)
*/
export const LOCAL_USER_ID = '_local'
let currentUserId: string | null = null
let sqlite: Database.Database | null = null
let db: BetterSQLite3Database<typeof schema> | null = null
@ -38,6 +48,11 @@ function getUserDbPath(userId: string): string {
return path.join(app.getPath('userData'), 'users', userId, 'd3ro.db')
}
/** 현재 모드가 익명 로컬 모드인지. */
export function isLocalMode(): boolean {
return currentUserId === LOCAL_USER_ID
}
/** 레거시(V1) 단일 DB 파일 경로. 한 번도 정식 서비스되지 않았으므로 발견 시 silent archive. */
function getLegacyDbPath(): string {
return path.join(app.getPath('userData'), 'd3ro-voice.db')
@ -338,6 +353,16 @@ export function openForUser(userId: string): OpenForUserResult {
return { created: !existed, dbPath }
}
/**
* 익명 로컬 모드 DB 열기. 앱 시작 시 기본으로 호출되는 entry point.
* 로그인 없이 바로 동작해야 하는 킬러 피처의 데이터 저장소.
*
* `userData/users/_local/d3ro.db`에 저장. 로그아웃 복귀 시 같은 경로로 재오픈.
*/
export function openLocal(): OpenForUserResult {
return openForUser(LOCAL_USER_ID)
}
/**
* 현재 열려있는 DB 닫기. 아무 것도 안 열려 있으면 no-op.
*/