LifeQuest Cards - Project Summary
📖 Overview
LifeQuest Cards (formerly InnerLevel) is a gamified productivity application that RPG-ifies real-life tasks. Users play as different character classes (Strategist, Warrior, Creator, Connector, Sage) and complete “Cards” (tasks) to gain XP and level up.
🏗️ Technical Architecture
1. Frontend
-
Framework: React 18 with TypeScript.
-
Build Tool: Vite.
-
Styling: Tailwind CSS (v3.3).
-
State Management: Hybrid approach using React Context API (
AppContext,AuthContext) and React Query (@tanstack/react-query). -
Key Libraries:
lucide-react(icons),framer-motion(animations),canvas-confetti.
2. Backend (Dual Service)
The project runs two backend services concurrently to handle different responsibilities. Proxies in vite.config.ts route frontend requests to the correct service.
-
Python AI Engine
-
Path:
ai_engine/main.py -
Framework: FastAPI / Uvicorn.
-
Port: 5000.
-
Responsibilities: Handles the core “Mystic Forge” feature via
/api/generate-daily-cards. Generates RPG-themed cards using OpenAI. -
Status: Active.
-
Node.js Server (Payments & Utilities)
-
Path:
server/server.js -
Framework: Express.js.
-
Port: 3000.
-
Responsibilities: Handles Stripe payments via
/create-checkout-sessionand/webhook. Also provides secondary OpenAI endpoints (/api/openai) for quota tracking. -
Status: Active.
3. Database & Auth
-
Supabase: Handles all user authentication and persistent data storage (
user_data,user_profiles,user_usages,guilds). -
Connection: Frontend connects directly using
@supabase/supabase-js.
⚙️ How It Works (Development Flow)
Service Orchestration
The command npm run dev:all uses concurrently to start three processes:
-
Vite Frontend (
localhost:5173): The UI your user interacts with. -
AI Engine (
localhost:5000): Listens for AI generation requests. -
Payment Server (
localhost:3000): Listens for payment and webhook events.
Key Data Flows
A. The “Mystic Forge” (AI Generation)
-
User clicks “Forge Cards” in the UI.
-
Frontend (
ArcaneEngine.ts) sendsPOST /api/generate-daily-cards. -
Vite Proxy forwards this to
http://localhost:5000(Python). -
Python backend constructs a prompt and calls OpenAI via
gpt-4o-mini. -
Structured RPG card data is returned to the frontend.
B. Premium Upgrade (Payments)
-
User clicks “Upgrade” in
PaymentModal.tsx. -
Frontend sends
POST /create-checkout-session. -
Vite Proxy forwards this to
http://localhost:3000(Node.js). -
Node.js backend interacts with Stripe APIs to create a session.
-
User is redirected to Stripe Checkout.
C. User Progression
-
All user data (XP, Level, Cards) is stored in Supabase.
-
AppContextloads this data on startup. -
When a card is completed, updates are optimistically applied to the UI and pushed to Supabase tables (
user_data).
⚠️ Development Considerations
1. RPG Transformation
The project utilizes a script (CLAUDE.md / transform-to-rpg.js) to enforce RPG terminology (e.g., “AI” → “Mystic Forge”, “Generate” → “Forge”). Ensure new code adheres to this “Magical/Fantasy” naming convention to maintain immersion.
2. State Migration
The codebase is in the process of migrating from heavy Context usage to React Query for server state. New data fetching features should use api.ts and React Query hooks instead of adding to AppContext.
🚀 Getting Started
- Install Dependencies:
-
npm install(Root) -
pip install -r requirements.txt(inai_engine, if exists)
- Environment Variables:
- Ensure
.envcontainsSUPABASE_URL,SUPABASE_ANON_KEY,OPENAI_API_KEY, andSTRIPE_SECRET_KEY.
- Run Development Environment:
-
npm run dev:all -
Starts Frontend (5173), Python Backend (5000), and Node Backend (3000).