Skip to content

Ahad-Panhwer/Scanimal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Scanimal - Animal Pattern Identification System

A comprehensive digital identity platform for animals, designed to provide unique identification through pattern recognition and secure ownership documentation.

๐ŸŽฏ Project Overview

Scanimal is a full-stack web application that enables animal owners to register their animals with digital identities, helping with:

  • Theft Prevention: Digital identity makes it difficult for stolen animals to be sold
  • Ownership Verification: Provides verifiable proof of ownership
  • Lost Animal Recovery: Helps reunite lost animals with their owners
  • Agricultural Management: Supports better livestock management and breeding programs

๐Ÿš€ Features

Current Implementation

  • โœ… User authentication (Registration & Login)
  • โœ… JWT-based secure authentication
  • โœ… Animal registration with multiple image uploads
  • โœ… User dashboard with profile management
  • โœ… Animal listing and search functionality
  • โœ… Responsive web design
  • โœ… MongoDB database integration

Future AI Integration (Planned)

  • ๐Ÿ”„ Deep learning pattern recognition
  • ๐Ÿ”„ Computer vision processing (OpenCV/TensorFlow)
  • ๐Ÿ”„ High-accuracy pattern matching
  • ๐Ÿ”„ Mobile app integration

๐Ÿ› ๏ธ Technology Stack

Backend

  • Node.js - Runtime environment
  • Express.js - Web framework
  • MongoDB - Database (local MongoDB)
  • Mongoose - ODM for MongoDB
  • JWT - Authentication tokens
  • bcryptjs - Password hashing
  • Multer - File upload handling

Frontend

  • HTML5 - Structure
  • CSS3 - Styling
  • Vanilla JavaScript - Interactivity
  • Fetch API - Backend communication

๐Ÿ“‹ Prerequisites

Before running the project, ensure you have:

  1. Node.js (v14 or higher) - Download
  2. MongoDB (local installation) - Download
  3. MongoDB Compass (optional, for database management) - Download

๐Ÿ”ง Installation & Setup

1. Clone or Download the Project

cd scanimal

2. Install Dependencies

npm install

This will install:

  • express
  • mongoose
  • jsonwebtoken
  • bcryptjs
  • multer
  • cors
  • dotenv

3. Set Up MongoDB

Option A: Using MongoDB Compass

  1. Open MongoDB Compass
  2. Connect to mongodb://127.0.0.1:27017
  3. Create a new database named animalDB (or it will be created automatically)

Option B: Using mongosh (Command Line)

mongosh
use animalDB

4. Configure Environment Variables (Optional)

Create a .env file in the root directory:

MONGODB_URI=mongodb://127.0.0.1:27017/animalDB
JWT_SECRET=your_secret_key_here
PORT=3000
NODE_ENV=development

Note: If you don't create a .env file, the application will use default values.

5. Create Uploads Directory

The uploads directory will be created automatically when you register your first animal. However, you can create it manually:

mkdir uploads

๐Ÿš€ Running the Application

Start the Server

npm start

Or for development:

npm run dev

The server will start on http://localhost:3000

Access the Application

Open your web browser and navigate to:

http://localhost:3000

๐Ÿ“ Project Structure

scanimal/
โ”œโ”€โ”€ server.js                 # Main Express server
โ”œโ”€โ”€ package.json              # Dependencies and scripts
โ”œโ”€โ”€ .gitignore               # Git ignore file
โ”œโ”€โ”€ .env.example             # Environment variables example
โ”‚
โ”œโ”€โ”€ models/                   # Mongoose models
โ”‚   โ”œโ”€โ”€ User.js              # User schema
โ”‚   โ””โ”€โ”€ Animal.js            # Animal schema
โ”‚
โ”œโ”€โ”€ routes/                   # API routes
โ”‚   โ”œโ”€โ”€ auth.js              # Authentication routes
โ”‚   โ”œโ”€โ”€ animals.js           # Animal routes
โ”‚   โ””โ”€โ”€ users.js             # User routes
โ”‚
โ”œโ”€โ”€ middleware/               # Custom middleware
โ”‚   โ””โ”€โ”€ auth.js              # JWT authentication middleware
โ”‚
โ”œโ”€โ”€ uploads/                 # Uploaded animal images (created automatically)
โ”‚
โ”œโ”€โ”€ assets/                  # Static assets (images, logos)
โ”‚
โ”œโ”€โ”€ index.html               # Homepage
โ”œโ”€โ”€ login.html               # Login page
โ”œโ”€โ”€ register-user.html        # User registration page
โ”œโ”€โ”€ register.html             # Animal registration page
โ”œโ”€โ”€ dashboard.html           # User dashboard
โ”œโ”€โ”€ identify.html             # Animal identification page
โ”œโ”€โ”€ animals-list.html         # Animals listing page
โ”œโ”€โ”€ script.js                 # Frontend JavaScript
โ””โ”€โ”€ styles.css                # Stylesheet

๐Ÿ” API Endpoints

Authentication

  • POST /api/auth/register - Register a new user
  • POST /api/auth/login - Login user

Animals

  • POST /api/animals/register - Register a new animal (requires auth)
  • GET /api/animals - Get all animals (with optional filters)
  • GET /api/animals/:id - Get animal by ID
  • GET /api/animals/image/:filename - Get animal image
  • POST /api/animals/identify - Identify animal (future AI implementation)

Users

  • GET /api/users/me - Get current user profile (requires auth)
  • GET /api/users/dashboard - Get dashboard data (requires auth)
  • GET /api/users/animals - Get user's animals (requires auth)

๐Ÿ‘ค User Flow

  1. Registration: Create a new account at /register-user.html
  2. Login: Login at /login.html
  3. Dashboard: View profile and registered animals at /dashboard.html
  4. Register Animal: Register a new animal at /register.html (requires login)
  5. View Animals: Browse all registered animals at /animals-list.html
  6. Identify Animal: Upload image to identify an animal at /identify.html

๐Ÿ”’ Security Features

  • Password Hashing: All passwords are hashed using bcrypt
  • JWT Authentication: Secure token-based authentication
  • Protected Routes: Animal registration requires authentication
  • Input Validation: Server-side validation for all inputs
  • File Upload Security: Only image files are accepted, with size limits

๐Ÿ“ Database Schema

User Collection

{
  name: String,
  email: String (unique),
  password: String (hashed),
  role: String (user/admin),
  createdAt: Date
}

Animal Collection

{
  ownerId: ObjectId (ref: User),
  animalType: String (cow/buffalo/goat/other),
  breed: String,
  gender: String (male/female),
  color: String,
  markings: String,
  description: String,
  images: [String], // Array of filenames
  patternVector: [Number], // Future AI feature
  registeredAt: Date
}

๐ŸŽจ Frontend Features

  • Responsive Design: Works on desktop, tablet, and mobile
  • Modern UI: Clean and professional interface
  • Real-time Updates: Dynamic content loading
  • Error Handling: User-friendly error messages
  • Authentication State: Automatic UI updates based on login status

๐Ÿ”ฎ Future Enhancements

AI Pattern Recognition

  • Integration of OpenCV for image processing
  • Deep learning models for pattern extraction
  • Feature vector generation and storage
  • Similarity matching algorithms
  • High-accuracy identification

Additional Features

  • Mobile application
  • Advanced search and filtering
  • Animal health records
  • Breeding history tracking
  • Export/import functionality
  • Admin dashboard

๐Ÿ› Troubleshooting

MongoDB Connection Issues

  • Ensure MongoDB is running: mongod or check MongoDB service
  • Verify connection string: mongodb://127.0.0.1:27017/animalDB
  • Check MongoDB Compass connection

Port Already in Use

  • Change PORT in .env file
  • Or kill the process using port 3000

Image Upload Issues

  • Ensure uploads/ directory exists and has write permissions
  • Check file size (max 5MB per image)
  • Verify file type (only images allowed)

๐Ÿ“„ License

This project is created for educational purposes as a university final-year project.

๐Ÿ‘จโ€๐Ÿ’ป Development Notes

  • The project is designed to be AI-ready with clear integration points
  • Pattern vectors are stored but not yet populated (awaiting AI implementation)
  • All code is well-commented for educational purposes
  • The structure follows best practices for scalability

๐Ÿค Contributing

This is a university project. For questions or suggestions, please contact the project maintainer.


Built with โค๏ธ for animal protection and agricultural development

About

A digital platform for your Herd

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors