Skip to content

sabzdotpy/niyaAPI

Repository files navigation

NiyaAPI

NiyaAPI is a backend API built with Django, designed to power the Niya health platform. The API provides endpoints for medical diagnosis predictions using machine learning, as well as general-purpose AI chat and database management features. This project aims to deliver reliable, scalable, and intelligent backend services for healthcare applications.

🖥️ Frontend: Niya Frontend


🔷 Django Apps Overview

1. diagnosis

  • Purpose: Handles all machine learning-related features, including medical diagnosis predictions based on user symptoms.
  • Key Features:
    • ML model endpoints for predicting diseases
    • Utilizes pre-trained models and datasets
    • Data-driven health insights

2. core

  • Purpose: Manages core backend features such as database models, AI chat, and integrations (e.g., Firebase).
  • Key Features:
    • User and data management
    • AI chat endpoints (e.g., Gemini integration)
    • Admin and service utilities

🧭 API Routes

diagnosis App

Route Method Description
/diagnosis/predict/ POST Predicts disease based on symptoms (ML model)
/diagnosis/get_prec/ GET Get precautions for a predicted disease
/diagnosis/get_related_syms/ GET Get related symptoms for a given symptom
/diagnosis/get_all_syms/ GET Get all possible symptoms

core App

Route Method Description
/core/chat/ POST AI chat endpoint (Gemini integration)
/core/generate_gemini_response/ POST Generate a Gemini AI response
/core/diary_entry/ POST Create or manage a diary entry

🚀 Getting Started

  1. Clone the repository:
    git clone https://github.com/sabzdotpy/niyaAPI.git
    cd niyaAPI
  2. Install dependencies:
    pip install -r requirements.txt
  3. Run migrations:
    python manage.py migrate
  4. Start the server:
    python manage.py runserver

⚠️ MUST DO! Environment Variables & Firebase Setup

  • Environment Variables:
    1. Gemini API Key
      • Create a .env file in the project root.
      • Add Google Gemini API Key under GEMINI_API_KEY. Refer to .env.sample.
      • Example:
        GEMINI_API_KEY=your_secret_key
    2. Firebase Admin SDK
      • Go to Firebase Console > Project Settings > Service Accounts.
      • Generate a new private key and download the JSON file.
      • Add the JSON content to .env under GOOGLE_APPLICATION_CREDENTIALS_JSON.
      • Refer to .env.sample for format.

🗂️ Project Structure

  • core/ — Core backend logic, AI chat, database models, admin, services
  • diagnosis/ — ML models, prediction endpoints, health datasets
  • ml/ — Machine learning scripts and saved models
  • niyabackend/ — Django project settings and configuration

For more details, see the code and comments in each app directory.

About

Django API for niya.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published