Files
stemengine_old/docs/plans/done/PHASE_A_VISUAL_GUIDE.md
2026-04-14 16:32:36 +09:00

15 KiB

Phase A: Visual Architecture & Component Guide

System Architecture Diagram

┌─────────────────────────────────────────────────────────────────┐
│                         APPLICATION SHELL                        │
│                                                                   │
│  ┌──────────────────────────────────────────────────────────┐   │
│  │                    FeishinShell Component                 │   │
│  │                                                            │   │
│  │  ┌─────────────────┬──────────────────────────────────┐   │   │
│  │  │                 │                                  │   │   │
│  │  │    SIDEBAR      │        CONTENT AREA             │   │   │
│  │  │    (250px)      │      (Flexible)                 │   │   │
│  │  │                 │                                  │   │   │
│  │  │  ┌───────────┐  │  ┌──────────────────────────┐    │   │   │
│  │  │  │   Home    │  │  │  SubsonicBrowser        │    │   │   │
│  │  │  ├───────────┤  │  │  ├─ Home                 │    │   │   │
│  │  │  │ Albums    │  │  │  ├─ Albums              │    │   │   │
│  │  │  ├───────────┤  │  │  ├─ Tracks              │    │   │   │
│  │  │  │ Tracks    │  │  │  ├─ Artists             │    │   │   │
│  │  │  ├───────────┤  │  │  ├─ Genres              │    │   │   │
│  │  │  │ Album Art │  │  │  ├─ Playlists           │    │   │   │
│  │  │  ├───────────┤  │  │  └─ Details             │    │   │   │
│  │  │  │ Artists   │  │  │     (Album/Artist)      │    │   │   │
│  │  │  ├───────────┤  │  └──────────────────────────┘    │   │   │
│  │  │  │ Genres    │  │                                  │   │   │
│  │  │  ├───────────┤  │                                  │   │   │
│  │  │  │ Playlists │  │                                  │   │   │
│  │  │  ├───────────┤  │                                  │   │   │
│  │  │  │ ┌───────┐ │  │                                  │   │   │
│  │  │  │ │  Sing │ │  │   Phase B: Karaoke browser      │   │   │
│  │  │  │ └───────┘ │  │   (Separate port)               │   │   │
│  │  │  └───────────┘  │                                  │   │   │
│  │  │                 │                                  │   │   │
│  │  └─────────────────┴──────────────────────────────────┘   │   │
│  │                                                            │   │
│  │  ┌──────────────────────────────────────────────────────┐   │   │
│  │  │     Now-Playing Footer (Ready for Phase B)           │   │   │
│  │  │  [Cover] Now Playing ► ⏸️ ⏭️  [Progress] [Time]      │   │   │
│  │  └──────────────────────────────────────────────────────┘   │   │
│  └──────────────────────────────────────────────────────────────┘   │
│                                                                   │
└─────────────────────────────────────────────────────────────────┘

Data Flow Architecture

                    ┌─────────────────┐
                    │ User Interaction│
                    └────────┬────────┘
                             │
                    ┌────────▼────────┐
                    │  FeishinShell   │
                    │  (Navigation)   │
                    └────────┬────────┘
                             │
                    ┌────────▼────────┐
                    │  LibraryPage    │
                    │  (Router)       │
                    └────────┬────────┘
                             │
                    ┌────────▼────────┐
                    │SubsonicBrowser  │
                    │ (View Logic)    │
                    └────────┬────────┘
                             │
               ┌─────────────┴─────────────┐
               │                           │
      ┌────────▼─────────┐     ┌─────────▼──────────┐
      │  useSubsonic()   │     │  SubsonicAPI       │
      │  (Context Hook)  │     │  (REST Calls)      │
      └────────┬─────────┘     └─────────┬──────────┘
               │                         │
      ┌────────▼─────────┐     ┌─────────▼──────────┐
      │SubsonicContext   │     │  /rest/getAlbum... │
      │• connection      │     │  /rest/getTracks.. │
      │• status          │     │  /rest/getArtist.. │
      │• localStorage    │     │  /rest/search...   │
      └──────────────────┘     └────────────────────┘

Component Hierarchy

App.tsx
└── SubsonicProvider (services/SubsonicContext.tsx)
    └── KMFrontend.tsx
        └── PrivateRoute
            └── LibraryPage.tsx (Phase A Integration)
                └── FeishinShell.tsx
                    ├── Sidebar Navigation
                    ├── Content Area
                    │   └── Routes
                    │       └── SubsonicBrowser.tsx
                    │           ├── Home View
                    │           ├── Albums View
                    │           ├── Tracks View
                    │           ├── Artists View
                    │           ├── Genres View
                    │           ├── Playlists View
                    │           ├── Album Detail
                    │           └── Artist Detail
                    └── Now-Playing Footer
                        └── [Ready for Phase B]

Services Layer:
├── SubsonicContext.tsx (Connection State)
├── SubsonicAPI.ts (REST Service)
└── useSubsonic.ts (Hook)

Subsonic Data Flow

SubsonicBrowser
├── Click "Albums"
│   └── loadAlbums()
│       └── api.getAlbums()
│           └── GET /rest/getAlbumList2.view
│               └── Response: Array<SubsonicAlbum>
│                   └── Render Album Grid
│
├── Click Album Card
│   └── loadAlbumDetail(albumId)
│       └── api.getAlbumDetail(albumId)
│           └── GET /rest/getAlbum.view?id=...
│               └── Response: { album, tracks: Array<SubsonicTrack> }
│                   └── Render Album Detail + Tracklist
│
├── Click Artist
│   └── loadArtistDetail(artistId)
│       └── api.getArtistDetail(artistId)
│           └── GET /rest/getArtist.view?id=...
│               └── Response: { artist, albums: Array<SubsonicAlbum> }
│                   └── Render Artist Detail + Album Grid
│
└── Click Track (Phase B)
    └── addToQueue(trackId)
        └── Get Stream URL
            └── api.getStreamUrl(trackId)
                └── Return URL for audio player

View State Machine

                    ┌─────────────┐
                    │    Home     │
                    └──────┬──────┘
                           │
        ┌──────────────────┼──────────────────┐
        │                  │                  │
        ▼                  ▼                  ▼
    ┌────────┐         ┌────────┐        ┌────────┐
    │Albums  │         │ Tracks │        │ Artists│
    └───┬────┘         └────────┘        └───┬────┘
        │                                     │
        │ (click album)              (click artist)
        │                                     │
        ▼                                     ▼
    ┌─────────────┐                   ┌─────────────┐
    │Album Detail │                   │Artist Detail│
    │ + Tracklist │                   │ + Albums    │
    └────┬────────┘                   └────┬────────┘
         │                                  │
         │ (back button)           (back button)
         │                                  │
         └──────────────┬───────────────────┘
                        │
                   Return to
                   Previous View

Feishin Design System

Colors

Background:     #121212 (Almost Black)
Panel:          #1a1a1a (Dark Gray)
Border:         #333 (Medium Gray)
Text Primary:   #fff (White)
Text Secondary: #b3b3b3 (Light Gray)
Text Tertiary:  #999 (Medium Gray)
Accent Primary: #1db954 (Spotify Green)
Accent Light:   #1ed760 (Bright Green - hover)
Error:          #ff4444 (Red)
Success:        #1db954 (Green)

Spacing

Sidebar Width:    250px
Content Padding:  24px
Gap Small:        8px
Gap Medium:       12px
Gap Large:        16px
Gap XLarge:       24px
Gap XXLarge:      32px / 48px

Typography

Heading 1:  28px Bold
Heading 2:  20px Bold
Body:       14px Regular
Small:      12px Regular
Label:      13px Bold

Components

Button:      12px padding, rounded corners, hover lift effect
Input:       10px padding, dark background, green focus
Card:        Rounded 6px, bg #2a2a2a
Grid:        auto-fill minmax(150px, 1fr)
List:        Vertical flex, border separators

File Size Summary

Component Size Type
FeishinShell.tsx 200 LOC TypeScript
FeishinShell.scss 200 LOC SCSS
SubsonicSetup.tsx 180 LOC TypeScript
SubsonicSetup.scss 300 LOC SCSS
SubsonicBrowser.tsx 550 LOC TypeScript
SubsonicBrowser.scss 500 LOC SCSS
SubsonicContext.tsx 150 LOC TypeScript
SubsonicAPI.ts 350 LOC TypeScript
LibraryPage.tsx 80 LOC TypeScript
useSubsonic.ts 12 LOC TypeScript
Total Code 2,522 ~2.5K LOC

Integration Checklist - Visual

┌─────────────────────────────────────────────┐
│         Phase A Integration Steps           │
├─────────────────────────────────────────────┤
│                                             │
│  Step 1: Copy Files ✓                       │
│  ├─ components/ (7 files)                   │
│  ├─ services/ (2 files)                     │
│  └─ hooks/ (1 file)                         │
│                                             │
│  Step 2: Update App.tsx ✓                   │
│  └─ Wrap in <SubsonicProvider>              │
│                                             │
│  Step 3: Update KMFrontend.tsx ✓            │
│  └─ Import & route LibraryPage              │
│                                             │
│  Step 4: Build ✓                            │
│  └─ yarn build                              │
│                                             │
│  Step 5: Test ✓                             │
│  ├─ Connect to Subsonic                     │
│  ├─ Browse albums                           │
│  └─ Verify localStorage                     │
│                                             │
└─────────────────────────────────────────────┘

Estimated Time: 30 minutes
Success Criteria: All items ✓

Phase A → Phase B Transition

Phase A (Complete)
├── ✓ Feishin Shell
├── ✓ Subsonic Integration
├── ✓ Library Browser
└── ✓ Now-Playing Footer (shell)

        ↓ Phase B Dependencies ↓

Phase B (Queue + Playback)
├── [ ] Queue Context
├── [ ] Audio Player
├── [ ] Playback Integration
├── [ ] Sing Browser
└── [ ] Now-Playing Footer (wired)

Key Dependencies:
- LibraryPage provides foundation for queue
- SubsonicAPI ready for streaming URLs
- FeishinShell footer ready for playback props
- Component patterns established

Visual Summary: Phase A provides a solid foundation with clean architecture, clear data flow, and Feishin-aligned design. Ready for Phase B queue and playback work.

Integration Timeline: 30 minutes
Testing Timeline: 15 minutes
Go-Live Risk: Low