From 17a5fdb0c4e45545c0df66767b6d1fffd63ee7e1 Mon Sep 17 00:00:00 2001 From: cherry2250 Date: Wed, 22 Oct 2025 10:33:31 +0900 Subject: [PATCH] edit logical architecture --- claude/check-mermaid.sh | 107 ++++++++++++++++ .../backend/logical/logical-architecture.mmd | 118 +++--------------- 2 files changed, 126 insertions(+), 99 deletions(-) create mode 100755 claude/check-mermaid.sh diff --git a/claude/check-mermaid.sh b/claude/check-mermaid.sh new file mode 100755 index 0000000..abb29cb --- /dev/null +++ b/claude/check-mermaid.sh @@ -0,0 +1,107 @@ +#!/bin/bash +# Mermaid Syntax Checker using Docker Container +# Similar to PlantUML checker - keeps container running for better performance + +# Colors for output +RED='\033[0;31m' +GREEN='\033[0;32m' +YELLOW='\033[0;33m' +CYAN='\033[0;36m' +GRAY='\033[0;90m' +NC='\033[0m' # No Color + +# Check if file path is provided +if [ -z "$1" ]; then + echo -e "${RED}Error: No file path provided${NC}" + echo "Usage: $0 " + exit 1 +fi + +FILE_PATH="$1" + +# Check if file exists +if [ ! -f "$FILE_PATH" ]; then + echo -e "${RED}Error: File not found: $FILE_PATH${NC}" + exit 1 +fi + +# Get absolute path +ABSOLUTE_PATH=$(realpath "$FILE_PATH") +FILE_NAME=$(basename "$ABSOLUTE_PATH") + +echo -e "\n${CYAN}Checking Mermaid syntax for: $FILE_NAME${NC}" +echo -e "${GRAY}$(printf '=%.0s' {1..60})${NC}" + +# Check if mermaid container is running +CONTAINER_RUNNING=$(docker ps --filter "name=mermaid-cli" --format "{{.Names}}" 2>/dev/null) + +if [ -z "$CONTAINER_RUNNING" ]; then + echo -e "${RED}Error: Mermaid CLI container is not running.${NC}" + echo -e "${YELLOW}Please follow the setup instructions in the Mermaid guide to start the container.${NC}" + echo -e "\n${CYAN}Quick setup commands:${NC}" + echo "" + echo -e "${GREEN}# 1. Start container with root privileges (port 48080)${NC}" + echo -e "${NC}docker run -d --rm --name mermaid-cli -u root -p 48080:8080 --entrypoint sh minlag/mermaid-cli:latest -c \"while true;do sleep 3600; done\"${NC}" + echo "" + echo -e "${GREEN}# 2. Install Chromium and dependencies${NC}" + echo -e "${NC}docker exec mermaid-cli sh -c \"apk add --no-cache chromium chromium-chromedriver nss freetype harfbuzz ca-certificates ttf-freefont\"${NC}" + echo "" + echo -e "${GREEN}# 3. Create Puppeteer configuration${NC}" + echo -e "${NC}docker exec mermaid-cli sh -c \"echo '{\\\"executablePath\\\": \\\"/usr/bin/chromium-browser\\\", \\\"args\\\": [\\\"--no-sandbox\\\", \\\"--disable-setuid-sandbox\\\", \\\"--disable-dev-shm-usage\\\"]}' > /tmp/puppeteer-config.json\"${NC}" + echo "" + exit 1 +fi + +# Set Puppeteer configuration file path +PUPPETEER_CONFIG_FILE="/tmp/puppeteer-config.json" + +# Generate unique temp filename +TIMESTAMP=$(date +"%Y%m%d%H%M%S") +PID=$$ +TEMP_FILE="/tmp/mermaid_${TIMESTAMP}_${PID}.mmd" +OUTPUT_FILE="/tmp/mermaid_${TIMESTAMP}_${PID}.svg" + +# Copy file to container +echo -e "${GRAY}Copying file to container...${NC}" +docker cp "$ABSOLUTE_PATH" "mermaid-cli:$TEMP_FILE" >/dev/null 2>&1 + +if [ $? -ne 0 ]; then + echo -e "${RED}Error: Failed to copy file to container${NC}" + exit 1 +fi + +# Run syntax check with Puppeteer configuration +echo -e "${GRAY}Running syntax check...${NC}" +OUTPUT=$(docker exec mermaid-cli sh -c "cd /home/mermaidcli && node_modules/.bin/mmdc -i '$TEMP_FILE' -o '$OUTPUT_FILE' -p '$PUPPETEER_CONFIG_FILE' -q" 2>&1) +EXIT_CODE=$? + +if [ $EXIT_CODE -eq 0 ]; then + echo -e "\n${GREEN}Success: Mermaid syntax is valid!${NC}" +else + echo -e "\n${RED}Error: Mermaid syntax validation failed!${NC}" + echo -e "\n${RED}Error details:${NC}" + + # Parse and display error messages + while IFS= read -r line; do + if [[ $line == *"Error:"* ]] || [[ $line == *"Parse error"* ]] || [[ $line == *"Expecting"* ]] || [[ $line == *"Syntax error"* ]]; then + echo -e " ${RED}$line${NC}" + elif [[ $line == *"line"* ]] && [[ $line =~ [0-9]+ ]]; then + echo -e " ${YELLOW}$line${NC}" + elif [[ ! -z "$line" ]]; then + echo -e " ${RED}$line${NC}" + fi + done <<< "$OUTPUT" + + # Clean up and exit with error + docker exec mermaid-cli rm -f "$TEMP_FILE" "$OUTPUT_FILE" >/dev/null 2>&1 + exit 1 +fi + +# Clean up temp files +echo -e "\n${GRAY}Cleaning up...${NC}" +docker exec mermaid-cli rm -f "$TEMP_FILE" "$OUTPUT_FILE" >/dev/null 2>&1 + +echo -e "\n${CYAN}Validation complete!${NC}" + +# Note: Container is kept running for subsequent checks +# To stop: docker stop mermaid-cli && docker rm mermaid-cli \ No newline at end of file diff --git a/design/backend/logical/logical-architecture.mmd b/design/backend/logical/logical-architecture.mmd index c255328..5148b9a 100644 --- a/design/backend/logical/logical-architecture.mmd +++ b/design/backend/logical/logical-architecture.mmd @@ -1,15 +1,5 @@ graph TB - %% KT AI 기반 소상공인 이벤트 자동 생성 서비스 - 논리 아키텍처 (Context Map) - - %% Client Layer - subgraph "Client Layer" - Mobile["Web/Mobile Client
• React PWA
• Mobile First
• 반응형 디자인"] - end - - %% Gateway Layer - subgraph "Gateway Layer" - Gateway["API Gateway
• JWT 인증/인가
• 라우팅
• Rate Limiting
• 중앙 로깅"] - end + %% KT AI 기반 소상공인 이벤트 자동 생성 서비스 - 논리 아키텍처 (간소화 버전) %% Service Layer subgraph "Service Layer" @@ -22,107 +12,37 @@ graph TB AnalSvc["Analytics Service
• 실시간 대시보드
• 채널별 성과
• ROI 분석"] end - %% Data Layer - subgraph "Data Layer" - Cache["Redis Cache
• 세션 정보
• AI 추천 결과 (24h)
• 이미지 URL (7d)
• 대시보드 데이터 (5m)"] - Queue["Message Queue
• AI 작업 큐
• 이미지 생성 큐
• 배포 작업 큐"] - UserDB["User DB
• users
• stores"] - EventDB["Event DB
• events
• distribution_logs"] - PartDB["Participation DB
• participants
• winners"] - AnalDB["Analytics DB
• event_stats
• channel_stats"] - end + %% Message Queue + Queue["Message Queue
• AI 작업 큐
• 이미지 생성 큐
• 배포 작업 큐"] - %% External APIs - subgraph "External APIs" - TaxAPI["국세청 API
사업자번호 검증"] - ClaudeAPI["Claude/GPT-4 API
AI 트렌드 분석
이벤트 추천"] - SDAPI["Stable Diffusion
DALL-E API
이미지 생성"] - UriAPI["우리동네TV API
영상 배포"] - RingoAPI["링고비즈 API
연결음 업데이트"] - GenieAPI["지니TV API
TV 광고"] - SNSAPI["SNS APIs
Instagram
Naver
Kakao"] - end + %% External System + External["외부시스템
• 국세청 API
• AI API
• 이미지 생성 API
• 배포 채널 APIs"] - %% Client to Gateway (단일 연결) - Mobile -->|HTTPS| Gateway - - %% Gateway to Services (동기) - Gateway -->|인증/프로필| UserSvc - Gateway -->|이벤트 관리| EventSvc - Gateway -->|참여자 관리| PartSvc - Gateway -->|성과 분석| AnalSvc - - %% Event Service Dependencies - EventSvc -.->|"[Event]AI 추천 요청
(Job 생성)"| Queue + %% Service to Queue + EventSvc -.->|AI 추천 요청| Queue + EventSvc -.->|이미지 생성 요청| Queue Queue -.->|비동기 작업 처리| AISvc - - EventSvc -.->|"[Event]이미지 생성 요청
(Job 생성)"| Queue Queue -.->|비동기 작업 처리| ContentSvc + %% Service to Service EventSvc -->|배포 시작| DistSvc - - %% AI Service Dependencies - AISvc -.->|"AI 추천 캐싱
(Cache-Aside, 24h)"| Cache - AISvc -->|"트렌드 분석
이벤트 추천
(Circuit Breaker)"| ClaudeAPI - - %% Content Service Dependencies - ContentSvc -.->|"이미지 URL 캐싱
(Cache-Aside, 7d)"| Cache - ContentSvc -->|"이미지 생성
(Circuit Breaker)"| SDAPI - - %% Distribution Service Dependencies - DistSvc -->|"영상 배포
(Circuit Breaker)"| UriAPI - DistSvc -->|"연결음 업데이트
(Circuit Breaker)"| RingoAPI - DistSvc -->|"TV 광고
(Circuit Breaker)"| GenieAPI - DistSvc -->|"SNS 자동 포스팅
(Circuit Breaker)"| SNSAPI - - %% User Service Dependencies - UserSvc -.->|세션 관리| Cache - UserSvc -.->|"사업자번호 캐싱
(Cache-Aside, 7d)"| Cache - UserSvc -->|"사업자번호 검증
(Circuit Breaker)"| TaxAPI - UserSvc -.->|사용자 정보| UserDB - - %% Event Service Database - EventSvc -.->|이벤트 정보| EventDB - - %% Participation Service Dependencies - PartSvc -.->|참여자 데이터| PartDB PartSvc -->|이벤트 정보 조회| EventSvc - - %% Analytics Service Dependencies - AnalSvc -.->|"대시보드 캐싱
(Cache-Aside, 5m)"| Cache - AnalSvc -.->|통계 데이터| AnalDB AnalSvc -->|이벤트 정보| EventSvc AnalSvc -->|참여자 데이터| PartSvc AnalSvc -->|배포 통계| DistSvc - AnalSvc -->|"채널별 노출 수
(Circuit Breaker)"| UriAPI - AnalSvc -->|"채널별 노출 수
(Circuit Breaker)"| GenieAPI - AnalSvc -->|"SNS 통계
(Circuit Breaker)"| SNSAPI + + %% Service to External + UserSvc -->|사업자번호 검증| External + AISvc -->|트렌드 분석/추천| External + ContentSvc -->|이미지 생성| External + DistSvc -->|다중 채널 배포| External + AnalSvc -->|채널별 통계| External %% Styling - classDef client fill:#BFDBFE,stroke:#3B82F6,stroke-width:2px - classDef gateway fill:#2E86AB,stroke:#1E3A8A,stroke-width:2px,color:#fff - classDef user fill:#4ECDC4,stroke:#14B8A6,stroke-width:2px - classDef event fill:#F18F01,stroke:#F97316,stroke-width:2px - classDef ai fill:#10B981,stroke:#059669,stroke-width:2px - classDef content fill:#8B5CF6,stroke:#7C3AED,stroke-width:2px,color:#fff - classDef dist fill:#EC4899,stroke:#DB2777,stroke-width:2px,color:#fff - classDef part fill:#F59E0B,stroke:#F97316,stroke-width:2px - classDef anal fill:#06B6D4,stroke:#0891B2,stroke-width:2px - classDef cache fill:#FCD34D,stroke:#F59E0B,stroke-width:2px + classDef service fill:#4ECDC4,stroke:#14B8A6,stroke-width:2px classDef queue fill:#FB923C,stroke:#EA580C,stroke-width:2px - classDef db fill:#A78BFA,stroke:#8B5CF6,stroke-width:2px,color:#fff classDef external fill:#E5E7EB,stroke:#9CA3AF,stroke-width:2px - class Mobile client - class Gateway gateway - class UserSvc user - class EventSvc event - class AISvc ai - class ContentSvc content - class DistSvc dist - class PartSvc part - class AnalSvc anal - class Cache cache + class UserSvc,EventSvc,AISvc,ContentSvc,DistSvc,PartSvc,AnalSvc service class Queue queue - class UserDB,EventDB,PartDB,AnalDB db - class TaxAPI,ClaudeAPI,SDAPI,UriAPI,RingoAPI,GenieAPI,SNSAPI external + class External external