Version: 1.0.1 Status: Active Development Primary Contact: cnitheesh7@gmail.com
eWarrants is a comprehensive, full-stack digital warranty management solution engineered for reliability, performance, and a seamless user experience. It empowers users to digitize, track, and manage product warranties effortlessly.
This application is architected with an offline-first strategy, ensuring full functionality in disconnected environments, a critical feature for users on the go. Data is securely stored locally and synchronized with a cloud backend when an internet connection is available.
The system integrates cutting-edge Artificial Intelligence through Google's Gemini platform to offer intelligent features such as automated receipt scanning and a conversational AI assistant, significantly enhancing user productivity and experience.
eWarrants is built on a robust client-server model, comprising a React Native (Expo) mobile application and a Node.js (Express) backend service.
- Client (Mobile Application): A cross-platform mobile app built with React Native and Expo. It is designed to be the primary user interface and operates on an offline-first principle.
- Backend (Server): A RESTful API built with Node.js and Express, responsible for business logic, data persistence, user authentication, and integration with third-party services.
- Database: The system utilizes a dual-database strategy:
- Local: SQLite via WatermelonDB on the client for high-performance, offline data storage.
- Remote: MongoDB on the server for persistent, centralized data storage.
- Synchronization: A sophisticated sync mechanism ensures data integrity between the local and remote databases, handling created, updated, and deleted records.
| Component | Technology |
|---|---|
| Frontend (Mobile) | React Native, Expo, Expo Router, JavaScript, WatermelonDB (SQLite), Axios |
| Backend (Server) | Node.js, Express.js, MongoDB, Mongoose, JSON Web Tokens (JWT), Cloudinary, Google Gemini API |
| DevOps & Tooling | Expo Application Services (EAS), Git, npm, ESLint |
The frontend is a meticulously structured Expo application designed for scalability and maintainability.
/app: Core navigation and screen layouts managed by Expo Router's file-based routing system. This includes the main tab navigator(tabs), authentication screens, and dynamic routes for warranty details (/warranty/[id])./src: Contains the majority of the application's logic, separated from the routing layer./api: Centralized Axios instance for all API communications, featuring an interceptor to automatically attach JWT authentication tokens./components: A library of reusable UI components (WarrantyForm,AddWarrantySheet, custom icons, etc.) that enforce a consistent design system./contexts: React Context providers for managing global state, including the database connection (DatabaseContext) and application theme (ThemeContext)./db: The complete configuration for WatermelonDB. This includes the database schema (schema.js), model definitions (Warranty.js), and the main database adapter setup./hooks: A collection of custom React hooks that encapsulate complex business logic and state management. This is a key pattern for code reusability and separation of concerns./screens: The primary UI views of the application, which are then rendered by the routes defined in the/appdirectory./sync.js: Implements the core offline-first data synchronization logic./theme: Defines color palettes and shared component styles for light and dark modes.
This is the most critical component of the frontend architecture.
- State Tracking: Each local record in WatermelonDB contains a
sync_statusfield (created,updated,deleted,synced) to track its state relative to the server. - Push Mechanism: The
pushChangesToServerfunction queries for all records that are notsyncedand performs the corresponding RESTful API call (POST,PUT,DELETE). On a successful API response, it updates the local record's status tosyncedor, in the case of a deletion, removes it permanently from the local database. - Pull Mechanism: The
pullChangesFromServerfunction sends the timestamp of the last successful sync to the server. The server responds with only the records that have changed since that time (a "delta sync"). The client then iterates through these changes and applies them to the local database, either by creating new records or updating existing ones.
useWarranties(): This hook provides a reactive data stream from the local WatermelonDB to the UI. It listens for changes to thewarrantiescollection and automatically triggers re-renders. It also contains all the logic for client-side searching, sorting, and filtering, ensuring the UI is always up-to-date and responsive.useWarrantyForm(): Manages the complex state and side effects associated with the warranty creation and editing form. This includes handling user input, managing the state of the bottom sheet modal, and orchestrating the AI-powered receipt scanning flow.
The backend is a secure, scalable, and efficient Node.js application that serves as the central hub for all data and business logic.
/controllers: Contains the core business logic. Each controller is responsible for handling requests for a specific resource (e.g.,authController.jsfor users,warrantyController.jsfor warranties)./middleware: Houses middleware functions, most notably theauthMiddleware.js, which uses JWTs to protect API routes from unauthorized access./models: Defines the Mongoose schemas for theUserandWarrantycollections in MongoDB. These schemas enforce data structure and validation rules./routes: Defines the API endpoints and maps them to the appropriate controller functions. This includes routes for authentication, warranty CRUD, and account management./utils: A collection of helper modules for tasks like generating email templates (emailTemplate.js) and defining custom error classes (errorResponse.js).
- AI Receipt Scanner: The
/process-receiptendpoint is a multi-step process:- An uploaded image is streamed to Cloudinary for persistent storage.
- The image buffer is also sent to the Google Gemini API with a carefully engineered prompt that instructs the model to extract specific fields (
productName,purchaseDate,warrantyMonths) and return them in a structured JSON format. This minimizes errors and ensures data consistency.
- AI Chat Assistant with Function Calling: The
/chatendpoint uses Gemini's powerful Function Calling capability.- The backend defines a
getWarrantiesfunction as a "tool" that the AI model can use. - When a user asks a question about their warranties, the AI model intelligently determines that it needs data and generates a request to execute the
getWarrantiestool with the relevant parameters (e.g.,{ "expiringWithinDays": 30 }). - The backend then executes a secure database query on behalf of the user and passes the results back to the AI model.
- The model then uses this data to formulate a natural, human-like response. This approach is highly secure as the AI never has direct access to the database.
- The backend defines a
- Authentication: The system uses JSON Web Tokens (JWT) for stateless authentication. Upon successful login, a token is issued to the client and included in the header of all subsequent authenticated requests.
- Password Security: User passwords are never stored in plaintext. They are hashed using the
bcryptjslibrary with a salt factor, a standard and secure practice for password management. - Rate Limiting: Authentication-related endpoints are protected with
express-rate-limitto mitigate the risk of brute-force attacks.
- Node.js (LTS version recommended)
- npm or Yarn
- Expo CLI
- MongoDB Atlas account (or a local MongoDB instance)
- Cloudinary account
- Google Gemini API key
- Navigate to the
serverdirectory. - Install dependencies:
npm install - Create a
.envfile in the root of theserverdirectory and populate it with the following keys:MONGO_URI=your_mongodb_connection_string JWT_SECRET=your_jwt_secret EMAIL_USER=your_gmail_address EMAIL_PASS=your_gmail_app_password CLOUDINARY_CLOUD_NAME=your_cloudinary_cloud_name CLOUDINARY_API_KEY=your_cloudinary_api_key CLOUDINARY_API_SECRET=your_cloudinary_api_secret GEMINI_API_KEY=your_google_gemini_api_key - Start the server:
npm start
- Navigate to the
eWarrantsdirectory. - Install dependencies:
npm install - Ensure your mobile device or emulator is running.
- Start the development server:
npm start - In
src/api.js, update theAPI_URLto point to your backend server's address. - Follow the instructions in the terminal to open the app on your desired platform (iOS simulator, Android emulator, or Expo Go on a physical device).
This project was made possible by the following team members:
