You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# 의존성 설치
pip install -r requirements.txt
# 서버 실행 (로컬)
python app.py
# 외부 공개 (ngrok)
python run_ngrok.py --token YOUR_NGROK_TOKEN
# 브라우저 접속
http://localhost:5000
주요 기능
그림 그리기
랜덤 단어 제시 → 캔버스에 자유롭게 그리기
2열 레이아웃: 왼쪽 패널(단어 카드 / 예시 그림 / 밑그림 버튼) + 오른쪽 캔버스
AI 참고 이미지 생성 기능 (LCM-DreamShaper v7, 컬러링북 스타일 — 4~7세 따라 그리기용)
그린 그림은 그림 모음장에 저장 (JS Canvas에서 흰 배경 제거 후 저장)
AI 동화 생성
그림 키워드 기반으로 Gemini AI가 4장면 동화 작성
주인공 지정: 선택한 그림 중 하나를 주인공으로 지정 가능 (항상 맨 앞에 배치)
배경 이미지 + TTS + 콜라주 병렬 생성 (ThreadPoolExecutor 3개)
아이 그림 객체가 배경에 중복 등장하지 않도록 제외 처리
CLOVA Voice로 동화 전체 음성 낭독 생성 (gTTS 폴백)
교훈 페이지 콜라주 이미지 자동 생성
동화책 뷰어
배경 + 아이 그림 + 텍스트 + 음성이 합쳐진 동화책 형태
Gemini layout_hints: AI가 장면마다 그림의 위치(sky/ground/ground-foreground)와 크기(large/normal/small) 지정
그림 최대 5개 동시 배치: primary / secondary / tertiary / quaternary / quinary
하늘 / 땅 자동 분류 배치 (layout_hints 우선, 없으면 키워드 기반 자동 분류)
땅 그림 레이아웃: 1개(단독) → pair(2) → trio(3) → quad(4) → quint(5)
스토리 문맥에 따라 그림 크기 자동 조절
도서관 & 뱃지 시스템
AI 동화 아카이빙: 생성된 나만의 동화책을 영구적으로 보관하고 언제든 다시 열람할 수 있는 도서관 페이지
인터랙티브 좌우 이동형 책장: 신규 생성된 책은 왼쪽 책장(<새로운 책>)에 꽂히며, 열람을 완료하면 오른쪽 책장(<읽은 책>)으로 자동 이동하여 독서 상태 직관적 분리
책꾸러미 (아카이브 보관함): 책장에 도서가 일정량 누적되면 측면에 '책꾸러미' 버튼이 활성화되어, 차곡차곡 쌓인 전체 누적 도서 목록을 한눈에 모아보기 가능
누적 독서 기반 성장형 뱃지 (Gamification): 책을 읽고 쌓아간 권수에 따라 단계별로 작가 타이틀 및 뱃지 자동 부여
뱃지 레벨업 로직: 🌱 새싹 작가(110권) → 🌳 꿈나무 작가(1121권) → 🪄 마법 작가(22~32권) → 👑 전설 작가(33권 이상)
보상 연동 기능: 뱃지 등급이 업그레이드될 때마다 캔버스 도구 잠금 해제 등 앱 내 숨겨진 기능이 활성화되어 지속적인 창작 및 독서 동기 부여
전체 아키텍처
flowchart TD
subgraph FE[프론트엔드]
landing[landing.html]
main[main.html]
draw[drawing.html + canvas.js]
collection[collection.html + collection.js]
library[library.html]
storybook[storybook.html + storybook.js]
end
subgraph BE[Flask 백엔드 app.py]
api1[POST /api/drawing/save]
api2[POST /api/story/generate]
api3[DELETE /api/story/:id]
api4[POST /api/drawing/help]
end
subgraph SVC[서비스 레이어]
ai[ai_service.py Gemini 2.5 Flash Lite / Claude Sonnet 4.6]
img[image_service.py LCM-DreamShaper v7 / Pollinations]
tts[tts_service.py CLOVA Voice / gTTS]
end
subgraph DB[SQLite DB]
d[(그림)]
s[(스토리)]
end
landing --> main
main --> draw & collection & library
draw -->|저장| api1 --> d
collection -->|그림 선택 + 주인공 지정| api2
api2 --> ai & img & tts
api2 --> s
library --> s
storybook --> s
api4 --> img
Loading
동화 생성 흐름
sequenceDiagram
actor 사용자
participant FE as collection.js
participant BE as app.py
participant AI as ai_service
participant IMG as image_service
participant TTS as tts_service
participant DB as database
사용자->>FE: 그림 1~5개 선택 + 주인공 지정 후 동화 만들기
FE->>BE: POST /api/story/generate {drawing_ids, protagonist_id}
BE->>AI: generate_fairy_tale(keywords, drawings, protagonist_kw)
AI->>AI: Gemini 2.5 Flash Lite (Vision)
Note right of AI: 폴백: Claude Sonnet 4.6
AI-->>BE: title, scenes[4], moral, name_map, layout_hints
BE->>BE: present 처리 (정확→조사제거→부분매칭→텍스트보완)
BE->>BE: layout_spreads 계산 (5슬롯: primary~quinary)
par 병렬 생성
BE->>IMG: generate_scene_bgs_parallel(scene_data)
Note right of IMG: exclude_en로 아이 그림 배경 제외
IMG-->>BE: bg_image 4장
and
BE->>IMG: generate_moral_collage
IMG-->>BE: 교훈 콜라주 이미지
and
BE->>TTS: generate_tts
TTS-->>BE: audio_path MP3
end
BE->>DB: save_story
DB-->>BE: story_id
BE-->>FE: success, story_id, level_up
FE->>사용자: /story/:id 이동