Toku Kaigan

Empowering accessible mental wellness with a gamified anime style AI psychiatrist that delivers personalized, adaptive care and real-time progress insights in a TEE(Trusted Execution Environment)

  • 0 Raised
  • 333 Views
  • 0 Judges

Tags

  • cypherpunks anonymoous
  • actually intelligent

Description

Toku Kaigan

Empowering accessible mental wellness with a gamified, anime-style AI psychiatrist that delivers personalized, adaptive care and real-time progress insights inside a Trusted Execution Environment (TEE).


Project description

Toku Kaigan is a privacy-first, AI-driven mental healthcare assistant that runs entirely inside a Phala Network TEE, so sensitive data never leaves a secure enclave. Users authenticate with a Privy wallet and maintain access via a Japan Smart Chain (JSC) smart-contract subscription (0.0001 JETH/month).

The assistant blends a robust LLM with a Gensyn Swarm of collaborating models that analyze anonymized aggregates to refine prompts and strategies, so guidance becomes more adaptive over time. A lightweight RAG pipeline (optional document uploads like journals/therapy notes) adds personal context while keeping processing inside the enclave.

To keep people engaged and increase self-awareness, Toku Kaigan turns daily interactions into manga/comic-style “memory snapshots” that visualize emotional progress. The result is a secure, stigma-reduced way to seek support: anonymous access, strong confidentiality, personalized and empathetic conversations, and gamified progress that’s easy to follow.


Technologies used

  • Next.js 15, Tailwind CSS, Hero UI (NextUI), Three.js

  • Privy (auth + embedded wallet)

  • Japan Smart Chain (smart-contract subscription, JETH)

  • Phala Network (TEE compute + attestation)

  • Ethers.js (on-chain interactions)

  • Gensyn Swarm (distributed RL/collaborating LLMs)

  • Red Pill (GPT-4o-mini in TEE)

  • Docker (containerized TEE deployment)

  • Live2D Cubism Core(Core Live2D animation engine)

  • pixi-live2d-display (PixiJS plugin for Live2D model rendering)

  • PixiJS (2D graphics rendering engine)

  • WebGL (Hardware-accelerated graphics through PixiJS)


Basic architecture

1. User Onboarding & Subscription


- Privy Wallet Login: 

  Users log in via their Privy wallet, which provides secure authentication and ease of access.


- Smart Contract-Based Subscription:

  The subscription process is executed through a Japan Smart Chain smart contract:

  - Users pay 0.0001 JETH to subscribe.

  - The contract records the payment and activates the subscription.

  - Monthly renewals are handled in the same way, ensuring continuous access.


2. Secure Processing within a TEE


- Phala Network TEE:

  All core processing—including AI interactions and data storage is conducted within a Trusted Execution Environment provided by Phala Network. This ensures:

  - Maximum data security and privacy.

  - All sensitive user data remains secure and never leaves the enclave.


- Integrated LLM:  

  The TEE hosts a robust Large Language Model (LLM) that serves as the AI psychiatrist. Additionally, models like Red Pill (ex. Deepseek that are pre-deployed in TEEs by Phala Network) can be utilized without the need for self-hosting, enhancing the system’s capabilities.


3. Dynamic Adaptive Guidance with Swarm Intelligence


- Gensyn Swarm as a Collective:

  The Gensyn Swarm represents a network of multiple LLMs collaborating in real time. It:

  - Aggregates anonymized session data and user feedback.

  - Functions as a roundtable of models, continuously refining and updating the prompt to make it better each time.


- Continuous Refinement:

  Off-chain, the swarm analyzes data from daily interactions, generating new approaches and personalized prompts. These updates are fed back into the TEE, ensuring that the LLM evolves and adapts over time based on the user's condition.


4. Retrieval-Augmented Generation (RAG) for Document Integration


- Optional Document Upload:  

  Users can optionally upload personal documents (e.g., journals, therapy notes) to provide additional context.

  - These documents are processed via a RAG pipeline.

  - It handle document parsing and information extraction, returning relevant content to enhance the AI’s contextual understanding.


- Enhanced Guidance:  

  The extracted context is combined with session data within the TEE, allowing the LLM to deliver even more targeted and empathetic advice.


5. Gamified Daily Memory & Progress Tracking


- Daily Visual Snapshots:  

  Each day, the system automatically generates a narrative story snapshot of the user's emotional state and progress.

  - These snapshots are stored securely to form a “manga”

  - Users can later review and reflect on their journey through these visual cues.

  - The images are also securely stored back in the data storage within the TEE.


- Engagement & Self-Reflection:  

Gamified progress tracking not only increases user engagement but also encourages a continuous and reflective mental health journey. Research shows that such visual feedback improves adherence, self-awareness, and long-term outcomes.


6. Data Flow & Feedback Loop


- Inbound Data Flow:  

  - User interactions, session feedback, and optional document uploads are securely processed inside the TEE.

  

- Outbound to Swarm:  

  - Anonymized session data (including daily snapshots) is periodically transmitted off-chain to the Gensyn Swarm for reinforcement learning and model updates.

  

- Inbound Updates:  

  - The refined prompts, strategies, and model parameters generated by the swarm flow back into the TEE, forming a continuous loop of improvement and personalization.


Source code

https://github.com/derek2403/ethtokyo


Deployed Link

https://d4c7da0089f4822cbf26ce287f6334247f58e04d-3000.dstack-prod8.phala.network/


Smart Contract Link

https://explorer.kaigan.jsc.dev/address/0xAb8281Eb535238eA29fC10cbc67959e0FBdb6626


Soul Bound Token Link

https://5278000.testnet.routescan.io/tx/0x2784d5256cdf0107daf2d814ae4c441fb6062a2398393fe99657c785e9941e94 

Attachments