Django REST API backend for the AviScreen Flutter application. Features user authentication via Firebase, bird flock diagnosis using AI/ML, and comprehensive API endpoints for the mobile app.
- Python 3.11+ (Recommended: 3.12.10)
- PostgreSQL 12+
- Git
- Firebase account (for credentials)
# Clone repository
git clone https://github.com/Farukhthegreat/fyp-backend.git
cd fyp-backend
# Create virtual environment
python -m venv venv
venv\Scripts\Activate.ps1
# Install dependencies
pip install -r requirements.txt
# Create local env file
# Windows PowerShell:
Copy-Item .env.example .env
# Create .env file (copy from .env.example, update config)
# Set up PostgreSQL database
# Add firebase-credentials.json to root folder
# Run migrations
python manage.py migrate
# Start server
python manage.py runserverVisit: http://127.0.0.1:8000/api/health/
Use one of these in .env:
- Local PostgreSQL mode (default): set
DB_NAME,DB_USER,DB_PASSWORD,DB_HOST,DB_PORT - Render PostgreSQL mode: set
DATABASE_URLand it will overrideDB_*automatically
This lets you test locally against the same Render Postgres instance when needed.
For detailed instructions on setting up PostgreSQL, Firebase, environment variables, and more, see:
👉 SETUP_GUIDE.md ← Read this for complete setup
This guide includes:
- ✅ PostgreSQL installation & configuration
- ✅ Firebase setup & credentials
- ✅ Environment variables configuration
- ✅ Database migrations
- ✅ Testing & verification
- ✅ Connecting Flutter app
- ✅ Troubleshooting
- ✅ Deployment checklist
fyp-backend/
├── api/ # Main application
│ ├── models.py # Database models (Flock, Diagnosis, etc.)
│ ├── views.py # API endpoints
│ ├── serializers.py # Data serialization
│ ├── authentication.py # Firebase authentication
│ ├── ai_engine.py # AI/ML diagnosis logic
│ ├── urls.py # API routes
│ └── migrations/ # Database migrations
├── fyp_backend/ # Project configuration
│ ├── settings.py # Django settings
│ ├── urls.py # URL configuration
│ └── wsgi.py # WSGI config
├── manage.py # Django CLI
├── requirements.txt # Dependencies
├── .env.example # Environment template (copy to .env)
├── firebase-credentials.json # Firebase credentials (not in repo)
├── README.md # This file
└── SETUP_GUIDE.md # Detailed setup instructions
GET /api/health/
POST /api/auth/register/
POST /api/auth/login/
POST /api/auth/logout/
GET /api/auth/user/
GET /api/flocks/ # List all flocks
POST /api/flocks/ # Create flock
GET /api/flocks/{id}/ # Get flock details
PUT /api/flocks/{id}/ # Update flock
DELETE /api/flocks/{id}/ # Delete flock
POST /api/diagnose/ # Run diagnosis
GET /api/diagnoses/ # List diagnoses
GET /api/diagnoses/{id}/ # Get diagnosis details
http://127.0.0.1:8000/admin/
(Login with superuser credentials)
# Start development server
python manage.py runserver
# Create migrations after model changes
python manage.py makemigrations
# Apply migrations
python manage.py migrate
# Create superuser (admin)
python manage.py createsuperuser
# Run tests
python manage.py test# Access PostgreSQL
psql -U aviansense_user -d aviansense_db
# Reset database
python manage.py migrate api zero
python manage.py migrate# Activate (Windows)
venv\Scripts\Activate.ps1
# Deactivate
deactivate- ✅ Firebase credentials are git-ignored (never committed)
- ✅
.envfile is git-ignored (never commit secrets) ⚠️ ChangeSECRET_KEYin production⚠️ SetDEBUG=Falsein production⚠️ Use strong database passwords⚠️ ConfigureALLOWED_HOSTSfor your domain
Update your Flutter app's API base URL:
const String API_BASE_URL = 'http://192.168.100.12:8000/api/';
// Replace 192.168.100.12 with your server's IP address- Framework: Django 6.0.2
- API: Django REST Framework 3.16.1
- Database: PostgreSQL
- Authentication: Firebase Admin SDK
- AI/ML: (Integrated in ai_engine.py)
- CORS: django-cors-headers
Common issues and solutions are documented in SETUP_GUIDE.md - Troubleshooting Section
- Check SETUP_GUIDE.md
- Review Django documentation: docs.djangoproject.com
- Check GitHub Issues: Issues
- Review code comments and docstrings
This project is part of the FYP (Final Year Project).
Ready to get started? → Follow SETUP_GUIDE.md
Last Updated: February 2026