Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

CrySense 👶🎙️

AI-Powered Baby Cry Analysis & Wellness Platform

CrySense is a production-grade, clinical-style SaaS platform designed to analyze infant cries using deep learning, helping parents identify emotional states (e.g., hunger, pain, discomfort, tiredness) and track wellness trends over time. Built with a React/Vite frontend, FastAPI backend, and Supabase database.


🚀 Key Features

  • Clinical-Grade AI Classifier: Uses a custom Convolutional Neural Network (CNN) trained on Mel-frequency cepstral coefficients (MFCCs) to classify infant cry signatures.
  • Real-time Waveform Recording: Securely capture and analyze 5-second audio recordings directly in the browser with visual feedback.
  • Comprehensive Wellness Dashboard: Track historical trends, average confidence levels, and common cry reasons.
  • Production Auth System: Fully integrated email/password and Google OAuth authentication flows using Supabase PKCE flow.
  • Modern Design System: Sleek clinical-teal theme (#1B6B8A) with responsive layouts, fluid animations, and a seamless Dark Mode toggle.
  • Privacy First: Waveform features are analyzed on-the-fly and classification metadata is stored securely in your database without storing raw audio files.

📂 Project Architecture

CrySense/
├── frontend/               # React (Vite) Single Page Application
│   ├── src/
│   │   ├── components/     # Reusable UI components (Navbar, Waveform recorder, etc.)
│   │   ├── context/        # React Auth Context (Supabase state)
│   │   ├── hooks/          # Custom hooks (predictions, audio recorder, dark mode)
│   │   ├── pages/          # App screens (Dashboard, Analyze, History, Profile, Docs)
│   │   └── styles/         # Global styles and design system variables
│   └── package.json        # Frontend dependencies
├── backend/                # FastAPI Application Server
│   ├── app/
│   │   ├── routes/         # HTTP endpoints (audio upload, predictions, contact, health)
│   │   ├── services/       # Audio conversion (FFmpeg), ML inference, and DB services
│   │   ├── utils/          # Config parser, logging, and JWT verifier (HS256/ES256/RS256)
│   │   └── main.py         # FastAPI App Entrypoint
│   └── requirements.txt    # Python dependencies
└── ml_pipeline/            # TensorFlow Model & Data Pipeline
    ├── saved_models/       # Pretrained CrySense CNN model (.keras)
    └── training/           # Model training and evaluation scripts

🛠️ Getting Started

Prerequisites

  • Node.js (v18 or higher)
  • Python (v3.11 or higher)
  • FFmpeg (The backend uses static-ffmpeg to automate paths, but local installation is recommended for fallback)

Setup Instructions

1. Setup your Database (Supabase)

Create a new project on Supabase and run the supabase_migration.sql file in the SQL Editor to set up the schema:

  • profiles: Stores user names and timestamps linked to auth.
  • predictions: Stores classification results, timestamps, and confidence scores.

Enable Google Provider under Authentication -> Providers -> Google in the Supabase Dashboard if you wish to support Google OAuth login.

2. Configure Environment Variables

Create a .env file in the root folder:

CRYSENSE_ENVIRONMENT=development
CRYSENSE_SUPABASE_URL=https://<your-project-ref>.supabase.co
CRYSENSE_SUPABASE_SERVICE_KEY=<your-service-role-key>
CRYSENSE_SUPABASE_JWT_SECRET=<your-jwt-secret-or-key-id>
CRYSENSE_CORS_ORIGINS=["http://127.0.0.1:5173","http://localhost:5173"]

Create a .env file in the frontend/ folder:

VITE_SUPABASE_URL=https://<your-project-ref>.supabase.co
VITE_SUPABASE_ANON_KEY=<your-anon-key>
VITE_API_BASE_URL=http://127.0.0.1:8000

Note: The backend verifier automatically handles both legacy symmetric HS256 and modern asymmetric ES256 / RS256 keys generated by newer Supabase projects.


Running the Project

Start the Backend API

  1. Navigate to the root directory and activate your Python virtual environment:
    # Windows
    .\.venv\Scripts\activate
  2. Install dependencies:
    pip install -r backend/requirements.txt
  3. Run the Uvicorn development server:
    python -m uvicorn backend.app.main:app --reload
    The backend API will be running at http://127.0.0.1:8000. You can inspect documentation at http://127.0.0.1:8000/docs.

Start the Frontend App

  1. Navigate to the frontend/ directory:
    cd frontend
  2. Install dependencies:
    npm install
  3. Run the Vite development server:
    npm run dev
    Open http://127.0.0.1:5173 in your browser to view the application.

🔒 Security & Verification

  • Token Verification: API endpoints are secured using Bearer JWT authentication linked to Supabase users.
  • Security Headers: Integrated FastAPI middleware enforces security policies (XSS blocks, Frame restrictions, MIME sniffing protection, CORS limits).
  • Build Optimization: The frontend utilizes Vite's Rollup configuration to compile assets cleanly, yielding a lightweight CSS size (~34.5 KB) and optimal bundle sizes.

📄 License

This project is private and proprietary. All rights reserved.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages