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.
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
- 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
- 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
- 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
Before setting up FinSight, ensure your development environment meets these requirements:
| 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 |
| 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) |
- VS Code with React/React Native extensions
- Postman or Insomnia for API testing
- Firebase CLI for Firebase operations:
npm install -g firebase-tools
- 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
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 componentsFollow these steps for a comprehensive manual setup:
The backend provides machine learning capabilities for SMS analysis.
cd FinSightApp/API# 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# Install required packages
pip install --upgrade pip
pip install -r requirements.txt
# Verify installation
pip listEnsure 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
# 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- π API Documentation: http://localhost:8000/docs
- π Health Check: http://localhost:8000/
- π OpenAPI Schema: http://localhost:8000/openapi.json
Expected endpoints:
POST /predict-spam- Spam/fraud detectionPOST /predict-sms- Financial SMS analysisPOST /predict- General message analysis
The web dashboard provides administrative controls and analytics.
cd ../../finsight # From API directory
# OR
cd finsight # From project root# Install all npm packages
npm install
# Alternative: Using yarn
yarn install
# Verify package installation
npm list --depth=0Create 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# Start the React development server
npm start
# Alternative commands
npm run dev # Same as npm start
npm run serve # Serve built application- π Application URL: http://localhost:3000
- π± Mobile View: Add
?mobile=trueto 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
The mobile app provides personal financial SMS analysis.
cd ../FinSightApp # From finsight directory
# OR
cd FinSightApp # From project root# 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# Windows (PowerShell)
ipconfig | findstr "IPv4"
# Windows (Command Prompt)
ipconfig
# macOS/Linux
ifconfig | grep "inet "
# OR
ip addr showEdit 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 simulatorUpdate 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"
};# 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- Install Expo Go from App Store/Google Play
- Scan QR code from terminal with your phone
- App will load on your device
# Android (requires Android Studio/emulator)
npx expo run:android
# iOS (requires Xcode - macOS only)
npx expo run:ios
# Web development version
npx expo start --webKey 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
| 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 |
# 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"]}'cd FinSightApp/API
python test_predict_sms.pyVisit http://localhost:8000/docs for Swagger UI interface
{
"is_spam": true,
"confidence": 0.95,
"category": "financial_fraud",
"risk_level": "high"
}{
"transaction_type": "money_transfer",
"amount": 50000,
"currency": "RWF",
"recipient": "John Doe",
"confidence": 0.87,
"category": "peer_to_peer"
}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
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
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
βββ π¦ 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
βββ .env # Environment variables (create locally)
βββ .env.example # Environment variables template
βββ .env.development # Development environment settings
βββ .env.production # Production environment settings
{
"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
}
}{
"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
}
}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
| 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 |
The project includes comprehensive documentation:
API_INTEGRATION_GUIDE.md- Complete API integration instructionsDEPLOYMENT_GUIDE.md- Production deployment guidelinesFIREBASE_INTEGRATION_GUIDE.md- Firebase setup and configurationMOBILE_APP_INTEGRATION_GUIDE.md- Mobile app development guideSMS_ANALYSIS_IMPROVEMENTS.md- SMS analysis feature documentationFRAUD_MAPPING_INTEGRATION_GUIDE.md- Fraud detection implementationLOCATION_VERIFICATION_SYSTEM.md- GPS and location features
# 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# 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# 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/healthcd finsight
# Run unit tests
npm test
# Run tests with coverage
npm run test:coverage
# Build for production testing
npm run build
npm run servecd 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# 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# Web app bundle analysis
cd finsight
npm run analyze
# Mobile app performance
cd FinSightApp
npx expo doctor # Check for issues| 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 |
# 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:all1. API Connection Issues:
# Check if API is running
curl http://localhost:8000/health
# Check network connectivity
ping localhost
# Verify Python environment
python --version
pip list2. Firebase Authentication Issues:
# Verify Firebase config
firebase projects:list
# Check Firebase rules
firebase firestore:rules:get
# Test Firebase connection
firebase auth:test3. 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 # iOS4. 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- 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
- 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
| 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 |
// 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;
};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=falseMobile 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()- Create Firebase Project: Go to Firebase Console
- Enable Authentication: Email/Password, Google Sign-In
- Setup Firestore Database: Configure security rules
- Add Web App: Copy configuration to
firebase.js - Add Android App: Download
google-services.json - Add iOS App: Download
GoogleService-Info.plist
// 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';
}
}
}// 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;
}
}
}# 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"
)# 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=["*"],
)// 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'
}
};// finsight/package.json
{
"proxy": "http://localhost:8000",
"scripts": {
"start": "HTTPS=true react-scripts start"
}
}| 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 |
This repository contains extensive documentation for different aspects of the FinSight platform:
FIREBASE_INTEGRATION_GUIDE.md- Complete Firebase setup and integrationAPI_INTEGRATION_GUIDE.md- Backend API integration instructionsMOBILE_APP_INTEGRATION_GUIDE.md- Mobile app development guideDEPLOYMENT_GUIDE.md- Production deployment guidelines
ADMIN_FIREBASE_SETUP.md- Admin authentication setupEMAIL_DELIVERABILITY_GUIDE.md- Email configuration for authenticationSMS_PERMISSION_DEBUG_GUIDE.md- SMS permissions troubleshooting
MOBILE_SMS_INTEGRATION_COMPLETE.md- SMS analysis implementationLOCATION_VERIFICATION_SYSTEM.md- GPS and location featuresAUTOMATIC_ULTRA_HIGH_PRECISION_GPS_SUMMARY.md- Advanced location tracking
SMS_ANALYSIS_IMPROVEMENTS.md- SMS analysis algorithmsFRAUD_MAPPING_INTEGRATION_GUIDE.md- Fraud detection and mappingDYNAMIC_SECURITY_SCORE_SYSTEM.md- Security scoring implementationREAL_TIME_ALERTS_IMPLEMENTATION.md- Real-time notification system
TROUBLESHOOTING_GUIDE.md- Common issues and solutionsDATA_PERSISTENCE_FIXES.md- Data storage troubleshootingMANUAL_ANALYSIS_DEBUG_FIXES.md- Analysis debugging guideRENDER_FIX.md- Deployment-specific fixes
- JavaScript Fundamentals: MDN JavaScript Guide
- React Basics: React Beta Docs
- Python Basics: Python.org Tutorial
- Git Version Control: Git Handbook
- React Performance: React Performance Optimization
- FastAPI Advanced: FastAPI Advanced User Guide
- Mobile App Performance: React Native Performance
- Machine Learning: TensorFlow Advanced Tutorials
{
"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"
]
}- React Developer Tools: Debug React components
- Redux DevTools: State management debugging
- Firebase Tools: Firebase debugging and monitoring
- Flipper: React Native debugging
- Android Studio: Android development and emulation
- Xcode: iOS development (macOS only)
# Web App Testing
cd finsight
npm test
# API Testing
cd FinSightApp/API
python -m pytest tests/
# Mobile App Testing
cd FinSightApp
npm test- Postman Collections: API endpoint testing
- Cypress: End-to-end web testing
- Detox: React Native E2E testing
- ESLint Configuration: JavaScript/TypeScript linting
- Prettier: Code formatting
- Python PEP 8: Python code style guide
- React Guidelines: React best practices
- OWASP Top 10: Web application security risks
- Firebase Security Rules: Database security guidelines
- API Security: FastAPI security best practices
We welcome contributions from the community! Here's how you can contribute:
- π Bug Reports: Report issues with detailed steps to reproduce
- π‘ Feature Requests: Suggest new features or improvements
- π Documentation: Improve documentation and guides
- π§ Code Contributions: Submit bug fixes and new features
- π§ͺ Testing: Help test new features and report findings
# Fork the repository on GitHub
git clone https://github.com/yourusername/FinSight_Front_Back.git
cd FinSight_Front_Back-6# 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- 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
- All existing tests pass
- New tests added for new functionality
- Manual testing completed
- Cross-platform compatibility verified (if applicable)
- Security implications considered
# 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| 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 |
## 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]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.
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
- 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
- π Check Documentation: Review this README and project docs first
- π Search Issues: Look for existing solutions in GitHub issues
- β Ask Questions: Create a new issue with the "question" label
- π¬ Community Discussion: Join our community discussions
- Project Maintainer: GitHub Profile
- Email: Contact through GitHub issues for project-related questions
- Bug Reports: Use GitHub Issues with detailed reproduction steps
- β Basic SMS analysis functionality
- β Firebase authentication
- β Web admin dashboard
- β Mobile app with core features
- β ML-powered fraud detection
- π Enhanced real-time analysis
- π Advanced analytics dashboard
- π Multi-language support
- π Improved notification system
- π± Offline functionality
- π€ Advanced AI models
- π¦ Bank API integrations
- π Predictive analytics
- π Enhanced security features
- π Multi-platform support
| Platform | Download Link | Version | Size |
|---|---|---|---|
| Android APK | Download Latest APK | v1.0.0 | ~25MB |
| Google Play | Coming Soon | - | - |
| iOS App Store | Coming Soon | - | - |
| 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 |
- GitHub Repository: FinSight_Front_Back
- Issue Tracker: GitHub Issues
- Release Notes: GitHub Releases
- Project Wiki: GitHub Wiki
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
- 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
β 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
β 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β 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β 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β Problem: User authentication failing
# Error: "Firebase Auth domain not authorized"β Solution:
- Go to Firebase Console
- Select your project
- Go to Authentication β Settings β Authorized domains
- Add
localhostand your domain - 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
}
}
}β 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# 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# 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# 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- Backend API:
FinSightApp/API/logs/ - Web App: Browser Developer Tools β Console
- Mobile App: Use
npx expo logs
# 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- Create GitHub Issue: For reproducible bugs with clear steps
- Check Documentation: Refer to specific guide files in the project
- Stack Overflow: For general React/React Native/FastAPI questions
- Firebase Support: For Firebase-specific authentication/database issues
## 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]
- 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
# 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# Install Vercel CLI
npm install -g vercel
# Deploy from finsight directory
cd finsight
vercel --prod
# Configure environment variables in Vercel dashboard# Build for production
cd finsight
npm run build
# Deploy to Netlify
# Upload build/ folder or connect GitHub repository# Build production bundle
npm run build
# Serve using nginx/apache
# Configure reverse proxy for API calls# 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# Install Railway CLI
npm install -g @railway/cli
# Deploy API
cd FinSightApp/API
railway login
railway init
railway up# 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"]cd FinSightApp
# Build production APK
eas build --platform android --profile production
# Submit to Google Play
eas submit --platform android# Build for iOS (requires macOS)
eas build --platform ios --profile production
# Submit to App Store
eas submit --platform ios# Build standalone APK
eas build --platform android --profile preview
# Download APK from Expo dashboard
# Distribute via website or direct download# 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"]
)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';
}
}
}# 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)// FinSightApp/metro.config.js
module.exports = {
transformer: {
minifierConfig: {
keep_classnames: true,
keep_fnames: true,
mangle: {
keep_classnames: true,
keep_fnames: true,
},
},
},
};# 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
)# 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@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
}# .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- Use PostgreSQL for production instead of SQLite
- Implement connection pooling
- Add database indexes for frequently queried fields
- Consider read replicas for heavy read workloads
- Use multiple Uvicorn workers
- Implement Redis for caching
- Add API rate limiting
- Use load balancer for multiple API instances
- Use CDN for static assets (images, CSS, JS)
- Optimize images and compress assets
- Implement browser caching headers
APK Link: ## π¦ Download
Dashboard Link: https://finsight-front-back-3.onrender.com