Skip to content

devansh436/feather-scan

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

152 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Feather Scan

Backend Tests License Python Node React

A full-stack image classification web application that identifies birds, plants, and animals using pretrained HuggingFace & BioCLIP machine learning models, with additional species information retrieved from internal datasets and an external LLM API when applicable.

The project focuses on backend architecture, service separation, and reliable API design rather than training custom ML models.

πŸ“‹ Table of Contents

Overview

Feather Scan is a three-service web application for classifying uploaded images as birds, plants, or animals.

It consists of a React frontend, an Express + TypeScript backend, and a FastAPI-based ML inference service. The backend handles authentication, validation, file uploads, saving user prediction history in the database, and mediates all communication with the ML service.

Inference uses pretrained Hugging Face and BioCLIP models, with bird predictions enriched using the Gemini API.

Application Snapshots

Login Page

User Login Page

Prediction Result

Prediction result screen

User History (paginated)

Paginated prediction history

Features

User-Facing

  • Upload an image of (up to 5 MB) and classify it as a bird, plant, or animal
  • Animal & plant species information retrieval from database, and bird species enrichment using Gemini API
  • Confidence score & additional info returned with each prediction

Engineering Highlights

  • Clear separation between frontend, backend, and ML services
  • Centralized request validation and file handling in the backend
  • Backend-to-ML communication via HTTP REST APIs
  • FastAPI-based ML inference service
  • Automated backend tests using Jest and Supertest on push using Github Actions

Architecture

Feather Scan follows a service-separated architecture to keep concerns isolated and the system easy to reason about.

Architecture Diagram

graph TD
    Client[Frontend<br/>React + Vite<br/>:5173]
    Backend[Backend API<br/>Express + TypeScript<br/>:3000]
    ML[ML Inference Service<br/>FastAPI<br/>:5000]
    DB[(MongoDB)]
    Auth[Firebase]
    Info[JSON DB]

    Client -->|POST /upload| Backend
    Backend -->|JSON Response| Client

    Backend -->|POST /predict| ML
    ML -->|Prediction Result| Backend
    ML -->|Fetch Species Info| Info

    Backend -->|Validate & Store History| DB
    Backend -->|Verify Token| Auth

Loading

Data Flow

  1. The client uploads an image along with the selected model type.
  2. Backend receives request; authentication is handled via Firebase. The backend verifies ID tokens and associates predictions with user history.
  3. The image is forwarded to the ML service for inference:
    • Birds and plants use pretrained Hugging Face models.
    • Animals use BioCLIP for zero-shot classification.
  4. For bird predictions, additional species information is generated using Gemini API.
  5. For animal & plant predictions, info is retrieved from a database based on predicted label.
  6. The backend returns a structured JSON response (label, confidence, info) to the client for display.

Tech Stack

Frontend

React Vite Bootstrap Axios

Backend

Node.js Express TypeScript Multer Jest

ML Service

Python FastAPI HuggingFace BioCLIP

Tooling

GitHub Actions Vercel

ML Models

Category Model Source Type
Birds chriamue/bird-species-classifier Hugging Face Pretrained classifier
Plants dima806/medicinal_plants_image_detection Hugging Face Pretrained classifier
Animals imageomics/bioclip-2 BioCLIP Zero Shot

Prerequisites

Before you begin, ensure you have the following installed:

  • Node.js (v18 or higher) - Download
  • Python (v3.9 or higher) - Download
  • npm or yarn - Comes with Node.js
  • pip - Python package manager
  • Git - Version control

Installation

1. Clone the Repository

git clone https://github.com/devansh436/feather-scan.git
cd feather-scan

2. Install Root Dependencies

npm install

3. Install Client Dependencies

cd client
npm install
cd ..

4. Install Server Dependencies

cd server
npm install
cd .. 

5. Install Model Dependencies

cd model
pip install -r requirements.txt
cd ..

Configuration

Environment Variables

Create .env files in the respective directories:

client/.env

VITE_API_BASE=http://localhost:3000
VITE_FIREBASE_API_KEY=<your-key>
VITE_FIREBASE_AUTH_DOMAIN=example-project.firebaseapp.com
VITE_FIREBASE_PROJECT_ID=example-project-a1b2c3
VITE_FIREBASE_APP_ID=x:123456789:web:e1x1m1p1le

server/.env

PORT=3000
FAST_API_URL=http://localhost:5000/predict
MONGO_URI=<your-mongo-uri>

model/.env

GEMINI_API_KEY=your_gemini_api_key_here
GEMINI_MODEL=gemini-2.5-flash

Running the Application

Run All Services Concurrently

From the root directory:

npm run dev

This starts all three services simultaneously:

Accessing the Application

Open your browser and navigate to:

http://localhost:5173

![Application Interface](https://via.placeholder.com/800x450/1e293b/ffffff? text=Upload+Interface+Screenshot)

API documentation

POST /upload

Accepts an image and model type, returns the predicted label and confidence.

Request

  • contains auth token
  • multipart/form-data
  • file: image (jpg/png)
  • modelType: bird | plant | animal

Response

{
  "label": "bald eagle",
  "type": "bird",
  "confidence": 0.95,
  "info": {
    "name": "Bald Eagle",
    "scientific_name": "Haliaeetus leucocephalus",
    "habitat": "Near large bodies of open water, forests",
    "origin": "North America",
    "description": "A large bird of prey known for its white head and tail."
  }
}

API details are intentionally kept minimal, as the backend is not intended for third-party consumption.

Project Structure

feather-scan/
β”‚
β”œβ”€β”€ client/                 # Frontend React application
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/    # React components
β”‚   β”‚   β”œβ”€β”€ context/       # Auth context
β”‚   β”‚   β”œβ”€β”€ data.js/       # Static data
β”‚   β”‚   β”œβ”€β”€ lib/           # firebase setup
β”‚   β”‚   β”œβ”€β”€ services/      # API calls & auth functions
β”‚   β”‚   β”œβ”€β”€ pages/         # Page components
β”‚   β”‚   β”œβ”€β”€ App.jsx        # Main app component
β”‚   β”‚   └── main.jsx       # Entry point
β”‚   β”œβ”€β”€ public/            # Static assets
β”‚   β”œβ”€β”€ package.json
β”‚   └── vite.config.js     # Vite configuration
β”‚
β”œβ”€β”€ server/                # Backend Express API
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ __tests__/     # Testing setup & files
β”‚   β”‚   β”œβ”€β”€ routes/        # API routes
β”‚   β”‚   β”œβ”€β”€ config/        # Configure database, Auth & env variables
β”‚   β”‚   β”œβ”€β”€ controllers/   # Implementation of routes (History, Upload, User, etc.) 
β”‚   β”‚   β”œβ”€β”€ middleware/    # Auth middleware
β”‚   β”‚   β”œβ”€β”€ models/        # User & History models
β”‚   β”‚   β”œβ”€β”€ validators/    # Model response validation via Zod
β”‚   β”‚   β”œβ”€β”€ app.ts         # Express app using created routes
β”‚   β”‚   └── index.ts       # Server entry point
β”‚   β”œβ”€β”€ package.json
β”‚   └── tsconfig.json      # TypeScript config
β”‚
β”œβ”€β”€ model/                 # ML inference service
β”‚   β”œβ”€β”€ data/              # Static species data
β”‚   β”œβ”€β”€ main.py            # FastAPI application
β”‚   β”œβ”€β”€ model.py           # Model loading & inference
β”‚   └── requirements.txt  # Python dependencies
β”‚
β”œβ”€β”€ .github/
β”‚   └── workflows/         # CI/CD workflows
β”‚       └── test.yml       # Automated testing
β”‚
β”œβ”€β”€ package.json           # Root package (scripts)
└── README.md

Testing

Run backend tests:

cd server
npm test

Tests are automatically run on push via GitHub Actions.

Key Engineering Decisions

  • Used pretrained ML models to focus on backend architecture and system integration.
  • Isolated ML inference into a separate FastAPI service to keep the Node.js backend non-blocking.
  • Centralized validation and file handling in the backend to avoid exposing the ML service.
  • Implemented backend testing early using Jest and Supertest to ensure API stability.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Built with ❀️ by devansh436

About

Multi Model Image classification platform using Hugging Face models and BioCLIP. Three-tier architecture (React + Express + FastAPI) designed for fast response, proper auth and history support.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors