Logo Lanfrica

Justdan111/coughSense-backend-main

Domaine:

healthcare

Type de record:

software
Créateur:
Jus
Hôte:
AI-powered cough sound Triage system for early detection of respiratory diseases in Nigeria. Final year project utilising machine learning to triage respiratory risks through audio classification. # CoughSense API Backend FastAPI backend for CoughSense - a cough analysis and triage system. ## Setup ### 1. Install Dependencies ```bash uv sync ``` ### 2. Configure Environment Variables Copy the example environment file and fill in your Supabase credentials: ```bash cp .env.example .env ``` Edit `.env` with your Supabase credentials: ```env SUPABASE_URL=your-project.supabase.co SUPABASE_API_KEY=your-anon-key SUPABASE_JWT_SECRET=your-jwt-secret ``` #### Getting Supabase Credentials: 1. Go to your Supabase Dashboard 2. Select your project 3. Go to **Settings** → **API** 4. Copy: - **Project URL** → `SUPABASE_URL` - **anon public** key → `SUPABASE_API_KEY` - **JWT Secret** → `SUPABASE_JWT_SECRET` ### 3. Run the Development Server ```bash uv run uvicorn app.main:app --reload ``` The API will be available at `127.0.0.1` ## API Documentation Once running, visit: - Swagger UI: `127.0.0.1` - ReDoc: `127.0.0.1` ## Authentication The API uses Supabase Auth with JWT tokens. ### Register a new user: ```bash POST /api/auth/register { "email": "user@example.com", "password": "your-password" } ``` ### Login: ```bash POST /api/auth/login { "email": "user@example.com", "password": "your-password" } ``` Returns: ```json { "access_token": "eyJhbG...", "token_type": "bearer", "user": { "id": "user-uuid", "email": "user@example.com" } } ``` ### Using Protected Endpoints: Include the token in the Authorization header: ``` Authorization: Bearer eyJhbG... ``` ### Analyze Cough (Protected): ```bash POST /api/analysis/analyze Authorization: Bearer your-token Content-Type: multipart/form-data audio: ``` ## Project Structure ``` app/ ├── api/ # API routes │ ├── auth.py # Authentication endpoints │ └── analysis.py # Cough analysis endpoints ├── core/ # Core configuration │ └── config.py # Supabase client & env vars ├── deps/ # Dependencies │ …