Snug Hub
Snug Hub
Main.py
from fastapi import FastAPI from chat import chat_router from matchmaking import
matchmaking_router from user_management import user_router from user_onboarding
import onboarding_router from ai_chatbot import chatbot_router from
next_question_prompting import question_prompt_router from social_sharing import
social_sharing_router from push_notifications import notifications_router
app = FastAPI()
Dataase.py
Matchmaking.py
from fastapi import APIRouter from database import user_profiles, chat_rooms import
random
def calculate_compatibility(user1: str, user2: str) -> int: if not user1 or not user2 or user1
== user2: return 0
score = 0
if user1_data.get("zodiac") == user2_data.get("zodiac"):
score += 20
if user1_data.get("mbti") == user2_data.get("mbti"):
score += 30
chat_history = chat_rooms.get(f"room-{user1}-{user2}",
{}).get("messages", [])
score += len(chat_history) * 2 # Increase score based on chat
frequency
return score
matchmaking_router = APIRouter()
@matchmaking_router.get("/") def matchmaking(email: str): user_data =
user_profiles.get(email, {}) potential_matches = [ { "username": data.get("username",
"MysticUser"), "zodiac": data.get("zodiac", "Unknown"), "mbti": data.get("mbti",
"Unknown"), "compatibility_score": calculate_compatibility(email, data.get("email")) } for
_, data in user_profiles.items() ]
Chat.py
from fastapi import APIRouter from database import chat_rooms import datetime
chat_router = APIRouter()
User management.py
user_router = APIRouter()
Utils.py
import random
def generate_username():
return f"{random.choice(adjectives)}{random.choice(animals)}"
User Onboarding.py
from fastapi import APIRouter, HTTPException from database import user_profiles import
firebase_admin from firebase_admin import auth
onboarding_router = APIRouter()
@onboarding_router.post("/register/") def register_user(email: str, password: str): try: user
= auth.create_user(email=email, password=password) user_profiles[email] = {"email":
email, "personality_type": None, "mbti": None, "zodiac": None} return {"message": "User
registered successfully!", "user_id": user.uid} except Exception as e: raise
HTTPException(status_code=400, detail=str(e))
User Management.py
user_router = APIRouter()
AI chatbot.py
from fastapi import APIRouter from database import user_profiles import openai
chatbot_router = APIRouter()
user_data = user_profiles[email]
context = f"Personality Type: {user_data.get('personality_type',
'Unknown')}, MBTI: {user_data.get('mbti', 'Unknown')}, Zodiac:
{user_data.get('zodiac', 'Unknown')}"
question_prompt_router = APIRouter()
Social Sharing.py
social_sharing_router = APIRouter()
@social_sharing_router.post("/share/") def share_insight(email: str, insight: str):
shareable_text = f"I just got this freakishly accurate reading on SnugHub! \n'{insight}'\nTry it
yourself: [link]" return {"shareable_text": shareable_text}
Push Notifications.py
notifications_router = APIRouter()
notification = messaging.Message(
notification=messaging.Notification(
title="A new insight for you!",
body=message
),
token=user_profiles[email].get("fcm_token", "")
)
response = messaging.send(notification)
return {"message": "Notification sent!", "response": response}
Requirements.py
fastapi
uvicorn
firebase-admin
openai