Skip to content

Latest commit

 

History

History
660 lines (525 loc) · 25.7 KB

File metadata and controls

660 lines (525 loc) · 25.7 KB

🩺 Arogya Assam

Smartphone-Based Anemia Screening for Rural Assam

Next.js TypeScript Tailwind CSS PostgreSQL Prisma License: MIT

Empowering ASHA workers with a free, offline-capable anemia screening tool that delivers results in under 5 minutes.

Live Demo · Report Bug · Request Feature · Contributing


Arogya Assam Hero

📋 Table of Contents


🏥 About The Project

Arogya Assam is a healthcare platform built to tackle the silent crisis of anemia in rural Assam, India. Designed for ASHA (Accredited Social Health Activist) workers, it provides a WHO-aligned symptom-based screening tool accessible from any smartphone — no internet required for screening.

Patients can also locate nearby hospitals using pincode-based search powered by OpenStreetMap, and access their results through a secure, authenticated portal.

🎯 Mission: Make anemia screening accessible, free, and fast for every village in Assam.


🔴 The Problem

Statistic Detail
50%+ Women in Assam are anemic (NFHS-5)
67% Children under 5 are anemic
Limited Access to diagnostic labs in rural areas
Low Awareness about anemia symptoms

Traditional screening requires blood tests, lab equipment, and trained technicians — resources scarce in rural Assam. Arogya Assam bridges this gap with a digital-first, symptom-based approach.


📸 Screenshots

Landing Page

Landing Page

Anemia Screening Tool

Screening Tool

Hospital Finder

Hospital Finder

Authentication

Sign In Sign Up
Sign In Sign Up

Mobile View

Home Screening Results
Mobile Home Mobile Screening Mobile Results

🏗 Architecture

┌─────────────────────────────────────────────────────────────────┐
│                         CLIENT (Browser)                        │
│                                                                 │
│  ┌──────────┐  ┌──────────┐  ┌──────────┐  ┌───────────────┐   │
│  │ Landing  │  │ Screening│  │   Auth   │  │   Hospital    │   │
│  │  Page    │  │   Tool   │  │  Pages   │  │   Finder      │   │
│  └──────────┘  └──────────┘  └──────────┘  └───────────────┘   │
│       │              │             │               │            │
└───────┼──────────────┼─────────────┼───────────────┼────────────┘
        │              │             │               │
        ▼              ▼             ▼               ▼
┌─────────────────────────────────────────────────────────────────┐
│                      NEXT.JS 16 SERVER                          │
│                                                                 │
│  ┌─────────────────────────────────────────────────────────┐    │
│  │                    Middleware Layer                       │    │
│  │            (Route Protection & Auth Guards)               │    │
│  └─────────────────────────────────────────────────────────┘    │
│                              │                                   │
│  ┌──────────────┐  ┌────────┴────────┐  ┌──────────────────┐   │
│  │  Better Auth │  │   API Routes    │  │  Server Actions  │   │
│  │   Handler    │  │  /api/auth/*    │  │                  │   │
│  └──────┬───────┘  └────────┬────────┘  └────────┬─────────┘   │
│         │                   │                     │              │
└─────────┼───────────────────┼─────────────────────┼──────────────┘
          │                   │                     │
          ▼                   ▼                     ▼
┌─────────────────┐  ┌───────────────┐  ┌─────────────────────┐
│   PostgreSQL    │  │  OpenStreetMap│  │   External Auth     │
│   (Neon DB)     │  │  Nominatim + │  │  ┌───────┐ ┌──────┐ │
│                 │  │  Overpass API │  │  │Google │ │GitHub│ │
│  ┌───────────┐  │  └───────────────┘  │  │ OAuth │ │OAuth │ │
│  │   Users   │  │                     │  └───────┘ └──────┘ │
│  │ Sessions  │  │  ┌───────────────┐  └─────────────────────┘
│  │ Accounts  │  │  │    Resend     │
│  │Verification│ │  │ (Email API)   │
│  └───────────┘  │  └───────────────┘
└─────────────────┘

Request Flow

User Request
     │
     ▼
┌──────────┐    ┌──────────────┐    ┌─────────────┐
│ Next.js  │───▶│  Middleware   │───▶│  Page/API   │
│  Router  │    │ (Auth Check) │    │   Handler   │
└──────────┘    └──────────────┘    └──────┬──────┘
                                           │
                    ┌──────────────────────┬┘
                    ▼                      ▼
             ┌─────────────┐      ┌──────────────┐
             │  Prisma ORM │      │ OpenStreetMap│
             │  (Database) │      │     APIs     │
             └─────────────┘      └──────────────┘

Screening Algorithm Flow

Start Screening
       │
       ▼
┌──────────────┐
│  10 Clinical │
│  Questions   │
│  (EN + AS)   │
└──────┬───────┘
       │
       ▼
┌──────────────┐
│ Risk Score   │
│ Calculation  │
│  (0 - 100)   │
└──────┬───────┘
       │
       ├── Score ≤ 30  ──▶ 🟢 Low Risk
       │
       ├── Score 31-60 ──▶ 🟡 Medium Risk
       │
       └── Score > 60  ──▶ 🔴 High Risk
                               │
                               ▼
                        ┌──────────────┐
                        │ Recommend    │
                        │ Nearby       │
                        │ Hospitals    │
                        └──────────────┘

⚙ Tech Stack

Frontend

Technology Purpose
Next.js React Framework (App Router)
React UI Library
TypeScript Type Safety
Tailwind Styling
Shadcn Component Library
Recharts Data Visualization
Lucide Icons

Backend

Technology Purpose
Better Auth Authentication Framework
Prisma Database ORM
PostgreSQL Database
Zod Schema Validation
Bcrypt Password Hashing

Services & APIs

Technology Purpose
OpenStreetMap Hospital Geolocation
Google Maps Navigation Links
Resend Email Service
Upstash Rate Limiting

DevOps & Tooling

Technology Purpose
Neon Serverless PostgreSQL
ESLint Code Linting
Turbopack Dev Server Bundler

✨ Features

Core Features

Feature Description Status
🩺 Anemia Screening 10-question WHO-aligned symptom assessment ✅ Live
🌐 Bilingual Support English + Assamese (অসমীয়া) ✅ Live
📊 Risk Scoring Clinical scoring algorithm (0-100 scale) ✅ Live
🏥 Hospital Finder Pincode-based nearby hospital search ✅ Live
🗺 Navigation Google Maps integration for directions ✅ Live
🔐 Authentication Email/password + Google & GitHub OAuth ✅ Live
📱 Responsive Design Mobile-first UI for smartphone users ✅ Live
Offline Screening Screening works without internet ✅ Live

Screening Questions Include

  • Age group classification
  • Fatigue level assessment (1-5 scale)
  • Breathlessness detection
  • Dizziness/lightheadedness check
  • Pica/unusual cravings indicator
  • Heart palpitation assessment
  • Pallor severity (none/mild/severe)
  • Iron-rich food intake frequency
  • Menstrual bleeding assessment
  • Recent blood loss history

🚀 Getting Started

Prerequisites

Installation

# 1. Clone the repository
git clone https://github.com/<your-username>/arogya-assam.git
cd arogya-assam

# 2. Install dependencies
npm install

# 3. Set up environment variables
cp .env.example .env
# Edit .env with your credentials (see Environment Variables section)

# 4. Set up the database
npx prisma generate
npx prisma db push

# 5. Start the development server
npm run dev

Open http://localhost:3000 in your browser.

Build for Production

npm run build
npm start

🔑 Environment Variables

Create a .env file in the root directory with the following variables:

# ──────────────── Database ────────────────
DATABASE_URL="postgresql://user:password@host:5432/arogya_assam"

# ──────────────── Authentication ────────────────
BETTER_AUTH_SECRET="your-secret-key-min-32-chars"
BETTER_AUTH_URL="http://localhost:3000"

# ──────────────── Google OAuth ────────────────
GOOGLE_CLIENT_ID="your-google-client-id"
GOOGLE_CLIENT_SECRET="your-google-client-secret"

# ──────────────── GitHub OAuth ────────────────
GITHUB_CLIENT_ID="your-github-client-id"
GITHUB_CLIENT_SECRET="your-github-client-secret"

# ──────────────── Email (Optional) ────────────────
RESEND_API_KEY="your-resend-api-key"

# ──────────────── App URLs ────────────────
NEXT_PUBLIC_APP_URL="http://localhost:3000"
NEXT_PUBLIC_BETTER_AUTH_URL="http://localhost:3000"

Important: Never commit your .env file. It is already included in .gitignore.


🗄 Database Setup

Schema Overview

model User {
  id            String    @id
  name          String
  email         String    @unique
  emailVerified Boolean
  image         String?
  sessions      Session[]
  accounts      Account[]
}

model Session {
  id        String   @id
  token     String   @unique
  expiresAt DateTime
  ipAddress String?
  userAgent String?
  userId    String   → User
}

model Account {
  id           String  @id
  provider     String         // google, github, credential
  accessToken  String?
  refreshToken String?
  userId       String  → User
}

model Verification {
  id         String   @id
  identifier String
  value      String
  expiresAt  DateTime
}

Database Commands

# Generate Prisma client
npx prisma generate

# Push schema to database
npx prisma db push

# Open Prisma Studio (GUI)
npx prisma studio

# Create a migration
npx prisma migrate dev --name init

📁 Project Structure

arogya-assam/
├── app/                          # Next.js App Router
│   ├── layout.tsx                # Root layout (fonts, theme, providers)
│   ├── page.tsx                  # Landing page
│   ├── screen/
│   │   └── page.tsx              # Anemia screening questionnaire
│   ├── result/
│   │   └── page.tsx              # Screening results display
│   ├── hospitals/
│   │   └── page.tsx              # Hospital finder (protected)
│   ├── dashboard/
│   │   └── page.tsx              # Patient dashboard (protected)
│   ├── signin/
│   │   └── page.tsx              # Sign in page
│   ├── signup/
│   │   └── page.tsx              # Sign up page
│   ├── soon/
│   │   └── page.tsx              # Coming soon page
│   └── api/
│       └── auth/
│           └── [...all]/route.ts # Better Auth API handler
│
├── components/
│   ├── landing/                  # Landing page components
│   │   ├── navbar.tsx            # Navigation header
│   │   ├── hero.tsx              # Hero section
│   │   ├── problem.tsx           # Problem statement
│   │   ├── solution.tsx          # Solution showcase
│   │   ├── faq.tsx               # FAQ accordion
│   │   └── footer.tsx            # Footer with contact info
│   └── ui/                       # shadcn/ui components
│       ├── button.tsx
│       ├── card.tsx
│       ├── input.tsx
│       └── ...
│
├── lib/                          # Utility & config modules
│   ├── auth.ts                   # Better Auth server config
│   ├── auth-client.ts            # Better Auth client config
│   ├── db.ts                     # Prisma client singleton
│   ├── openstreetmap.ts          # Hospital geolocation API
│   ├── password.ts               # Bcrypt hash/compare
│   ├── token.ts                  # Verification token generator
│   ├── validators.ts             # Zod schemas
│   └── utils.ts                  # Class name utility
│
├── hooks/
│   └── use-mobile.ts             # Mobile viewport detection
│
├── prisma/
│   └── schema.prisma             # Database schema
│
├── types/
│   └── bcrypt.d.ts               # Type declarations
│
├── middleware.ts                  # Route protection middleware
├── package.json
├── tailwind.config.ts
├── tsconfig.json
└── next.config.ts                # Next.js config (Turbopack)

🔌 API Reference

Authentication Endpoints

All auth routes are handled by Better Auth at /api/auth/*:

Method Endpoint Description
POST /api/auth/sign-up/email Register with email/password
POST /api/auth/sign-in/email Sign in with email/password
GET /api/auth/sign-in/social?provider=google Google OAuth
GET /api/auth/sign-in/social?provider=github GitHub OAuth
POST /api/auth/sign-out Sign out
GET /api/auth/session Get current session

OpenStreetMap Integration

Function Description
getPincodeCoordinate(pincode) Converts 6-digit Indian pincode to lat/lon
getHospotialsNearby(coords, radius) Queries Overpass API for hospitals within radius
formatHospitalData(hospitals, userCoords) Calculates distance & formats results
calculateDistance(lat1, lon1, lat2, lon2) Haversine formula for distance

🤝 Contributing

Contributions make the open-source community an incredible place to learn, inspire, and create. Any contribution you make is greatly appreciated.

How to Contribute

  1. Fork the repository
  2. Clone your fork
    git clone https://github.com/<your-username>/arogya-assam.git
  3. Create a feature branch
    git checkout -b feature/amazing-feature
  4. Make your changes and commit
    git commit -m "feat: add amazing feature"
  5. Push to your branch
    git push origin feature/amazing-feature
  6. Open a Pull Request

Commit Convention

We follow Conventional Commits:

Prefix Usage
feat: New feature
fix: Bug fix
docs: Documentation only
style: Formatting, no code change
refactor: Code refactoring
test: Adding tests
chore: Maintenance tasks

Code Guidelines

  • Use TypeScript for all new files
  • Follow existing code style and patterns
  • Use shadcn/ui for new UI components
  • Write meaningful commit messages
  • Test your changes locally before submitting a PR
  • Keep PRs focused — one feature/fix per PR

🗺 Feature Roadmap

Looking for something to work on? Here are features we'd love help with:

🟢 Good First Issues

  • Add loading skeleton for landing page
  • Improve form accessibility (ARIA labels)
  • Add more FAQ questions
  • Dark mode toggle improvements
  • Add Assamese translations for hospital finder page

🟡 Medium Complexity

  • Patient Medical Records — Store and view screening history
  • PDF Report Generation — Download screening results as PDF
  • PWA Support — Full offline capability with service worker
  • SMS Notifications — Send results via SMS for non-smartphone users
  • Admin Dashboard — Analytics for ASHA workers and health officials
  • Multi-language — Add Hindi, Bengali, and other regional languages
  • Screening History Chart — Recharts-based visualization of past screenings

🔴 Advanced Features

  • AI Health Assistant — Chatbot for health queries using LLM
  • Telemedicine Chat — Real-time chat with hospital staff
  • Appointment Booking — Schedule visits with nearby hospitals
  • Blood Bank Finder — Locate blood banks with availability
  • Emergency SOS — One-tap emergency services with location sharing
  • ASHA Worker Portal — Dedicated portal for community health workers
  • Government Health API Integration — Connect with NHA/ABDM APIs
  • Wearable Device Integration — Sync with health monitoring devices

Architecture Improvements

  • Add unit tests (Jest + React Testing Library)
  • Add E2E tests (Playwright)
  • Set up CI/CD pipeline (GitHub Actions)
  • Add rate limiting to API routes (Upstash Redis is ready)
  • Implement proper error boundaries
  • Add Sentry for error monitoring
  • Docker containerization

📄 License

Distributed under the MIT License. See LICENSE for more information.

MIT License

Copyright (c) 2025 Arogya Assam

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

📬 Contact

Project Maintainer: Yash Sharma

Project Link: https://github.com/your-username/arogya-assam


🙏 Acknowledgements


Built with ❤️ for the people of Assam

⭐ Star this repo if you found it useful!