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
- 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
- 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
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 |
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 |
- Clone the repository:
git clone https://github.com/sabzdotpy/niyaAPI.git cd niyaAPI
- Install dependencies:
pip install -r requirements.txt
- Run migrations:
python manage.py migrate
- Start the server:
python manage.py runserver
- Environment Variables:
- 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
- Create a
- 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
underGOOGLE_APPLICATION_CREDENTIALS_JSON
. - Refer to
.env.sample
for format.
- Gemini API Key
core/
— Core backend logic, AI chat, database models, admin, servicesdiagnosis/
— ML models, prediction endpoints, health datasetsml/
— Machine learning scripts and saved modelsniyabackend/
— Django project settings and configuration
For more details, see the code and comments in each app directory.