Skip to content

DRN-X2/Aegis

Repository files navigation

Project Aegis

Mental Health Support Platform — Northern Bukidnon State College "Safety Through Pseudonymity"


Stack

  • Frontend: Ionic React + TypeScript + Capacitor
  • Backend: Supabase (PostgreSQL + Realtime + RLS)

Project Structure

project-aegis/
├── src/
│   ├── types/index.ts          # Shared TypeScript types
│   ├── services/
│   │   ├── supabaseClient.ts   # Supabase instance
│   │   ├── authService.ts      # Ghost Profile registration + session
│   │   ├── chatService.ts      # Realtime messaging
│   │   ├── moodService.ts      # Mood logging
│   │   └── sosService.ts       # SOS event logging
│   ├── hooks/
│   │   └── useAuth.ts          # Auth state hook
│   ├── utils/
│   │   ├── aliasGenerator.ts   # Deterministic alias from aegis_id
│   │   └── encryption.ts       # SHA-256 hashing + XOR obfuscation
│   ├── pages/
│   │   ├── Login.tsx           # Ghost Profile registration
│   │   ├── Home.tsx            # Dashboard
│   │   ├── Chat.tsx            # Counselor list + conversation list
│   │   ├── ChatRoom.tsx        # Realtime chat room
│   │   ├── Toolkit.tsx         # CBT exercises + mood history
│   │   ├── Profile.tsx         # Anonymous profile + privacy settings
│   │   └── SOSScreen.tsx       # Panic Shield emergency screen
│   ├── components/
│   │   ├── ChatBox.tsx         # Chat message bubble
│   │   ├── SOSButton.tsx       # SOS trigger button
│   │   ├── MoodTracker.tsx     # Emoji mood selector
│   │   ├── CounselorList.tsx   # Counselor status rows
│   │   └── ExerciseModal.tsx   # CBT exercise bottom sheet
│   ├── App.tsx                 # Router + tab nav
│   ├── global.css              # Aegis design tokens
│   └── index.tsx               # Entry point
├── supabase/
│   └── schema.sql              # Full DB schema + RLS policies
├── .env.example
├── package.json
└── tsconfig.json

Setup

1. Clone and install

npm install

2. Configure Supabase

cp .env.example .env
# Fill in REACT_APP_SUPABASE_URL and REACT_APP_SUPABASE_ANON_KEY

3. Run schema

In your Supabase project → SQL Editor → paste contents of supabase/schema.sql → Run.

Enable Realtime for the messages table: Supabase Dashboard → Database → Replication → toggle messages.

4. Run dev server

npm start

5. Build for mobile (Capacitor)

npm run build
npx cap add android   # or ios
npx cap sync
npx cap open android

Authentication Flow

  1. Student enters student_id + department on Login screen.
  2. authService hashes the ID with SHA-256.
  3. Checks students table for a matching record (pre-seeded by registrar).
  4. If found, generates a deterministic aegis_id + alias (e.g. Blue-Owl-42).
  5. Creates a profiles row — no real name stored.
  6. Session saved to localStorage (obfuscated).

Security Notes

Concern Approach
Real identity in chat Never. Only alias used in all chat tables
Student ID storage SHA-256 hashed before any DB write
Local session XOR-obfuscated in localStorage
Message privacy Auto-cleared from localStorage on session end
Row-level security Enabled on all Supabase tables

For production: replace XOR obfuscation with AES-GCM (Web Crypto API) and move student validation to a Supabase Edge Function to protect the students table with a service key.


Feature Checklist

  • Ghost Profile registration (alias + aegis_id)
  • Counselor status (online / in_session / offline)
  • Realtime encrypted chat (student ↔ counselor)
  • Panic Shield SOS with hotlines + grounding exercise
  • Mood tracker (emoji-based, logged to Supabase)
  • CBT toolkit (Box Breathing, Grounding, Thought Journal, PMR)
  • Anonymous profile with privacy toggles
  • Auto-clear local messages on session end
  • Mobile-first UI with bottom tab navigation

About

A privacy-first, mobile mental health support platform built with Ionic React and Supabase, enabling anonymous, secure, and low-bandwidth communication between students and counselors.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors