Soulcompass / app.py
Rong6693's picture
Create app.py
0b08044 verified
raw
history blame
23 kB
# ==================== SoulCompass International - Complete App ====================
import streamlit as st
import json
import random
import hashlib
from datetime import datetime, timedelta
import pandas as pd
import plotly.express as px
from urllib.parse import quote
# 多語言配置
LANGUAGES = {
“🇺🇸 English”: “en”,
“🇨🇳 中文”: “zh”,
“🇪🇸 Español”: “es”,
“🇫🇷 Français”: “fr”,
“🇩🇪 Deutsch”: “de”,
“🇯🇵 日本語”: “ja”,
“🇰🇷 한국어”: “ko”,
“🇮🇳 हिन्दी”: “hi”
}
# 多語言文本內容
TRANSLATIONS = {
“en”: {
“app_title”: “🧭 SoulCompass - Find Your Inner North Star”,
“tagline”: “Tarot Reading | Numerology | Soul Journal | AI Therapist”,
“main_header”: “SoulCompass”,
“sub_header”: “Find Your Inner North Star”,
“features_desc”: “🔮 Tarot Reading | 🔢 Numerology | 📖 Soul Journal | 🤖 AI Therapist”,
“user_stats”: “15,247 users trust us”,
“rating”: “4.9/5 rating”,
“satisfaction”: “98.3% satisfaction”,
```
# Navigation
"nav_tarot": "🔮 Tarot Reading",
"nav_numerology": "🔢 Numerology",
"nav_journal": "📖 Soul Journal",
"nav_ai_therapist": "🤖 AI Therapist",
"nav_testimonials": "💬 Testimonials",
"nav_faq": "❓ FAQ",
# Tarot Section
"tarot_title": "🔮 Tarot Reading - Explore Life's Questions",
"tarot_desc": "Let ancient tarot wisdom guide your life's direction",
"question_placeholder": "Example: I'm facing difficulties at work and don't know which path to choose next...",
"question_label": "💭 Please describe your question in detail",
"spread_label": "Choose Tarot Spread",
"start_reading": "🔮 Start Tarot Reading",
"reading_complete": "✨ Reading Complete!",
"remaining_quota": "Remaining free readings today",
"quota_exceeded": "😔 Daily free quota exceeded! Come back tomorrow or upgrade to Pro",
# Spreads
"single_card": "Single Card - Quick Guidance",
"three_card": "Three Cards - Past Present Future",
"love_triangle": "Love Triangle - Relationship Focus",
"career_cross": "Career Cross - Work Development",
# Numerology Section
"numerology_title": "🔢 Numerology - Decode Your Life Numbers",
"numerology_desc": "Discover your life's mysteries through the power of numbers",
"life_number_title": "📅 Life Path Number Calculation",
"birth_date_label": "Select your birth date",
"calculate_life_number": "🌟 Calculate Life Number",
"name_numerology_title": "📝 Name Numerology",
"name_input_label": "Enter your full name",
"calculate_name_number": "✨ Analyze Name Number",
# Journal Section
"journal_title": "📖 Soul Journal - Record Your Inner Growth",
"journal_desc": "Track your emotional journey and connect with your inner self",
"mood_today": "🌈 Today's Mood Record",
"mood_score": "Today's mood score",
"main_emotion": "Primary emotion",
"energy_level": "Energy level",
"gratitude": "What are you grateful for today",
"journal_content": "📝 Today's Soul Journal Entry",
"journal_placeholder": "Write about your thoughts, feelings, experiences, or anything you want to record today...",
"save_journal": "💾 Save Today's Journal",
"journal_saved": "✅ Journal saved! Another precious record added to your soul's growth journey 🌱",
# AI Therapist Section
"ai_therapist_title": "🤖 AI Therapist - Soul Conversation Companion",
"ai_therapist_desc": "24/7 soul guide providing warm support and guidance",
"ai_intro_title": "SoulCompass AI Therapist",
"ai_intro_desc": "Your dedicated soul guide, always here to provide support and companionship",
"conversation_topics": "🎯 Choose conversation topic",
"general_chat": "💭 General Soul Conversation",
"stress_anxiety": "😰 Stress & Anxiety Support",
"relationship": "💔 Relationship Counseling",
"life_goals": "🎯 Life Goals Discussion",
"meditation": "🧘 Meditation & Relaxation",
"personal_growth": "🌱 Personal Growth Advice",
"chat_placeholder": "Tell me how you're feeling, or what you'd like to discuss...",
"start_conversation": "💫 Start Conversation",
# Emotions
"emotion_happy": "😊 Happy",
"emotion_sad": "😔 Sad",
"emotion_anxious": "😰 Anxious",
"emotion_angry": "😡 Angry",
"emotion_calm": "😌 Calm",
"emotion_grateful": "🤗 Grateful",
"emotion_tired": "😴 Tired",
"emotion_confused": "🤔 Confused",
# Common UI Elements
"loading": "Loading...",
"please_wait": "Please wait...",
"error": "An error occurred",
"success": "Success!",
"try_again": "Please try again",
"back": "Back",
"next": "Next",
"cancel": "Cancel",
"confirm": "Confirm",
"close": "Close",
# FAQ
"faq_title": "❓ Frequently Asked Questions",
"faq_1_q": "Is SoulCompass really free?",
"faq_1_a": "Yes! We provide 5 completely free readings daily, no registration or payment required.",
"faq_2_q": "How accurate is the AI tarot reading?",
"faq_2_a": "Our AI system combines traditional tarot wisdom with modern data analysis, achieving 94.7% accuracy.",
"faq_3_q": "What types of questions can I ask?",
"faq_3_a": "You can ask about love, career, finances, health, relationships, or any life question.",
# Testimonials
"testimonials_title": "💬 User Testimonials",
"testimonial_1": "SoulCompass tarot readings are incredibly accurate! The AI interpretation perfectly matched my situation.",
"testimonial_2": "As a tarot enthusiast, I've tried many websites. SoulCompass has the most in-depth readings!",
"testimonial_3": "The numerology analysis was surprisingly accurate! SoulCompass really helped me find direction!",
# Pro Version
"upgrade_pro": "💎 Upgrade to Pro",
"pro_features": "Pro Features",
"unlimited_readings": "Unlimited readings",
"detailed_reports": "Detailed reports",
"full_history": "Complete history",
"priority_support": "Priority support",
"early_bird_price": "Early bird price: $6.99/month"
},
"zh": {
"app_title": "🧭 SoulCompass 心靈羅盤 - 找到內心的北極星",
"tagline": "塔羅占卜 | 數字占卜 | 心靈日記 | AI療癒師",
"main_header": "SoulCompass 心靈羅盤",
"sub_header": "找到內心的北極星",
"features_desc": "🔮 塔羅占卜 | 🔢 數字占卜 | 📖 心靈日記 | 🤖 AI療癒師",
"user_stats": "15,247 用戶信任",
"rating": "4.9/5 評分",
"satisfaction": "98.3% 滿意度",
# Navigation
"nav_tarot": "🔮 塔羅占卜",
"nav_numerology": "🔢 數字占卜",
"nav_journal": "📖 心靈日記",
"nav_ai_therapist": "🤖 AI療癒師",
"nav_testimonials": "💬 用戶見證",
"nav_faq": "❓ 常見問題",
# Tarot Section
"tarot_title": "🔮 塔羅占卜 - 探索人生問題",
"tarot_desc": "讓古老的塔羅智慧為您指引人生方向",
"question_placeholder": "例如:我最近在工作上遇到困難,不知道該如何選擇下一步...",
"question_label": "💭 請詳細描述您想要占卜的問題",
"spread_label": "選擇塔羅牌陣",
"start_reading": "🔮 開始塔羅占卜",
"reading_complete": "✨ 占卜完成!",
"remaining_quota": "今日剩餘免費占卜次數",
"quota_exceeded": "😔 今日免費額度已用完!明天再來或升級 Pro",
"single_card": "單張牌 - 快速指引",
"three_card": "三張牌 - 過去現在未來",
"love_triangle": "愛情三角 - 感情專用",
"career_cross": "事業十字 - 工作發展",
"numerology_title": "🔢 數字占卜 - 解讀生命密碼",
"numerology_desc": "透過數字的神秘力量,發現您的人生密碼",
"life_number_title": "📅 生命靈數計算",
"birth_date_label": "選擇您的出生日期",
"calculate_life_number": "🌟 計算生命靈數",
"name_numerology_title": "📝 姓名數字學",
"name_input_label": "輸入您的姓名",
"calculate_name_number": "✨ 分析姓名數字",
"journal_title": "📖 心靈日記 - 記錄內心成長",
"journal_desc": "追蹤情緒軌跡,與內在自我深度對話",
"mood_today": "🌈 今日心情記錄",
"mood_score": "今日心情指數",
"main_emotion": "主要情緒",
"energy_level": "能量水平",
"gratitude": "今日感恩的事",
"journal_content": "📝 今日心靈日記",
"journal_placeholder": "寫下今天的想法、感受、經歷或任何想記錄的內容...",
"save_journal": "💾 保存今日日記",
"journal_saved": "✅ 日記已保存!您的心靈成長軌跡又增加了珍貴的一筆記錄 🌱",
"ai_therapist_title": "🤖 AI療癒師 - 心靈對話陪伴",
"ai_therapist_desc": "24小時陪伴的心靈導師,提供溫暖支持",
"ai_intro_title": "SoulCompass AI 療癒師",
"ai_intro_desc": "您的專屬心靈導師,隨時為您提供支持與陪伴",
"conversation_topics": "🎯 選擇對話主題",
"general_chat": "💭 一般心靈對話",
"stress_anxiety": "😰 壓力焦慮疏導",
"relationship": "💔 感情問題諮詢",
"life_goals": "🎯 人生目標探討",
"meditation": "🧘 冥想放鬆指導",
"personal_growth": "🌱 自我成長建議",
"chat_placeholder": "告訴我您現在的感受,或想要討論的問題...",
"start_conversation": "💫 開始對話"
}
```
}
# 頁面配置
st.set_page_config(
page_title=“🧭 SoulCompass - Find Your Inner North Star | International”,
page_icon=“🧭”,
layout=“wide”,
initial_sidebar_state=“collapsed”
)
# 初始化語言設定
if ‘language’ not in st.session_state:
st.session_state.language = ‘en’
if ‘daily_usage’ not in st.session_state:
st.session_state.daily_usage = 0
if ‘reading_history’ not in st.session_state:
st.session_state.reading_history = []
if ‘journal_entries’ not in st.session_state:
st.session_state.journal_entries = []
def get_text(key):
“”“獲取當前語言的文本”””
lang = st.session_state.language
return TRANSLATIONS.get(lang, TRANSLATIONS[‘en’]).get(key, key)
def change_language(selected_lang):
“”“切換語言”””
lang_code = LANGUAGES[selected_lang]
st.session_state.language = lang_code
# SoulCompass 國際版 CSS
def load_international_css():
st.markdown(”””
<style>
@import url(‘https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Cinzel:wght@400;500;600&display=swap’);
```
:root {
--primary-color: #6366F1;
--secondary-color: #F59E0B;
--accent-color: #C084FC;
--dark-blue: #1E3A8A;
--text-primary: #1F2937;
--text-secondary: #6B7280;
--background-light: #F8FAFC;
}
.soulcompass-international-header {
text-align: center;
background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
color: white;
padding: 4rem 2rem;
border-radius: 20px;
margin-bottom: 2rem;
box-shadow: 0 20px 40px rgba(99, 102, 241, 0.3);
position: relative;
overflow: hidden;
}
.soulcompass-international-header::before {
content: '';
position: absolute;
top: -50%;
left: -50%;
width: 200%;
height: 200%;
background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 50%);
animation: rotate 20s linear infinite;
}
@keyframes rotate {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.soulcompass-international-header h1 {
font-family: 'Cinzel', serif;
font-size: 4rem;
font-weight: 600;
margin-bottom: 1rem;
text-shadow: 2px 2px 8px rgba(0,0,0,0.3);
position: relative;
z-index: 1;
}
.compass-icon {
font-size: 5rem;
margin-bottom: 1rem;
display: inline-block;
animation: compass-spin 3s ease-in-out infinite;
}
@keyframes compass-spin {
0%, 100% { transform: rotate(-10deg); }
50% { transform: rotate(10deg); }
}
.international-feature-card {
background: white;
border-radius: 20px;
padding: 2.5rem;
box-shadow: 0 10px 30px rgba(0,0,0,0.1);
border: 2px solid transparent;
transition: all 0.3s ease;
height: 100%;
text-align: center;
}
.international-feature-card:hover {
border-color: var(--primary-color);
transform: translateY(-5px);
box-shadow: 0 20px 40px rgba(99, 102, 241, 0.2);
}
.feature-icon {
font-size: 4rem;
margin-bottom: 1.5rem;
display: block;
}
.global-stats {
background: linear-gradient(135deg, #F8FAFC 0%, #E2E8F0 100%);
border-radius: 20px;
padding: 2rem;
margin: 2rem 0;
display: flex;
justify-content: space-around;
align-items: center;
flex-wrap: wrap;
}
.stat-item {
text-align: center;
margin: 1rem;
}
.stat-number {
font-size: 3rem;
font-weight: 700;
color: var(--primary-color);
display: block;
font-family: 'Inter', sans-serif;
}
.stat-label {
color: var(--text-secondary);
font-size: 1rem;
margin-top: 0.5rem;
font-weight: 500;
}
.tarot-card-international {
background: linear-gradient(135deg, var(--dark-blue) 0%, var(--primary-color) 100%);
border: 3px solid var(--secondary-color);
border-radius: 20px;
padding: 2rem;
color: white;
text-align: center;
box-shadow: 0 15px 35px rgba(0,0,0,0.3);
transition: all 0.4s ease;
min-width: 220px;
min-height: 320px;
position: relative;
overflow: hidden;
margin: 1rem;
}
.tarot-card-international::before {
content: '✨';
position: absolute;
top: 15px;
right: 20px;
font-size: 2rem;
opacity: 0.8;
}
.tarot-card-international:hover {
transform: translateY(-10px) scale(1.02);
box-shadow: 0 25px 50px rgba(99, 102, 241, 0.4);
}
.reading-result-international {
background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
color: white;
padding: 3rem;
border-radius: 20px;
margin: 2rem 0;
box-shadow: 0 15px 35px rgba(99, 102, 241, 0.3);
position: relative;
}
.reading-result-international::before {
content: '🔮';
position: absolute;
top: 25px;
right: 30px;
font-size: 2.5rem;
opacity: 0.8;
}
.quota-display-international {
background: linear-gradient(135deg, var(--secondary-color) 0%, #FB923C 100%);
color: white;
padding: 1.5rem 3rem;
border-radius: 50px;
text-align: center;
font-weight: 600;
font-size: 1.2rem;
box-shadow: 0 8px 20px rgba(245, 158, 11, 0.3);
margin: 2rem auto;
max-width: 600px;
}
.testimonial-international {
background: linear-gradient(135deg, #FFF7ED 0%, #FEF3C7 100%);
border-left: 5px solid var(--secondary-color);
padding: 2rem;
border-radius: 15px;
margin: 1.5rem 0;
box-shadow: 0 4px 15px rgba(245, 158, 11, 0.1);
}
.faq-item-international {
background: white;
border: 2px solid #E5E7EB;
border-radius: 15px;
margin: 20px 0;
padding: 2rem;
box-shadow: 0 4px 15px rgba(0,0,0,0.05);
transition: all 0.3s ease;
}
.faq-item-international:hover {
border-color: var(--primary-color);
box-shadow: 0 8px 25px rgba(99, 102, 241, 0.1);
}
.faq-question-international {
font-weight: 600;
color: var(--text-primary);
margin-bottom: 15px;
font-size: 1.2rem;
}
.faq-answer-international {
color: var(--text-secondary);
line-height: 1.7;
font-size: 1.1rem;
}
/* Responsive Design */
@media (max-width: 768px) {
.soulcompass-international-header h1 {
font-size: 2.5rem;
}
.compass-icon {
font-size: 3rem;
}
.global-stats {
flex-direction: column;
}
.stat-item {
margin: 0.5rem;
}
}
</style>
""", unsafe_allow_html=True)
```
# 塔羅牌數據
TAROT_CARDS_EN = {
“The Fool”: {“meaning”: “New beginnings, adventure, innocence”, “description”: “Represents the beginning of a life journey, symbolizing infinite possibilities”},
“The Magician”: {“meaning”: “Creativity, skill, willpower”, “description”: “Has all the tools needed to achieve goals”},
“The High Priestess”: {“meaning”: “Intuition, mystery, inner wisdom”, “description”: “Represents inner wisdom and intuitive guidance”},
“The Empress”: {“meaning”: “Fertility, motherhood, creation”, “description”: “Symbolizes maternal energy and creativity”},
“The Emperor”: {“meaning”: “Authority, structure, control”, “description”: “Represents authority and order”},
“The Hierophant”: {“meaning”: “Spiritual guidance, tradition”, “description”: “Provides spiritual guidance and wisdom”},
“The Lovers”: {“meaning”: “Love, relationships, choices”, “description”: “Symbolizes love and important choices”},
“The Chariot”: {“meaning”: “Victory, willpower, control”, “description”: “Achieving victory through determination”},
“Strength”: {“meaning”: “Inner strength, courage”, “description”: “Symbolizes inner courage and gentle strength”},
“The Hermit”: {“meaning”: “Introspection, searching, wisdom”, “description”: “Represents inner exploration and seeking wisdom”},
“Wheel of Fortune”: {“meaning”: “Fate, cycles, change”, “description”: “Symbolizes life’s cycles and transformation”},
“Justice”: {“meaning”: “Fairness, balance, truth”, “description”: “Represents fairness and moral choices”},
“The Hanged Man”: {“meaning”: “Sacrifice, pause, new perspective”, “description”: “Gaining new insights through letting go”},
“Death”: {“meaning”: “Transformation, endings, rebirth”, “description”: “Represents endings and new beginnings”},
“Temperance”: {“meaning”: “Balance, patience, harmony”, “description”: “Teaching balance and moderation”},
“The Devil”: {“meaning”: “Bondage, temptation, addiction”, “description”: “Symbolizes inner fears and bondage”},
“The Tower”: {“meaning”: “Sudden change, destruction, awakening”, “description”: “Represents sudden awakening and transformation”},
“The Star”: {“meaning”: “Hope, inspiration, healing”, “description”: “Symbolizes hope and guidance”},
“The Moon”: {“meaning”: “Illusion, intuition, subconscious”, “description”: “Represents subconscious and intuition”},
“The Sun”: {“meaning”: “Success, joy, vitality”, “description”: “Symbolizes success and positive energy”},
“Judgement”: {“meaning”: “Rebirth, inner calling”, “description”: “Represents spiritual awakening and rebirth”},
“The World”: {“meaning”: “Completion, achievement, fulfillment”, “description”: “Represents goal achievement and completion”}
}
TAROT_CARDS_ZH = {
“愚者”: {“meaning”: “新開始、冒險、純真”, “description”: “代表人生旅程的開始,象徵無限可能性”},
“魔術師”: {“meaning”: “創造力、技能、意志力”, “description”: “擁有實現目標的所有工具”},
“女祭司”: {“meaning”: “直覺、神秘、內在智慧”, “description”: “代表內在智慧和直覺指引”},
“皇后”: {“meaning”: “豐饒、母性、創造”, “description”: “象徵母性能量和創造力”},
“皇帝”: {“meaning”: “權威、結構、控制”, “description”: “代表權威和秩序”},
“教皇”: {“meaning”: “靈性指導、傳統”, “description”: “提供精神指導和智慧”},
“戀人”: {“meaning”: “愛情、關係、選擇”, “description”: “象徵愛情和重要選擇”},
“戰車”: {“meaning”: “勝利、意志力、控制”, “description”: “通過決心獲得勝利”},
“力量”: {“meaning”: “內在力量、勇氣”, “description”: “象徵內在勇氣和溫柔力量”},
“隱者”: {“meaning”: “內省、尋找、智慧”, “description”: “代表內在探索和智慧尋求”},
“命運之輪”: {“meaning”: “命運、循環、變化”, “description”: “象徵生命循環和轉變”},
“正義”: {“meaning”: “公正、平衡、真理”, “description”: “代表公平和道德選擇”},
“倒吊人”: {“meaning”: “犧牲、暫停、新視角”, “description”: “通過放下獲得新洞察”},
“死神”: {“meaning”: “轉變、結束、重生”, “description”: “代表結束和新開始”},
“節制”: {“meaning”: “平衡、耐心、融合”, “description”: “教導平衡和適度”},
“惡魔”: {“meaning”: “束縛、誘惑、成癮”, “description”: “象徵內在恐懼和束縛”},
“塔”: {“meaning”: “突然變化、破壞、覺醒”, “description”: “代表突然覺醒和轉變”},
“星星”: {“meaning”: “希望、靈感、治癒”, “description”: “象徵希望和指引”},
“月亮”: {“meaning”: “幻象、直覺、潛意識”, “description”: “代表潛意識和直覺”},
“太陽”: {“meaning”: “成功、喜悅、活力”, “description”: “象徵成功和正能量”},
“審判”: {“meaning”: “重生、內在呼喚”, “description”: “代表靈性覺醒和重生”},
“世界”: {“meaning”: “完成、成就、滿足”, “description”: “代表目標達成和圓滿”}
}
def get_tarot_cards():
“”“根據當前語言獲取塔羅牌數據”””
if st.session_state.language == ‘zh’:
return TAROT_CARDS_ZH
else:
return TAROT_CARDS_EN
# 語言選擇器
def render_language_selector():
“”“渲染語言選擇器”””
col1, col2, col3 = st.columns([2, 1, 1])
```
with col3:
selected_lang = st.selectbox(
"🌍 Language / 語言",
options=list(LANGUAGES.keys()),
index=0 if st.session_state.language == 'en' else 1,
key="language_selector"
)
if LANGUAGES[selected_lang] != st.session_state.language:
change_language(selected_lang)
st.rerun()
```
# 國際版主標題
def render_international_header():
“”“渲染國際版主標題”””
st.markdown(f”””
<div class="soulcompass-international-header">
<div class="compass-icon">🧭</div>
<h1>{get_text(‘main_header’)}</h1>
<h2 style="font-family: 'Inter', sans-serif; font-size: 2rem; margin: 1.5rem 0; opacity: 0.95;">{get_text(‘sub_header’)}</h2>
<div style="font-size: 1.3rem; margin: 2rem 0; opacity: 0.9;">
{get_text(‘features_desc’)}
</div>
<div class=“global-