Skip to content
Samar-M3Public

About

PetMate: a mobile app for pet owners in Nepal. Swipe to find playdate and mating partners for your pet, chat with matches, book vets, shop for pet products and join pet events. Built with Flutter, Node.js, PostgreSQL and Firebase.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

102 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

PetMate 🐾

An all-in-one multi-role pet care and pet services platform.
Connects pet owners, veterinarians, sellers, and event organizers in a unified, modern mobile ecosystem.

Flutter Dart Node.js TypeScript Express Prisma PostgreSQL


πŸ“– Overview

PetMate simplifies pet parenting by bringing essential pet-related services together under one roof. Instead of relying on disparate channels for breeding connections, veterinary consultations, supplies, and community gatherings, PetMate delivers a secure, role-based platform designed with an initial focus on the Nepalese market.

Key Highlights

  • Pet Dating & Matching: Swipe-based matching ("Mating to Dating") for pet breeding and playdates with two-way consent verification.
  • Veterinary Appointments: Discover certified veterinarians, check real-time availability slots, and book non-conflicting consultations.
  • Multi-Vendor Marketplace: Shop verified pet food, supplements, and accessories with server-enforced pricing.
  • Community Events: Register and participate in pet competitions, vaccination drives, and meetups with capacity tracking.
  • End-to-End Security: JWT authentication, strict role-based access control (RBAC), and server-verified workflows.

πŸ‘₯ User Roles & Permissions

PetMate operates on a granular multi-role authorization model:

Role Primary Responsibilities & Capabilities
Pet Owner Manage pet profiles, discover pet partners via swipe matching, chat with confirmed matches, browse & buy products, schedule vet visits, and sign up for community events.
Seller Manage pet supply store profiles, publish product listings, track inventory, and process incoming customer orders upon admin verification.
Veterinarian Set up clinical profiles and credentials, manage availability schedules, specify consultation charges, and conduct booked appointments once verified.
Administrator Moderate platform content, verify seller applications and veterinarian licenses, monitor transactions, oversee platform statistics, and enforce account suspensions.

πŸ› οΈ Technology Stack

Mobile Client (Flutter)

  • Framework: Flutter (Stable channel) with Dart 3
  • Architecture: Feature-first modular organization
  • State Management: Riverpod 3 (Notifier / NotifierProvider)
  • Navigation: GoRouter
  • Networking: HTTP Client with typed error envelopes and automated JWT Bearer token injection
  • Persistence: shared_preferences for secure local session caching
  • UI System: Material 3 with customized PetCare design tokens

Backend API (Node.js & TypeScript)

  • Runtime & Language: Node.js with TypeScript (tsx runtime execution)
  • Web Framework: Express.js 5
  • ORM & Database: Prisma ORM 7 with PostgreSQL (leveraging @prisma/adapter-pg)
  • Authentication: JSON Web Tokens (JWT) & bcryptjs password hashing
  • File & Media Storage: Cloudinary (secure server-side asset handling)
  • Real-Time Communication: Socket.IO for real-time messaging

πŸ“‚ Repository Structure

The project is maintained as a cohesive monorepo with the Flutter mobile application at the root and the TypeScript backend service encapsulated in backend/:

petmatee/
β”œβ”€β”€ android/                         # Native Android platform configurations
β”œβ”€β”€ backend/                         # Node.js TypeScript API service
β”‚   β”œβ”€β”€ prisma/
β”‚   β”‚   β”œβ”€β”€ migrations/              # Database migration history
β”‚   β”‚   └── schema.prisma            # Prisma schema models & enums
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ config/                  # Environment and database client configs
β”‚   β”‚   β”‚   β”œβ”€β”€ db.ts                # PrismaClient instance
β”‚   β”‚   β”‚   └── env.ts               # Typed environment loader
β”‚   β”‚   β”œβ”€β”€ generated/prisma/        # Generated Prisma Client
β”‚   β”‚   β”œβ”€β”€ middleware/              # Auth & error handling middlewares
β”‚   β”‚   β”‚   β”œβ”€β”€ auth.middleware.ts   # JWT & role authorization guards
β”‚   β”‚   β”‚   └── errorHandler.ts      # Centralized error handler
β”‚   β”‚   β”œβ”€β”€ modules/                 # Modular feature domains
β”‚   β”‚   β”‚   └── auth/                # Authentication module
β”‚   β”‚   β”‚       β”œβ”€β”€ auth.controller.ts
β”‚   β”‚   β”‚       β”œβ”€β”€ auth.routes.ts
β”‚   β”‚   β”‚       β”œβ”€β”€ auth.service.ts
β”‚   β”‚   β”‚       β”œβ”€β”€ auth.types.ts
β”‚   β”‚   β”‚       └── auth.validation.ts
β”‚   β”‚   β”œβ”€β”€ utils/                   # Standard API response builders
β”‚   β”‚   β”œβ”€β”€ app.ts                   # Express application setup
β”‚   β”‚   └── server.ts                # Server entry point & graceful shutdown
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ prisma7.config.ts
β”‚   └── tsconfig.json
β”œβ”€β”€ lib/                             # Flutter mobile application
β”‚   β”œβ”€β”€ core/                        # Shared cross-cutting infrastructure
β”‚   β”‚   β”œβ”€β”€ config/                  # App constants & platform-aware API base URLs
β”‚   β”‚   β”œβ”€β”€ constants/               # Color palettes & UI tokens
β”‚   β”‚   β”œβ”€β”€ errors/                  # Typed exception definitions
β”‚   β”‚   β”œβ”€β”€ router/                  # GoRouter configuration
β”‚   β”‚   β”œβ”€β”€ services/                # ApiClient & StorageService
β”‚   β”‚   └── theme/                   # Material 3 theme data
β”‚   β”œβ”€β”€ features/                    # Feature-first slices
β”‚   β”‚   β”œβ”€β”€ auth/                    # Auth data, domain & presentation
β”‚   β”‚   └── home/                    # Landing dashboard & platform navigation
β”‚   β”œβ”€β”€ app.dart                     # Root ConsumerWidget
β”‚   └── main.dart                    # Application entry point & ProviderScope setup
β”œβ”€β”€ test/                            # Unit & widget tests
└── pubspec.yaml                     # Flutter dependencies

πŸš€ Getting Started

Prerequisites


1. Backend Setup

  1. Navigate to the backend directory:

    cd backend
  2. Install dependencies:

    npm install
  3. Configure Environment Variables:
    Create or verify .env in backend/.env:

    PORT=5000
    NODE_ENV=development
    DATABASE_URL="postgresql://<user>:<password>@localhost:5432/petmate_db?schema=public"
    JWT_SECRET="your_secure_jwt_secret_key"
    JWT_EXPIRES_IN="7d"
    CLOUDINARY_CLOUD_NAME="your_cloud_name"
    CLOUDINARY_API_KEY="your_api_key"
    CLOUDINARY_API_SECRET="your_api_secret"
  4. Run Database Migrations & Generate Prisma Client:

    npx prisma migrate dev
    npx prisma generate
  5. Start the Development Server:

    npm run dev
    • Server runs at: http://localhost:5000
    • Health check: http://localhost:5000/api/v1/health

2. Mobile App Setup (Flutter)

  1. Navigate to the repository root:

    cd ..
  2. Install Flutter packages:

    flutter pub get
  3. Verify API Base URL:
    In lib/core/config/app_config.dart, PetMate automatically routes requests:

    • Android Emulator: http://10.0.2.2:5000/api/v1
    • Web / Desktop / iOS Simulator: http://localhost:5000/api/v1
    • Physical devices: Update with your local machine's IP address (e.g., http://192.168.x.x:5000/api/v1).
  4. Launch the application:

    flutter run

πŸ“‘ API Conventions

All API routes follow standard RESTful conventions prefixed by /api/v1.

Response Envelopes

βœ… Success Response (200 OK, 201 Created)

{
  "success": true,
  "message": "Operation completed successfully",
  "data": {
    "user": {
      "id": "6f26ba44-b606-4cfa-84a2-fc67f4963bea",
      "email": "user@example.com",
      "fullName": "Jane Doe",
      "role": "PET_OWNER",
      "status": "ACTIVE"
    },
    "token": "eyJhbGciOi..."
  }
}

❌ Error Response (400, 401, 403, 404, 409, 500)

{
  "success": false,
  "message": "Validation failed",
  "errors": [
    "Password must be at least 6 characters long"
  ]
}

Core Auth Endpoints

Method Endpoint Access Description
GET /api/v1/health Public System status and health monitor
POST /api/v1/auth/register Public Register new PET_OWNER, SELLER, or VETERINARIAN
POST /api/v1/auth/login Public Authenticate user and obtain JWT
GET /api/v1/auth/me Bearer Token Fetch authenticated user profile

πŸ”’ Security & Business Rules

  1. Strict Role Isolation: Public registration is restricted to PET_OWNER, SELLER, and VETERINARIAN. Initial ADMIN accounts are provisioned via secure administrative seed scripts.
  2. Consent-Gated Matching: A right-swipe indicates interest. Both owners must accept before a match is confirmed and real-time chat unlocks.
  3. Double-Booking Prevention: Veterinary booking slots are verified via transactional locking to eliminate race conditions.
  4. Server-Side Financial Calculations: Product prices and order totals are calculated exclusively on the backend from trusted database state.
  5. Session Safety: Suspended accounts are immediately blocked at the authentication middleware level.

πŸ§ͺ Testing

Mobile Tests

# Analyze code quality and formatting
flutter analyze

# Execute Flutter widget and unit tests
flutter test

Backend Type Check & Tests

cd backend

# Run TypeScript type verification
npm run typecheck

🀝 Development & Contribution Guidelines

  1. Branching Strategy: Work on designated feature branches (feature/<name>) and coordinate Prisma schema changes before applying migrations.
  2. Secrets Protection: Never commit .env or production credentials. Use local environment files for development.
  3. Commit Standards: Write descriptive, imperative commit messages (e.g., feat(auth): add role validation to registration flow).

πŸ“„ License

This project is developed under an academic and proprietary license for PetMate. All rights reserved.

About

PetMate: a mobile app for pet owners in Nepal. Swipe to find playdate and mating partners for your pet, chat with matches, book vets, shop for pet products and join pet events. Built with Flutter, Node.js, PostgreSQL and Firebase.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages