Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

48 Commits

Folders and files

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

Repository files navigation

🏦 FinSight - Advanced Financial SMS Analysis Platform

License: MIT Node.js Python React React Native FastAPI

FinSight is a comprehensive financial SMS analysis platform that leverages machine learning to help users monitor mobile money transactions, detect fraud/spam, and gain valuable insights into their financial activities. The platform features real-time SMS analysis, intelligent categorization, and advanced security measures.

πŸ—οΈ Project Architecture

FinSight_Front_Back-6/
β”œβ”€β”€ 🌐 finsight/                   # React Web Application (Admin Dashboard)
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ components/           # Reusable UI components
β”‚   β”‚   β”œβ”€β”€ config/              # Firebase and app configuration
β”‚   β”‚   β”œβ”€β”€ utils/               # Utility functions and helpers
β”‚   β”‚   β”œβ”€β”€ App.js               # Main application component
β”‚   β”‚   β”œβ”€β”€ Sidebar.js           # Navigation sidebar
β”‚   β”‚   β”œβ”€β”€ Overview.js          # Dashboard overview
β”‚   β”‚   β”œβ”€β”€ SMSInbox.js          # SMS management interface
β”‚   β”‚   └── ...                  # Other pages and components
β”‚   β”œβ”€β”€ public/                  # Static assets
β”‚   └── package.json             # Web app dependencies
β”‚
β”œβ”€β”€ πŸ“± FinSightApp/               # React Native Mobile Application
β”‚   β”œβ”€β”€ 🐍 API/                   # Python FastAPI Backend
β”‚   β”‚   β”œβ”€β”€ main.py              # FastAPI application
β”‚   β”‚   β”œβ”€β”€ model/               # ML model files
β”‚   β”‚   β”œβ”€β”€ requirements.txt     # Python dependencies
β”‚   β”‚   └── start_server.bat     # Server startup script
β”‚   β”œβ”€β”€ src/
β”‚   β”‚   β”œβ”€β”€ screens/             # Mobile app screens
β”‚   β”‚   β”œβ”€β”€ components/          # Reusable mobile components
β”‚   β”‚   β”œβ”€β”€ navigation/          # App navigation structure
β”‚   β”‚   β”œβ”€β”€ services/            # API and Firebase services
β”‚   β”‚   β”œβ”€β”€ config/              # Configuration files
β”‚   β”‚   └── utils/               # Utility functions
β”‚   β”œβ”€β”€ assets/                  # Mobile app assets
β”‚   └── package.json             # Mobile app dependencies
β”‚
β”œβ”€β”€ πŸ”§ Configuration Files
β”‚   β”œβ”€β”€ package.json             # Root project dependencies
β”‚   β”œβ”€β”€ app.json                 # Expo configuration
β”‚   β”œβ”€β”€ eas.json                 # Expo Application Services config
β”‚   β”œβ”€β”€ firestore.indexes.json   # Firebase Firestore indexes
β”‚   └── render.yaml              # Deployment configuration
β”‚
└── πŸ“š Documentation
    β”œβ”€β”€ README.md                # This comprehensive guide
    β”œβ”€β”€ DEPLOYMENT_GUIDE.md      # Production deployment guide
    β”œβ”€β”€ API_INTEGRATION_GUIDE.md # API integration documentation
    └── ...                      # Additional documentation files

οΏ½ Applications Overview

1. FinSight Web Dashboard (/finsight) 🌐

  • Technology: React.js v19+ with modern hooks and context
  • Purpose: Comprehensive admin dashboard for financial oversight and user management
  • Port: 3000 (development), configurable for production
  • Key Features:
    • πŸ” Firebase authentication with role-based access control
    • πŸ“Š Real-time financial analytics and dashboards
    • πŸ“¨ Advanced SMS inbox management with filtering
    • βš™οΈ System settings and configuration management
    • πŸ‘₯ User management with permission guards
    • πŸ—ΊοΈ Interactive fraud mapping with Leaflet integration
    • πŸ“ˆ Financial summary visualizations
    • πŸ”” Real-time notification system

2. FinSightApp Mobile (/FinSightApp) πŸ“±

  • Technology: React Native v0.79+ with Expo framework
  • Purpose: Personal financial SMS analysis companion app
  • Key Features:
    • πŸ“± Real-time SMS scanning and intelligent analysis
    • πŸ’° Automated financial transaction tracking and categorization
    • πŸ›‘οΈ Advanced spam/fraud detection with ML algorithms
    • πŸ“Š Personalized financial insights dashboard
    • πŸ” Secure Firebase authentication
    • πŸ“ Location-based transaction verification
    • πŸ”” Push notifications for important financial events
    • πŸ’³ Mobile money transaction monitoring
    • πŸ“ˆ Spending pattern analysis
    • 🎯 Smart financial advice recommendations

3. FastAPI ML Backend (/FinSightApp/API) 🐍

  • Technology: Python FastAPI with TensorFlow/Scikit-learn
  • Purpose: Machine learning-powered SMS analysis engine
  • Port: 8000 (default), configurable
  • Core Capabilities:
    • πŸ€– Advanced spam/fraud detection using TensorFlow models
    • πŸ’Έ Intelligent financial transaction parsing
    • πŸ“Š SMS sentiment analysis and classification
    • πŸ” Pattern recognition for mobile money services
    • πŸ“ˆ Real-time analysis API endpoints
    • πŸ”’ Secure data processing and validation
    • πŸ“‹ Comprehensive API documentation (Swagger/OpenAPI)
    • RESTful API endpoints

πŸš€ Installation and Setup

πŸ› οΈ Prerequisites and System Requirements

Before setting up FinSight, ensure your development environment meets these requirements:

πŸ“‹ Required Software

Component Version Purpose Installation
Node.js v18.0+ JavaScript runtime for React apps Download
npm/yarn Latest Package manager Included with Node.js
Python v3.8+ Backend API and ML models Download
pip Latest Python package manager Included with Python
Git Latest Version control Download

πŸ“± Mobile Development (Optional)

Component Platform Purpose
Expo CLI Cross-platform npm install -g @expo/cli
Android Studio Android Android development and emulation
Xcode macOS only iOS development (Mac required)

πŸ”§ Development Tools (Recommended)

  • VS Code with React/React Native extensions
  • Postman or Insomnia for API testing
  • Firebase CLI for Firebase operations: npm install -g firebase-tools

πŸ–₯️ System Requirements

  • RAM: 8GB minimum, 16GB recommended
  • Storage: 5GB free space
  • OS: Windows 10+, macOS 10.15+, or Ubuntu 18.04+
  • Network: Stable internet connection for Firebase and API calls

πŸš€ Quick Start Guide

⚑ One-Command Setup (Recommended)

For the fastest setup, use our automated script:

# Clone the repository
git clone https://github.com/Dohessiekan/FinSight_Front_Back.git
cd FinSightAPP OR cd finsight

# Install all dependencies
npm run setup-all  # This will install dependencies for all components

οΏ½ Manual Installation

Follow these steps for a comprehensive manual setup:


🐍 Backend Setup (FastAPI ML Engine)

The backend provides machine learning capabilities for SMS analysis.

Step 1: Navigate to API Directory

cd FinSightApp/API

Step 2: Create Python Virtual Environment

# Windows (PowerShell/Command Prompt)
python -m venv finsight_env
finsight_env\Scripts\activate

# Windows (Git Bash)
python -m venv finsight_env
source finsight_env/Scripts/activate

# macOS/Linux
python3 -m venv finsight_env
source finsight_env/bin/activate

Step 3: Install Python Dependencies

# Install required packages
pip install --upgrade pip
pip install -r requirements.txt

# Verify installation
pip list

Step 4: Verify ML Model Files

Ensure these critical files exist in the FinSightApp/ directory:

  • βœ… model_sentiment.keras - TensorFlow spam detection model
  • βœ… tokenizer.pkl - Text tokenizer for preprocessing
  • βœ… label_encoder.pkl - Label encoder for classification
  • βœ… max_len.pkl - Maximum sequence length for padding

Step 5: Start the API Server

# Option 1: Using Python directly (recommended for development)
python main.py

# Option 2: Using uvicorn with auto-reload
uvicorn main:app --host 0.0.0.0 --port 8000 --reload

# Option 3: Using the Windows batch file
start_server.bat  # Windows only

Step 6: Verify API Functionality

Expected endpoints:

  • POST /predict-spam - Spam/fraud detection
  • POST /predict-sms - Financial SMS analysis
  • POST /predict - General message analysis

🌐 Web Application Setup (React Dashboard)

The web dashboard provides administrative controls and analytics.

Step 1: Navigate to Web App Directory

cd ../../finsight  # From API directory
# OR
cd finsight  # From project root

Step 2: Install Dependencies

# Install all npm packages
npm install

# Alternative: Using yarn
yarn install

# Verify package installation
npm list --depth=0

Step 3: Configure Environment Variables

Create a .env file in the finsight directory:

# Firebase Configuration
REACT_APP_FIREBASE_API_KEY=your_api_key_here
REACT_APP_FIREBASE_AUTH_DOMAIN=finsight-9d1fd.firebaseapp.com
REACT_APP_FIREBASE_PROJECT_ID=finsight-9d1fd
REACT_APP_FIREBASE_STORAGE_BUCKET=finsight-9d1fd.firebasestorage.app

# API Configuration
REACT_APP_API_BASE_URL=http://localhost:8000

# Development Settings
REACT_APP_ENV=development

Step 4: Start Development Server

# Start the React development server
npm start

# Alternative commands
npm run dev      # Same as npm start
npm run serve    # Serve built application

Step 5: Access Web Application

  • 🌐 Application URL: http://localhost:3000
  • πŸ“± Mobile View: Add ?mobile=true to test responsive design
  • πŸ” Login: Use Firebase authentication or test credentials

Expected pages:

  • /overview - Dashboard overview
  • /fraud-alerts - Fraud alert management
  • /sms-inbox - SMS message analysis
  • /settings - Application settings

πŸ“± Mobile Application Setup (React Native)

The mobile app provides personal financial SMS analysis.

Step 1: Navigate to Mobile App Directory

cd ../FinSightApp  # From finsight directory
# OR
cd FinSightApp  # From project root

Step 2: Install Dependencies

# Install React Native packages
npm install

# Install Expo CLI globally (if not already installed)
npm install -g @expo/cli

# Clear cache if needed
npm cache clean --force

Step 3: Configure API Connection

Find Your Local IP Address:

# Windows (PowerShell)
ipconfig | findstr "IPv4"

# Windows (Command Prompt)
ipconfig

# macOS/Linux
ifconfig | grep "inet "
# OR
ip addr show

Update API Configuration:

Edit src/utils/api.js:

// Replace YOUR_LOCAL_IP with your actual IP address
const API_BASE_URL = 'http://192.168.1.100:8000';  // Example IP

// Alternative: Use localhost for emulator testing
const API_BASE_URL = 'http://10.0.2.2:8000';  // Android emulator
const API_BASE_URL = 'http://localhost:8000';  // iOS simulator

Step 4: Configure Firebase

Update src/config/firebase.js with your Firebase project configuration:

const firebaseConfig = {
  apiKey: "your_api_key",
  authDomain: "finsight-9d1fd.firebaseapp.com",
  projectId: "finsight-9d1fd",
  storageBucket: "finsight-9d1fd.firebasestorage.app",
  messagingSenderId: "your_sender_id",
  appId: "your_app_id"
};

Step 5: Start the Expo Development Server

# Start Expo development server
npx expo start

# Alternative: Start with specific options
npx expo start --clear       # Clear cache
npx expo start --tunnel      # Use tunnel for external devices
npx expo start --lan        # Use LAN for local network devices

Step 6: Run on Device/Emulator

Using Expo Go App (Recommended for testing):

  1. Install Expo Go from App Store/Google Play
  2. Scan QR code from terminal with your phone
  3. App will load on your device

Using Development Builds:

# Android (requires Android Studio/emulator)
npx expo run:android

# iOS (requires Xcode - macOS only)
npx expo run:ios

# Web development version
npx expo start --web

Step 7: Test Mobile App Features

Key screens to test:

  • πŸ“± Dashboard: Financial overview and insights
  • πŸ“¨ SMS Inbox: Message analysis and categorization
  • πŸ” Authentication: Login/signup with Firebase
  • βš™οΈ Settings: App configuration and preferences
  • πŸ“Š Analytics: Financial statistics and reports

πŸ”— API Integration and Testing

Core API Endpoints

Endpoint Method Purpose Request Body
/predict-spam POST Spam/fraud detection {"text": "message"}
/predict-sms POST Financial analysis {"messages": ["msg1", "msg2"]}
/predict POST General analysis {"text": "message"}
/health GET Health check None

Testing API Endpoints

1. Using Curl:

# Test spam detection
curl -X POST "http://localhost:8000/predict-spam" \
     -H "Content-Type: application/json" \
     -d '{"text": "Congratulations! You won $1000. Click here to claim."}'

# Test financial analysis
curl -X POST "http://localhost:8000/predict-sms" \
     -H "Content-Type: application/json" \
     -d '{"messages": ["RWF 50,000 sent to John Doe"]}'

2. Using Python Test Script:

cd FinSightApp/API
python test_predict_sms.py

3. Using the Interactive API Documentation:

Visit http://localhost:8000/docs for Swagger UI interface

Sample API Responses

Spam Detection Response:

{
  "is_spam": true,
  "confidence": 0.95,
  "category": "financial_fraud",
  "risk_level": "high"
}

Financial Analysis Response:

{
  "transaction_type": "money_transfer",
  "amount": 50000,
  "currency": "RWF",
  "recipient": "John Doe",
  "confidence": 0.87,
  "category": "peer_to_peer"
}

οΏ½ Project Structure and Key Files

🎯 Core Application Files

Web Application (/finsight/src/)

finsight/src/
β”œβ”€β”€ πŸ“„ App.js                 # Main React application component
β”œβ”€β”€ πŸ” LoginPage.jsx          # User authentication page
β”œβ”€β”€ πŸ“Š Overview.js            # Dashboard overview with analytics
β”œβ”€β”€ πŸ’° FinancialSummary.jsx   # Financial data visualization
β”œβ”€β”€ πŸ“¨ SMSInbox.js            # SMS message management interface
β”œβ”€β”€ βš™οΈ SettingsPage.jsx       # Application settings and configuration
β”œβ”€β”€ 🧭 Sidebar.js             # Navigation sidebar component
β”œβ”€β”€ 🏷️ PageHeader.js          # Common page header component
β”œβ”€β”€ πŸ›‘οΈ PermissionGuard.js     # Access control and authentication guard
β”œβ”€β”€ πŸ“± components/            # Reusable UI components
β”‚   β”œβ”€β”€ Button.js
β”‚   β”œβ”€β”€ Card.js
β”‚   β”œβ”€β”€ Modal.js
β”‚   └── ...
β”œβ”€β”€ βš™οΈ config/                # Configuration files
β”‚   β”œβ”€β”€ firebase.js           # Firebase configuration
β”‚   └── app.js               # Application settings
└── πŸ› οΈ utils/                 # Utility functions
    β”œβ”€β”€ auth.js              # Authentication helpers
    β”œβ”€β”€ api.js               # API communication utilities
    └── helpers.js           # General helper functions

Mobile Application (/FinSightApp/src/)

FinSightApp/src/
β”œβ”€β”€ πŸ“± screens/               # Mobile app screens
β”‚   β”œβ”€β”€ DashboardScreen.js    # Main financial dashboard
β”‚   β”œβ”€β”€ LoginScreen.js        # User authentication
β”‚   β”œβ”€β”€ SignupScreen.js       # New user registration
β”‚   β”œβ”€β”€ SMSInboxScreen.js     # SMS message list and analysis
β”‚   β”œβ”€β”€ SMSDetailScreen.js    # Individual SMS message details
β”‚   β”œβ”€β”€ SMSStatsScreen.js     # SMS statistics and insights
β”‚   β”œβ”€β”€ MessagesScreen.js     # Message management interface
β”‚   β”œβ”€β”€ ProfileScreen.js      # User profile management
β”‚   └── AdviceScreen.js       # Financial advice recommendations
β”œβ”€β”€ 🧩 components/            # Reusable mobile components
β”‚   β”œβ”€β”€ Button.js             # Custom button component
β”‚   β”œβ”€β”€ Card.js               # Card layout component
β”‚   β”œβ”€β”€ Input.js              # Input field component
β”‚   β”œβ”€β”€ PasswordResetForm.js  # Password reset functionality
β”‚   └── ...
β”œβ”€β”€ 🧭 navigation/            # App navigation structure
β”‚   β”œβ”€β”€ AppNavigator.js       # Main navigation container
β”‚   β”œβ”€β”€ TabNavigator.js       # Bottom tab navigation
β”‚   └── StackNavigator.js     # Stack navigation for screens
β”œβ”€β”€ πŸ”§ services/              # External service integrations
β”‚   β”œβ”€β”€ AuthService.js        # Authentication logic
β”‚   β”œβ”€β”€ FirebaseService.js    # Firebase integration
β”‚   β”œβ”€β”€ ApiService.js         # API communication
β”‚   └── NotificationService.js # Push notification handling
β”œβ”€β”€ βš™οΈ config/                # Configuration files
β”‚   β”œβ”€β”€ firebase.js           # Firebase configuration
β”‚   β”œβ”€β”€ emailConfig.js        # Email configuration
β”‚   └── app.js               # App-wide settings
β”œβ”€β”€ 🎨 theme/                 # UI theme and styling
β”‚   β”œβ”€β”€ colors.js             # Color palette
β”‚   β”œβ”€β”€ fonts.js              # Typography settings
β”‚   └── styles.js             # Common styles
└── πŸ› οΈ utils/                 # Utility functions
    β”œβ”€β”€ api.js                # API communication helpers
    β”œβ”€β”€ storage.js            # Local storage management
    β”œβ”€β”€ validation.js         # Form validation
    └── helpers.js            # General utilities

Backend API (/FinSightApp/API/)

FinSightApp/API/
β”œβ”€β”€ 🐍 main.py                # FastAPI application with all endpoints
β”œβ”€β”€ 🧠 model/                 # Machine learning models directory
β”‚   β”œβ”€β”€ model_sentiment.keras # TensorFlow spam detection model
β”‚   β”œβ”€β”€ tokenizer.pkl         # Text tokenizer for preprocessing
β”‚   β”œβ”€β”€ label_encoder.pkl     # Label encoder for classification
β”‚   └── max_len.pkl           # Sequence length configuration
β”œβ”€β”€ πŸ§ͺ test_predict_sms.py    # API testing and validation script
β”œβ”€β”€ πŸ“‹ requirements.txt       # Python dependencies
β”œβ”€β”€ πŸš€ start_server.bat       # Windows server startup script
└── πŸ“š docs/                  # API documentation
    β”œβ”€β”€ endpoints.md          # Endpoint documentation
    └── models.md             # ML model documentation

πŸ”§ Configuration Files

Root Level Configuration

β”œβ”€β”€ πŸ“¦ package.json           # Root project dependencies and scripts
β”œβ”€β”€ πŸ“± app.json               # Expo configuration for mobile app
β”œβ”€β”€ πŸ—οΈ eas.json               # Expo Application Services configuration
β”œβ”€β”€ πŸ”₯ firestore.indexes.json # Firebase Firestore database indexes
β”œβ”€β”€ πŸš€ render.yaml            # Production deployment configuration
β”œβ”€β”€ πŸ”€ .gitignore             # Git ignore patterns
└── πŸ“„ README.md              # This comprehensive documentation

Environment Configuration Files

β”œβ”€β”€ .env                      # Environment variables (create locally)
β”œβ”€β”€ .env.example              # Environment variables template
β”œβ”€β”€ .env.development          # Development environment settings
└── .env.production           # Production environment settings

πŸ”‘ Key Dependencies

Web Application Dependencies (finsight/package.json)

{
  "dependencies": {
    "react": "^19.1.0",              # Core React library
    "react-dom": "^19.1.0",          # React DOM rendering
    "react-router-dom": "^7.6.2",    # Client-side routing
    "firebase": "^11.10.0",          # Firebase integration
    "leaflet": "^1.9.4",             # Interactive maps
    "react-leaflet": "^5.0.0",       # React Leaflet integration
    "react-scripts": "^5.0.1"        # Create React App scripts
  }
}

Mobile App Dependencies (FinSightApp/package.json)

{
  "dependencies": {
    "expo": "~53.0.12",                    # Expo framework
    "react": "19.0.0",                     # React library
    "react-native": "0.79.4",              # React Native framework
    "@react-navigation/native": "^7.1.14", # Navigation library
    "@react-navigation/stack": "^7.4.1",   # Stack navigation
    "firebase": "^11.10.0",                # Firebase integration
    "expo-location": "~18.1.6",            # Location services
    "expo-notifications": "~0.31.4"        # Push notifications
  }
}

Backend Dependencies (API/requirements.txt)

fastapi==0.104.1        # FastAPI web framework
uvicorn[standard]       # ASGI server
tensorflow==2.19.0      # Machine learning framework
scikit-learn           # ML utilities and algorithms
pandas                 # Data manipulation
pydantic              # Data validation
python-multipart      # File upload support

🎯 Important File Descriptions

File Purpose Key Features
Sidebar.js Navigation component Admin profile, logout functionality, menu items
SMSInbox.js SMS management Message filtering, analysis results, bulk operations
Overview.js Dashboard overview Analytics widgets, real-time data, charts
main.py FastAPI backend ML model integration, API endpoints, data processing
firebase.js Firebase config Authentication, Firestore, real-time updates
api.js API utilities HTTP client, error handling, request/response logic
DashboardScreen.js Mobile dashboard Financial insights, transaction summaries
AuthService.js Authentication Login/logout, token management, user sessions

πŸ“š Documentation Files

The project includes comprehensive documentation:

  • API_INTEGRATION_GUIDE.md - Complete API integration instructions
  • DEPLOYMENT_GUIDE.md - Production deployment guidelines
  • FIREBASE_INTEGRATION_GUIDE.md - Firebase setup and configuration
  • MOBILE_APP_INTEGRATION_GUIDE.md - Mobile app development guide
  • SMS_ANALYSIS_IMPROVEMENTS.md - SMS analysis feature documentation
  • FRAUD_MAPPING_INTEGRATION_GUIDE.md - Fraud detection implementation
  • LOCATION_VERIFICATION_SYSTEM.md - GPS and location features

οΏ½ Development Workflow and Commands

πŸš€ Starting All Services

Option 1: Individual Terminal Windows (Recommended)

# Terminal 1: Start Backend API
cd FinSightApp/API
python -m venv finsight_env
finsight_env\Scripts\activate  # Windows
source finsight_env/bin/activate  # macOS/Linux
pip install -r requirements.txt
python main.py

# Terminal 2: Start Web Application
cd finsight
npm install
npm start

# Terminal 3: Start Mobile Application
cd FinSightApp
npm install
npx expo start

Option 2: Using npm Scripts (Root Level)

# Install all dependencies
npm run install:all

# Start all services concurrently
npm run start:all

# Start individual services
npm run start:api      # Backend only
npm run start:web      # Web app only
npm run start:mobile   # Mobile app only

πŸ§ͺ Testing and Validation

Backend API Testing

# Navigate to API directory
cd FinSightApp/API

# Run automated tests
python test_predict_sms.py

# Test specific endpoints
curl -X POST "http://localhost:8000/predict-spam" \
     -H "Content-Type: application/json" \
     -d '{"text": "Test spam message"}'

# Health check
curl http://localhost:8000/health

Web Application Testing

cd finsight

# Run unit tests
npm test

# Run tests with coverage
npm run test:coverage

# Build for production testing
npm run build
npm run serve

Mobile Application Testing

cd FinSightApp

# Start in development mode
npx expo start

# Run on specific platforms
npx expo start --android
npx expo start --ios
npx expo start --web

# Build for testing
npx expo build:android
npx expo build:ios

πŸ“Š Monitoring and Debugging

Application Logs

# Backend API logs
tail -f FinSightApp/API/logs/app.log

# Web application logs (browser console)
# Open Developer Tools β†’ Console

# Mobile application logs
npx expo logs --platform android
npx expo logs --platform ios

Performance Monitoring

# Web app bundle analysis
cd finsight
npm run analyze

# Mobile app performance
cd FinSightApp
npx expo doctor  # Check for issues

πŸ”„ Development Scripts

Useful npm Scripts

Command Purpose Location
npm start Start development server All projects
npm run build Build for production Web/Mobile
npm test Run test suite All projects
npm run lint Code linting All projects
npm run format Code formatting All projects
npm run clean Clean build files All projects

Custom Development Scripts

# Reset all node_modules
npm run clean:all

# Update all dependencies
npm run update:all

# Run security audit
npm run audit:all

# Format all code
npm run format:all

πŸ” Debugging Tips

Common Development Issues

1. API Connection Issues:

# Check if API is running
curl http://localhost:8000/health

# Check network connectivity
ping localhost

# Verify Python environment
python --version
pip list

2. Firebase Authentication Issues:

# Verify Firebase config
firebase projects:list

# Check Firebase rules
firebase firestore:rules:get

# Test Firebase connection
firebase auth:test

3. Mobile App Build Issues:

# Clear Expo cache
npx expo start --clear

# Reset Metro bundler cache
npx expo start --reset-cache

# Check device connectivity
adb devices  # Android
xcrun simctl list  # iOS

4. Web App Build Issues:

# Clear npm cache
npm cache clean --force

# Delete node_modules and reinstall
rm -rf node_modules package-lock.json
npm install

# Check for dependency conflicts
npm ls

πŸ”’ Security, Permissions & Configuration

πŸ›‘οΈ Security Features

Authentication & Authorization

  • Firebase Authentication: Secure user login/signup with email verification
  • Role-Based Access Control: Admin and user permissions
  • JWT Token Management: Secure API communication
  • Session Management: Automatic logout and session expiry
  • Password Security: Strong password requirements and reset functionality

Data Security

  • Input Validation: All API inputs validated using Pydantic models
  • SQL Injection Prevention: Parameterized queries and ORM usage
  • XSS Protection: Input sanitization and output encoding
  • CSRF Protection: Cross-site request forgery mitigation
  • HTTPS Enforcement: Secure communication in production

πŸ“± Mobile App Permissions

Required Permissions

Permission Purpose Justification
SMS_READ Read SMS messages Core functionality for SMS analysis
INTERNET API communication Required for backend data processing
ACCESS_NETWORK_STATE Network status Ensure connectivity before API calls
WRITE_EXTERNAL_STORAGE Local data cache Store analysis results offline
ACCESS_FINE_LOCATION GPS location Transaction location verification
RECEIVE_BOOT_COMPLETED Auto-start service Background SMS monitoring
WAKE_LOCK Keep device awake Real-time SMS processing

Permission Request Implementation

// In FinSightApp/src/utils/permissions.js
import { PermissionsAndroid, Platform } from 'react-native';

export const requestSMSPermission = async () => {
  if (Platform.OS === 'android') {
    try {
      const granted = await PermissionsAndroid.request(
        PermissionsAndroid.PERMISSIONS.READ_SMS,
        {
          title: 'SMS Permission',
          message: 'FinSight needs access to your SMS to analyze financial messages',
          buttonNeutral: 'Ask Me Later',
          buttonNegative: 'Cancel',
          buttonPositive: 'OK',
        }
      );
      return granted === PermissionsAndroid.RESULTS.GRANTED;
    } catch (err) {
      console.warn(err);
      return false;
    }
  }
  return true;
};

βš™οΈ Configuration Management

Environment Variables

Web Application (.env):

# Firebase Configuration
REACT_APP_FIREBASE_API_KEY=your_firebase_api_key
REACT_APP_FIREBASE_AUTH_DOMAIN=finsight-9d1fd.firebaseapp.com
REACT_APP_FIREBASE_PROJECT_ID=finsight-9d1fd
REACT_APP_FIREBASE_STORAGE_BUCKET=finsight-9d1fd.firebasestorage.app
REACT_APP_FIREBASE_MESSAGING_SENDER_ID=your_sender_id
REACT_APP_FIREBASE_APP_ID=your_app_id

# API Configuration
REACT_APP_API_BASE_URL=http://localhost:8000
REACT_APP_WS_URL=ws://localhost:8000/ws

# Application Settings
REACT_APP_ENV=development
REACT_APP_DEBUG=true
REACT_APP_VERSION=1.0.0

# Feature Flags
REACT_APP_ENABLE_ANALYTICS=true
REACT_APP_ENABLE_NOTIFICATIONS=true
REACT_APP_ENABLE_OFFLINE_MODE=false

Mobile App Environment:

// FinSightApp/src/config/environment.js
const config = {
  development: {
    API_BASE_URL: 'http://192.168.1.100:8000',
    WS_URL: 'ws://192.168.1.100:8000/ws',
    DEBUG: true,
    LOG_LEVEL: 'debug'
  },
  production: {
    API_BASE_URL: 'https://api.finsight.app',
    WS_URL: 'wss://api.finsight.app/ws',
    DEBUG: false,
    LOG_LEVEL: 'error'
  }
};

export default config[process.env.NODE_ENV || 'development'];

Backend Configuration:

# FinSightApp/API/config.py
import os
from pydantic import BaseSettings

class Settings(BaseSettings):
    # API Settings
    API_HOST: str = "0.0.0.0"
    API_PORT: int = 8000
    DEBUG: bool = True
    
    # Database
    DATABASE_URL: str = "sqlite:///./finsight.db"
    
    # Firebase
    FIREBASE_PROJECT_ID: str = "finsight-9d1fd"
    FIREBASE_PRIVATE_KEY: str = ""
    
    # ML Models
    MODEL_PATH: str = "./model/"
    MAX_SEQUENCE_LENGTH: int = 100
    
    # Security
    SECRET_KEY: str = "your-secret-key-here"
    ACCESS_TOKEN_EXPIRE_MINUTES: int = 30
    
    class Config:
        env_file = ".env"

settings = Settings()

πŸ”₯ Firebase Configuration

Firebase Project Setup

  1. Create Firebase Project: Go to Firebase Console
  2. Enable Authentication: Email/Password, Google Sign-In
  3. Setup Firestore Database: Configure security rules
  4. Add Web App: Copy configuration to firebase.js
  5. Add Android App: Download google-services.json
  6. Add iOS App: Download GoogleService-Info.plist

Firestore Security Rules

// firestore.rules
rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    // Users can only access their own data
    match /users/{userId} {
      allow read, write: if request.auth != null && request.auth.uid == userId;
    }
    
    // Admin-only access to admin collections
    match /admin/{document=**} {
      allow read, write: if request.auth != null && 
        get(/databases/$(database)/documents/users/$(request.auth.uid)).data.role == 'admin';
    }
    
    // Public read access to fraud alerts
    match /fraud_alerts/{alertId} {
      allow read: if request.auth != null;
      allow write: if request.auth != null && 
        get(/databases/$(database)/documents/users/$(request.auth.uid)).data.role == 'admin';
    }
  }
}

Firebase Storage Rules

// storage.rules
rules_version = '2';
service firebase.storage {
  match /b/{bucket}/o {
    match /user_data/{userId}/{allPaths=**} {
      allow read, write: if request.auth != null && request.auth.uid == userId;
    }
    
    match /public/{allPaths=**} {
      allow read: if true;
      allow write: if request.auth != null;
    }
  }
}

πŸ” API Security Configuration

Authentication Middleware

# FinSightApp/API/middleware/auth.py
from fastapi import HTTPException, Depends, status
from fastapi.security import HTTPBearer
import firebase_admin
from firebase_admin import auth

security = HTTPBearer()

async def verify_firebase_token(token: str = Depends(security)):
    try:
        decoded_token = auth.verify_id_token(token.credentials)
        return decoded_token
    except Exception as e:
        raise HTTPException(
            status_code=status.HTTP_401_UNAUTHORIZED,
            detail="Invalid authentication token"
        )

CORS Configuration

# FinSightApp/API/main.py
from fastapi.middleware.cors import CORSMiddleware

app.add_middleware(
    CORSMiddleware,
    allow_origins=["http://localhost:3000", "http://localhost:19006"],
    allow_credentials=True,
    allow_methods=["*"],
    allow_headers=["*"],
)

🌐 Network Configuration

API Endpoints Configuration

// Shared API configuration
const API_CONFIG = {
  BASE_URL: process.env.REACT_APP_API_BASE_URL || 'http://localhost:8000',
  TIMEOUT: 30000,
  RETRY_ATTEMPTS: 3,
  ENDPOINTS: {
    AUTH: '/auth',
    SMS_ANALYSIS: '/predict-sms',
    SPAM_DETECTION: '/predict-spam',
    HEALTH: '/health',
    WEBSOCKET: '/ws'
  }
};

Proxy Configuration (Development)

// finsight/package.json
{
  "proxy": "http://localhost:8000",
  "scripts": {
    "start": "HTTPS=true react-scripts start"
  }
}

πŸ“š Additional Resources and Documentation

πŸ”— External Documentation Links

Technology Official Documentation Tutorials
React.js React Docs React Tutorial
React Native RN Docs RN Tutorial
Expo Expo Docs Expo Tutorial
FastAPI FastAPI Docs FastAPI Tutorial
Firebase Firebase Docs Firebase Guides
TensorFlow TensorFlow Docs ML Tutorials

πŸ“– Project-Specific Documentation

This repository contains extensive documentation for different aspects of the FinSight platform:

πŸ”§ Setup and Configuration

  • FIREBASE_INTEGRATION_GUIDE.md - Complete Firebase setup and integration
  • API_INTEGRATION_GUIDE.md - Backend API integration instructions
  • MOBILE_APP_INTEGRATION_GUIDE.md - Mobile app development guide
  • DEPLOYMENT_GUIDE.md - Production deployment guidelines

πŸ›‘οΈ Security and Authentication

  • ADMIN_FIREBASE_SETUP.md - Admin authentication setup
  • EMAIL_DELIVERABILITY_GUIDE.md - Email configuration for authentication
  • SMS_PERMISSION_DEBUG_GUIDE.md - SMS permissions troubleshooting

πŸ“± Mobile Features

  • MOBILE_SMS_INTEGRATION_COMPLETE.md - SMS analysis implementation
  • LOCATION_VERIFICATION_SYSTEM.md - GPS and location features
  • AUTOMATIC_ULTRA_HIGH_PRECISION_GPS_SUMMARY.md - Advanced location tracking

πŸ” Analysis and Detection

  • SMS_ANALYSIS_IMPROVEMENTS.md - SMS analysis algorithms
  • FRAUD_MAPPING_INTEGRATION_GUIDE.md - Fraud detection and mapping
  • DYNAMIC_SECURITY_SCORE_SYSTEM.md - Security scoring implementation
  • REAL_TIME_ALERTS_IMPLEMENTATION.md - Real-time notification system

πŸ› Debugging and Maintenance

  • TROUBLESHOOTING_GUIDE.md - Common issues and solutions
  • DATA_PERSISTENCE_FIXES.md - Data storage troubleshooting
  • MANUAL_ANALYSIS_DEBUG_FIXES.md - Analysis debugging guide
  • RENDER_FIX.md - Deployment-specific fixes

πŸŽ“ Learning Resources

For Beginners

  1. JavaScript Fundamentals: MDN JavaScript Guide
  2. React Basics: React Beta Docs
  3. Python Basics: Python.org Tutorial
  4. Git Version Control: Git Handbook

For Advanced Development

  1. React Performance: React Performance Optimization
  2. FastAPI Advanced: FastAPI Advanced User Guide
  3. Mobile App Performance: React Native Performance
  4. Machine Learning: TensorFlow Advanced Tutorials

πŸ› οΈ Development Tools and Extensions

VS Code Extensions (Recommended)

{
  "recommendations": [
    "ms-python.python",
    "bradlc.vscode-tailwindcss",
    "esbenp.prettier-vscode",
    "ms-vscode.vscode-json",
    "ms-vscode.vscode-typescript-next",
    "msjsdiag.vscode-react-native",
    "firebase.vscode-firebase-explorer",
    "ms-python.flake8"
  ]
}

Chrome Extensions for Development

  • React Developer Tools: Debug React components
  • Redux DevTools: State management debugging
  • Firebase Tools: Firebase debugging and monitoring

Mobile Development Tools

  • Flipper: React Native debugging
  • Android Studio: Android development and emulation
  • Xcode: iOS development (macOS only)

πŸ§ͺ Testing Resources

Unit Testing

# Web App Testing
cd finsight
npm test

# API Testing
cd FinSightApp/API
python -m pytest tests/

# Mobile App Testing
cd FinSightApp
npm test

Integration Testing

  • Postman Collections: API endpoint testing
  • Cypress: End-to-end web testing
  • Detox: React Native E2E testing

🎯 Best Practices

Code Style and Standards

  • ESLint Configuration: JavaScript/TypeScript linting
  • Prettier: Code formatting
  • Python PEP 8: Python code style guide
  • React Guidelines: React best practices

Security Best Practices

  • OWASP Top 10: Web application security risks
  • Firebase Security Rules: Database security guidelines
  • API Security: FastAPI security best practices

🀝 Contributing to FinSight

We welcome contributions from the community! Here's how you can contribute:

🌟 Ways to Contribute

  1. πŸ› Bug Reports: Report issues with detailed steps to reproduce
  2. πŸ’‘ Feature Requests: Suggest new features or improvements
  3. πŸ“ Documentation: Improve documentation and guides
  4. πŸ”§ Code Contributions: Submit bug fixes and new features
  5. πŸ§ͺ Testing: Help test new features and report findings

πŸ“‹ Contribution Guidelines

1. Fork and Clone

# Fork the repository on GitHub
git clone https://github.com/yourusername/FinSight_Front_Back.git
cd FinSight_Front_Back-6

2. Create Feature Branch

# Create a new branch for your feature
git checkout -b feature/your-feature-name
git checkout -b bugfix/issue-description
git checkout -b docs/documentation-update

3. Development Standards

  • Code Style: Follow existing code patterns and style guides
  • Testing: Add tests for new features and bug fixes
  • Documentation: Update relevant documentation
  • Commit Messages: Use clear, descriptive commit messages

4. Testing Checklist

  • All existing tests pass
  • New tests added for new functionality
  • Manual testing completed
  • Cross-platform compatibility verified (if applicable)
  • Security implications considered

5. Submit Pull Request

# Push your changes
git push origin feature/your-feature-name

# Create pull request on GitHub with:
# - Clear description of changes
# - Screenshots (if UI changes)
# - Testing notes
# - Related issue numbers

🏷️ Issue Labels

Label Description
bug Something isn't working
enhancement New feature or request
documentation Improvements or additions to docs
good first issue Good for newcomers
help wanted Extra attention is needed
security Security-related issues
performance Performance improvements

πŸ“ Pull Request Template

## Description
Brief description of the changes made.

## Type of Change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
- [ ] Documentation update

## Testing
- [ ] Unit tests pass
- [ ] Integration tests pass
- [ ] Manual testing completed
- [ ] Cross-browser testing (if web changes)

## Screenshots
If applicable, add screenshots to help explain your changes.

## Related Issues
Closes #[issue number]

πŸ“„ License and Legal

πŸ“œ MIT License

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

Copyright (c) 2024 FinSight Team

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

βš–οΈ Third-Party Licenses

This project uses several open-source libraries. Key licenses include:

  • React: MIT License
  • React Native: MIT License
  • Expo: MIT License
  • FastAPI: MIT License
  • Firebase: Google Terms of Service
  • TensorFlow: Apache License 2.0
  • Leaflet: BSD 2-Clause License

πŸ›‘οΈ Privacy and Data Handling

  • SMS Data: Processed locally and on secure servers only
  • User Data: Stored securely using Firebase with encryption
  • Analytics: Optional and anonymized data collection
  • GDPR Compliance: Right to data deletion and export available

πŸ“ž Support and Community

πŸ†˜ Getting Help

  1. πŸ“– Check Documentation: Review this README and project docs first
  2. πŸ” Search Issues: Look for existing solutions in GitHub issues
  3. ❓ Ask Questions: Create a new issue with the "question" label
  4. πŸ’¬ Community Discussion: Join our community discussions

πŸ“§ Contact Information

  • Project Maintainer: GitHub Profile
  • Email: Contact through GitHub issues for project-related questions
  • Bug Reports: Use GitHub Issues with detailed reproduction steps

🎯 Project Roadmap

Current Version: v1.0.0

  • βœ… Basic SMS analysis functionality
  • βœ… Firebase authentication
  • βœ… Web admin dashboard
  • βœ… Mobile app with core features
  • βœ… ML-powered fraud detection

Upcoming Features (v1.1.0)

  • πŸ”„ Enhanced real-time analysis
  • πŸ“Š Advanced analytics dashboard
  • 🌍 Multi-language support
  • πŸ”” Improved notification system
  • πŸ“± Offline functionality

Future Plans (v2.0.0)

  • πŸ€– Advanced AI models
  • 🏦 Bank API integrations
  • πŸ“ˆ Predictive analytics
  • πŸ” Enhanced security features
  • 🌐 Multi-platform support

πŸ“¦ Download Links and Demo

πŸ“± Mobile App Downloads

Platform Download Link Version Size
Android APK Download Latest APK v1.0.0 ~25MB
Google Play Coming Soon - -
iOS App Store Coming Soon - -

πŸŽ₯ Demo and Tutorials

Resource Link Description
Project Demo Video Watch on YouTube Complete project walkthrough
Installation Guide Video Tutorial Step-by-step setup guide
Feature Overview Demo Site Live web demo

πŸ”— Related Links


πŸŽ‰ Acknowledgments

πŸ‘₯ Contributors

Special thanks to all contributors who have helped make FinSight better:

  • Core Development Team: Initial development and architecture
  • Community Contributors: Bug reports, feature suggestions, and testing
  • Beta Testers: Early feedback and testing on mobile devices

πŸ™ Special Thanks

  • Firebase Team: For excellent authentication and database services
  • Expo Team: For simplifying React Native development
  • FastAPI Team: For the excellent Python web framework
  • TensorFlow Team: For machine learning capabilities
  • React Team: For the amazing frontend framework
  • Open Source Community: For the countless libraries that make this project possible

πŸ† Powered By


⭐ If you find FinSight useful, please consider giving it a star on GitHub! ⭐

πŸ“’ Share FinSight with others who might find it helpful for financial SMS analysis!

Made with ❀️ by the FinSight Team

πŸ› Troubleshooting Guide

πŸ”§ Common Issues and Solutions

1. Backend API Issues

❌ Problem: API server won't start

# Error: "Port 8000 is already in use"

βœ… Solution:

# Windows - Find and kill process using port 8000
netstat -ano | findstr :8000
taskkill /PID <process_id> /F

# Alternative: Use different port
uvicorn main:app --host 0.0.0.0 --port 8001 --reload

❌ Problem: ML Models not loading

# Error: "FileNotFoundError: model_sentiment.keras not found"

βœ… Solution:

# Verify model files exist
ls -la FinSightApp/model_sentiment.keras
ls -la FinSightApp/tokenizer.pkl
ls -la FinSightApp/label_encoder.pkl
ls -la FinSightApp/max_len.pkl

# If missing, download from releases or train new models

❌ Problem: Python dependencies installation fails

# Error: "Failed building wheel for tensorflow"

βœ… Solution:

# Update pip and setuptools
pip install --upgrade pip setuptools wheel

# Install Visual C++ Build Tools (Windows)
# Download from: https://visualstudio.microsoft.com/visual-cpp-build-tools/

# Install dependencies one by one
pip install tensorflow==2.19.0
pip install fastapi uvicorn
pip install -r requirements.txt

2. Web Application Issues

❌ Problem: React app won't start

# Error: "Module not found: Can't resolve 'react-router-dom'"

βœ… Solution:

cd finsight
rm -rf node_modules package-lock.json
npm cache clean --force
npm install
npm start

❌ Problem: Firebase connection issues

# Error: "Firebase configuration object is invalid"

βœ… Solution:

// Check firebase.js configuration
const firebaseConfig = {
  apiKey: "your-actual-api-key",           // βœ… Must be actual key
  authDomain: "finsight-9d1fd.firebaseapp.com",
  projectId: "finsight-9d1fd",
  storageBucket: "finsight-9d1fd.firebasestorage.app",
  messagingSenderId: "your-sender-id",
  appId: "your-app-id"
};

// Verify Firebase project is active
firebase projects:list

❌ Problem: API calls failing from web app

# Error: "Network Error" or "CORS policy" error

βœ… Solution:

// Check API base URL in config
const API_BASE_URL = 'http://localhost:8000';  // βœ… Correct
const API_BASE_URL = 'https://localhost:8000'; // ❌ Wrong (use http in dev)

// Verify API is running
curl http://localhost:8000/health

3. Mobile Application Issues

❌ Problem: Expo won't start

# Error: "Expo CLI not found"

βœ… Solution:

# Install Expo CLI globally
npm install -g @expo/cli

# Alternative: Use npx
npx expo start

# Check Expo CLI version
expo --version

❌ Problem: API connection from mobile app

# Error: "Network request failed"

βœ… Solution:

// Update API_BASE_URL in src/utils/api.js
// Find your local IP address first

// Windows
ipconfig | findstr "IPv4"

// Update API configuration
const API_BASE_URL = 'http://192.168.1.100:8000';  // Your actual IP

// Test API connectivity
ping 192.168.1.100
curl http://192.168.1.100:8000/health

❌ Problem: Metro bundler cache issues

# Error: "Unable to resolve module" or "Unexpected token"

βœ… Solution:

cd FinSightApp

# Clear all caches
npx expo start --clear
npx expo start --reset-cache

# Alternative: Manual cache clearing
rm -rf node_modules/.cache
rm -rf .expo
npm start

❌ Problem: Android build issues

# Error: "Android SDK not found"

βœ… Solution:

# Set Android SDK path
export ANDROID_SDK_ROOT=$HOME/Android/Sdk  # Linux/macOS
set ANDROID_SDK_ROOT=C:\Users\%USERNAME%\AppData\Local\Android\Sdk  # Windows

# Verify Android SDK
adb version

# Check connected devices
adb devices

4. Firebase Authentication Issues

❌ Problem: User authentication failing

# Error: "Firebase Auth domain not authorized"

βœ… Solution:

  1. Go to Firebase Console
  2. Select your project
  3. Go to Authentication β†’ Settings β†’ Authorized domains
  4. Add localhost and your domain
  5. Verify email/password sign-in is enabled

❌ Problem: Firestore permission denied

# Error: "Missing or insufficient permissions"

βœ… Solution:

// Update Firestore rules in Firebase Console
rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if request.auth != null;  // Allow authenticated users
    }
  }
}

5. Development Environment Issues

❌ Problem: Node.js version compatibility

# Error: "Unsupported engine" or npm warnings

βœ… Solution:

# Check Node.js version
node --version  # Should be v18.0.0 or higher

# Update Node.js if needed
# Download from: https://nodejs.org/

# Use Node Version Manager (recommended)
nvm install 18
nvm use 18

❌ Problem: Python virtual environment issues

# Error: "Command not found: python"

βœ… Solution:

# Windows: Use py launcher
py -3 --version
py -3 -m venv finsight_env

# Add Python to PATH
# Windows: System Properties β†’ Environment Variables β†’ Path

# Verify Python installation
python --version
python3 --version

πŸ” Debugging Tools and Commands

Backend Debugging

# Check API health
curl -v http://localhost:8000/health

# Test specific endpoints
curl -X POST "http://localhost:8000/predict-spam" \
     -H "Content-Type: application/json" \
     -d '{"text": "test message"}'

# Check Python environment
pip list | grep -E "(fastapi|tensorflow|uvicorn)"

# View API logs
tail -f logs/app.log  # If logging to file

Frontend Debugging

# Web app debugging
npm run build  # Check for build errors
npm run analyze  # Bundle size analysis

# Mobile app debugging
npx expo doctor  # Check for issues
npx expo diagnostics  # Detailed diagnostics

# Check package versions
npm ls react react-native @expo/cli

Network Debugging

# Test network connectivity
ping google.com
nslookup firebase.googleapis.com

# Check firewall settings (Windows)
netsh advfirewall firewall show rule name="Node.js Server App"

# Test local API from different device
curl http://YOUR_IP:8000/health

πŸ“ž Getting Additional Help

Log File Locations

  • Backend API: FinSightApp/API/logs/
  • Web App: Browser Developer Tools β†’ Console
  • Mobile App: Use npx expo logs

Useful Debugging Commands

# Check all running processes on relevant ports
netstat -tulpn | grep -E "(3000|8000|19000|19001|19002)"

# Verify Git repository status
git status
git log --oneline -10

# Check system resources
# Windows: Task Manager
# macOS: Activity Monitor
# Linux: htop or top

When to Seek Help

  1. Create GitHub Issue: For reproducible bugs with clear steps
  2. Check Documentation: Refer to specific guide files in the project
  3. Stack Overflow: For general React/React Native/FastAPI questions
  4. Firebase Support: For Firebase-specific authentication/database issues

Issue Reporting Template

## Bug Report

**Environment:**
- OS: [Windows/macOS/Linux]
- Node.js version: [version]
- Python version: [version]
- Component: [Web/Mobile/API]

**Steps to Reproduce:**
1. 
2. 
3. 

**Expected Behavior:**
[What should happen]

**Actual Behavior:**
[What actually happens]

**Error Messages:**

[Paste error messages here]


**Screenshots:**
[If applicable]

οΏ½ Production Deployment

πŸ“‹ Deployment Checklist

Pre-Deployment Requirements

  • All environment variables configured
  • Firebase project setup and configured
  • SSL certificates obtained
  • Domain names configured
  • Production database setup
  • ML models trained and optimized
  • Security review completed
  • Performance testing completed

Environment Variables for Production

# Production Environment Variables
NODE_ENV=production
REACT_APP_ENV=production

# API Configuration
API_HOST=0.0.0.0
API_PORT=8000
DATABASE_URL=postgresql://user:pass@host:port/db

# Firebase Production Config
REACT_APP_FIREBASE_API_KEY=prod_api_key
REACT_APP_FIREBASE_PROJECT_ID=finsight-prod

# Security
SECRET_KEY=strong_production_secret_key
JWT_SECRET=jwt_production_secret

🌐 Web Application Deployment

Option 1: Vercel (Recommended)

# Install Vercel CLI
npm install -g vercel

# Deploy from finsight directory
cd finsight
vercel --prod

# Configure environment variables in Vercel dashboard

Option 2: Netlify

# Build for production
cd finsight
npm run build

# Deploy to Netlify
# Upload build/ folder or connect GitHub repository

Option 3: Traditional Hosting

# Build production bundle
npm run build

# Serve using nginx/apache
# Configure reverse proxy for API calls

🐍 Backend API Deployment

Option 1: Render (Current Setup)

# render.yaml
services:
  - type: web
    name: finsight-api
    env: python
    buildCommand: "pip install -r requirements.txt"
    startCommand: "uvicorn main:app --host 0.0.0.0 --port $PORT"
    envVars:
      - key: PYTHON_VERSION
        value: 3.9.16

Option 2: Railway

# Install Railway CLI
npm install -g @railway/cli

# Deploy API
cd FinSightApp/API
railway login
railway init
railway up

Option 3: Docker Deployment

# Dockerfile for API
FROM python:3.9-slim

WORKDIR /app
COPY requirements.txt .
RUN pip install -r requirements.txt

COPY . .
EXPOSE 8000

CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]

πŸ“± Mobile App Deployment

Android Deployment (Google Play Store)

cd FinSightApp

# Build production APK
eas build --platform android --profile production

# Submit to Google Play
eas submit --platform android

iOS Deployment (App Store)

# Build for iOS (requires macOS)
eas build --platform ios --profile production

# Submit to App Store
eas submit --platform ios

Standalone APK for Direct Distribution

# Build standalone APK
eas build --platform android --profile preview

# Download APK from Expo dashboard
# Distribute via website or direct download

πŸ”’ Security Hardening for Production

API Security

# FinSightApp/API/main.py - Production settings
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from fastapi.middleware.trustedhost import TrustedHostMiddleware

app = FastAPI(docs_url=None, redoc_url=None)  # Disable docs in production

# Restrict CORS to specific domains
app.add_middleware(
    CORSMiddleware,
    allow_origins=["https://yourdomain.com"],
    allow_credentials=True,
    allow_methods=["GET", "POST"],
    allow_headers=["*"],
)

# Trust only specific hosts
app.add_middleware(
    TrustedHostMiddleware, 
    allowed_hosts=["yourdomain.com", "*.yourdomain.com"]
)

Firebase Security Rules (Production)

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    // Strict user data access
    match /users/{userId} {
      allow read, write: if request.auth != null 
        && request.auth.uid == userId
        && request.auth.token.firebase.sign_in_provider != 'anonymous';
    }
    
    // Admin access with additional verification
    match /admin/{document=**} {
      allow read, write: if request.auth != null 
        && request.auth.token.email_verified == true
        && get(/databases/$(database)/documents/users/$(request.auth.uid)).data.role == 'admin';
    }
  }
}

οΏ½ Performance Optimization

Web App Optimization

# Build with optimizations
cd finsight
npm run build:prod

# Analyze bundle size
npm run analyze

# Enable compression and caching
# Configure in web server (nginx/apache)

Mobile App Optimization

// FinSightApp/metro.config.js
module.exports = {
  transformer: {
    minifierConfig: {
      keep_classnames: true,
      keep_fnames: true,
      mangle: {
        keep_classnames: true,
        keep_fnames: true,
      },
    },
  },
};

API Optimization

# FinSightApp/API/main.py
import uvicorn
from fastapi import FastAPI
from fastapi.middleware.gzip import GZipMiddleware

app = FastAPI()
app.add_middleware(GZipMiddleware, minimum_size=1000)

# Production server config
if __name__ == "__main__":
    uvicorn.run(
        "main:app",
        host="0.0.0.0",
        port=8000,
        workers=4,  # Multiple workers for production
        access_log=False,  # Disable for performance
    )

πŸ” Monitoring and Logging

Application Monitoring

# Add logging and monitoring
import logging
from fastapi import Request
import time

logging.basicConfig(
    level=logging.INFO,
    format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
    handlers=[
        logging.FileHandler("app.log"),
        logging.StreamHandler()
    ]
)

@app.middleware("http")
async def log_requests(request: Request, call_next):
    start_time = time.time()
    response = await call_next(request)
    process_time = time.time() - start_time
    
    logging.info(
        f"{request.method} {request.url} - "
        f"Status: {response.status_code} - "
        f"Time: {process_time:.2f}s"
    )
    return response

Health Check Endpoints

@app.get("/health")
async def health_check():
    return {
        "status": "healthy",
        "timestamp": time.time(),
        "version": "1.0.0"
    }

@app.get("/metrics")
async def metrics():
    # Add application metrics
    return {
        "requests_total": request_count,
        "response_time_avg": avg_response_time,
        "active_users": active_user_count
    }

πŸ”„ CI/CD Pipeline

GitHub Actions Workflow

# .github/workflows/deploy.yml
name: Deploy FinSight

on:
  push:
    branches: [ main ]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: '18'
      - run: npm install
      - run: npm test

  deploy-api:
    needs: test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v4
        with:
          python-version: '3.9'
      - run: pip install -r FinSightApp/API/requirements.txt
      - run: python FinSightApp/API/test_predict_sms.py
      # Deploy to production server

  deploy-web:
    needs: test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: '18'
      - run: cd finsight && npm install && npm run build
      # Deploy to Vercel/Netlify

  build-mobile:
    needs: test
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: '18'
      - run: cd FinSightApp && npm install
      - run: npx eas-cli build --platform all --non-interactive

πŸ“ˆ Scaling Considerations

Database Scaling

  • Use PostgreSQL for production instead of SQLite
  • Implement connection pooling
  • Add database indexes for frequently queried fields
  • Consider read replicas for heavy read workloads

API Scaling

  • Use multiple Uvicorn workers
  • Implement Redis for caching
  • Add API rate limiting
  • Use load balancer for multiple API instances

CDN and Static Assets

  • Use CDN for static assets (images, CSS, JS)
  • Optimize images and compress assets
  • Implement browser caching headers

APK Link: ## πŸ“¦ Download

Download APK

Dashboard Link: https://finsight-front-back-3.onrender.com

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages