A comprehensive, secure payment management system built for textile operations with role-based access control, automated workflows, and real-time notifications.
# Backend
cd backend
docker-compose up --build
# API available at http://localhost:8000
# Mobile App
cd payments
npm install
npx expo startDefault login: admin / admin
graph TB
Mobile[React Native App] --> FastAPI[FastAPI Backend]
FastAPI --> PostgreSQL[(PostgreSQL)]
FastAPI --> Redis[(Redis Rate Limiter)]
FastAPI --> Firebase[Firebase FCM]
FastAPI --> Railway[Railway Cloud]
sequenceDiagram
participant User
participant App
participant Backend
User->>App: Login
App->>Backend: POST /auth/login
Backend->>App: JWT Token
App->>Backend: API Calls + JWT
Backend->>App: Data Response
sequenceDiagram
participant App
participant FastAPI
participant PostgreSQL
participant Redis
App->>FastAPI: Login Request
FastAPI->>Redis: Check Rate Limit
FastAPI->>PostgreSQL: Validate User
PostgreSQL->>FastAPI: User Data
FastAPI->>App: JWT Token
App->>FastAPI: API Request + JWT
FastAPI->>Redis: Check Rate Limit
FastAPI->>PostgreSQL: Execute Query
PostgreSQL->>FastAPI: Data
FastAPI->>App: Response
stateDiagram-v2
[*] --> Executive_Creates
Executive_Creates --> Submitted: Executive Submits
Submitted --> AccountantApproved: Accountant Reviews
Submitted --> Declined: Rejected
AccountantApproved --> AdminApproved: Admin Reviews
AccountantApproved --> Declined: Admin Rejects
AdminApproved --> [*]
Declined --> [*]
sequenceDiagram
participant APScheduler
participant NotificationService
participant Database
participant Firebase
participant Users
APScheduler->>NotificationService: Trigger Overdue Check (Daily)
NotificationService->>Database: Query Overdue Bills
Database->>NotificationService: Return Overdue Bills List
loop For each overdue bill
NotificationService->>Database: Get Assigned Users
Database->>NotificationService: Return User Tokens
NotificationService->>Firebase: Send Push Notification
Firebase->>Users: Deliver Notification
end
NotificationService->>APScheduler: Schedule Next Check
- FastAPI - Modern Python web framework
- PostgreSQL - Primary database with ACID compliance
- SQLAlchemy + Alembic - ORM and database migrations
- Redis - Rate limiting storage and caching layer
- SlowAPI - Rate limiting middleware (Redis-backed)
- APScheduler - Background task scheduling
- JWT Authentication - Secure token-based auth
- bcrypt - Password hashing and verification
- Firebase Admin SDK - Push notifications
- React Native - Cross-platform mobile development
- Expo - Development platform and build tools
- Redux Toolkit - Predictable state management
- React Navigation - Screen navigation and routing
- expo-secure-store - Secure token storage
- expo-notifications - Push notification handling
- React Hook Form - Form management and validation
- Docker + docker-compose - Containerization
- Railway - Cloud deployment platform
- Firebase Cloud Messaging - Push notifications
- GitHub - Version control and CI/CD
- โ Role-based Authentication (Admin/Accountant/Executive)
- โ Payment Management with two-stage approval workflow
- โ Rate Limiting on all 56 API endpoints using Redis
- โ Legacy Data Import from .DBF files with validation
- โ Real-time Push Notifications via Firebase FCM
- โ Automated Scheduling for overdue bill alerts
- โ Secure Mobile App with encrypted token storage
- โ Company & Bill Management with promise date tracking
- โ Comprehensive Testing (56+ test files covering all scenarios)
- โ Production Deployment on Railway cloud platform
-
Executive:
- View assigned companies and their bills
- Submit payment requests with proper documentation
- Track payment status and approval progress
-
Accountant:
- Review payment submissions with bill details
- Approve or decline payments with comments
- Monitor company payment histories
-
Admin:
- Final approval authority for all payments
- User management and role assignment
- System configuration and data imports
- Access to comprehensive analytics and reports
-
System Automation:
- Auto-notify stakeholders on overdue bills
- Schedule and trigger notification scans
- Maintain audit trails for all operations
POST /auth/login # Login with username/password
GET /auth/me # Get current user profile
POST /auth/logout # Invalidate current session
POST /payments # Submit new payment request
GET /payments # List payments (role-based filtering)
GET /payments/{id} # Get payment details
PATCH /payments/{id} # Update payment details
# Accountant Routes
POST /accountant/payments/{id}/approve # Accountant approval
POST /accountant/payments/{id}/decline # Accountant rejection
GET /accountant/pending # Pending accountant approvals
# Admin Routes
POST /admin/payments/{id}/approve # Admin final approval
POST /admin/payments/{id}/decline # Admin rejection
GET /admin/pending # Pending admin approvals
GET /companies # List all companies
GET /companies/{code} # Company details
GET /companies/{code}/bills # Company bills with status
PATCH /companies/{code}/promise # Update promise date
GET /companies/{code}/payments # Payment history
GET /admin/users # List all users
POST /admin/users # Create new user
GET /admin/users/{id} # User details
PATCH /admin/users/{id} # Update user details
DELETE /admin/users/{id} # Delete user
PATCH /admin/users/{id}/role # Change user role
POST /uploads/master # Import .DBF master data
POST /uploads/transactions # Import transaction data
GET /uploads/status/{job_id} # Check import status
POST /admin/notifications/scan # Trigger notification scan
GET /admin/stats # System statistics
GET /health # Health check endpoint
graph TB
subgraph "Development"
DEV[Local Development]
GIT[Git Commit & Push]
GITHUB[GitHub Repository]
end
subgraph "Railway Cloud Platform"
WEBHOOK[GitHub Webhook]
BUILD[Docker Build]
DEPLOY[Auto Deploy]
subgraph "Production Environment"
APP[FastAPI Application]
PG[(PostgreSQL Database)]
REDIS[(Redis Cache)]
end
end
subgraph "External Services"
FIREBASE[Firebase FCM]
MONITORING[Railway Monitoring]
end
DEV --> GIT
GIT --> GITHUB
GITHUB --> WEBHOOK
WEBHOOK --> BUILD
BUILD --> DEPLOY
DEPLOY --> APP
APP --> PG
APP --> REDIS
APP --> FIREBASE
APP --> MONITORING
graph TB
subgraph "Development"
LOCAL[Local Development]
EXPO_CLI[Expo CLI]
TESTING[Device Testing]
end
subgraph "Expo Platform"
BUILD_SERVICE[Expo Build Service]
APK[APK Generation]
OTA[Over-the-Air Updates]
end
subgraph "Distribution"
INTERNAL[Internal Testing]
DIRECT[Direct APK Distribution]
end
LOCAL --> EXPO_CLI
EXPO_CLI --> TESTING
EXPO_CLI --> BUILD_SERVICE
BUILD_SERVICE --> APK
EXPO_CLI --> OTA
APK --> INTERNAL
APK --> DIRECT
OTA --> INTERNAL
- Backend: Automatic Railway deployment on Git push
- Frontend: Expo build service for APK generation
- Updates: Over-the-air updates for instant app updates
- 56+ Test Files - Comprehensive test suite
- 95%+ Code Coverage - High confidence in code quality
- 200+ Individual Tests - All scenarios covered
- Concurrent Testing - Race condition validation
- Security Testing - Authentication and authorization
mindmap
root((Testing))
Authentication
JWT Validation
Role Permissions
Password Security
Business Logic
Payment Workflows
Bill Calculations
Date Validations
API Security
Rate Limiting
Input Validation
SQL Injection Prevention
Data Integrity
Transaction Safety
Concurrent Operations
Import Validation
# Backend Test Results (Docker)
cd backend
docker-compose exec app pytest tests/ --cov=app --cov-report=html
# Coverage: 96% total across all modules
Authentication Tests: โ
45 tests passing
Payment Workflow Tests: โ
67 tests passing
Security Tests: โ
34 tests passing
Concurrency Tests: โ
28 tests passing
Integration Tests: โ
89 tests passing- Docker & Docker Compose - Container orchestration
- Node.js 18+ - JavaScript runtime for mobile development
- Expo CLI - React Native development tools
- PostgreSQL 13+ - Database for local development
- Redis 6+ - Caching and rate limiting
- Python 3.9+ - Backend development (if running locally)
- Clone Repository
git clone https://github.com/TexZ-GenZ/MoneyManagementApp.git
cd MoneyManagementApp- Backend Setup (Docker)
cd backend
cp .env.example .env
# Edit .env with your configuration
docker-compose up --build
# Backend API available at http://localhost:8000- Backend Setup (Docker - Recommended)
cd backend
cp .env.example .env
# Edit .env with your configuration
docker-compose up --build
# Backend API available at http://localhost:8000- Backend Setup (Local Python - Alternative)
cd backend
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
alembic upgrade head
uvicorn app.main:app --reload --port 8000- Mobile App Setup
cd payments
npm install
npx expo start
# Use Expo Go app or emulator to run- Database Initialization (Docker)
# Create default admin user using Docker
cd backend
docker-compose exec app python -c "
from app.db.session import get_db
from app.services.auth_service import create_user
from app.schemas.user import UserCreate
db = next(get_db())
admin = UserCreate(username='admin', password='admin', full_name='System Admin', role='admin')
create_user(db, admin)
"# Database Configuration
DATABASE_URL=postgresql+psycopg://user:password@localhost:5432/money_management
REDIS_URL=redis://localhost:6379/0
# Authentication Settings
JWT_SECRET=your-super-secret-jwt-key-change-in-production
JWT_ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=60
# Rate Limiting Configuration (Redis-backed)
RATE_LIMIT_LOGIN=10/minute
RATE_LIMIT_PAYMENT_SUBMIT=10/hour
RATE_LIMIT_DATA_READ=60/minute
RATE_LIMIT_DATA_WRITE=30/hour
RATE_LIMIT_ADMIN=100/hour
# Firebase Configuration (for push notifications)
SERVICE_ACCOUNT_FILE=payments-firebase-adminsdk.json
PROJECT_ID=your-firebase-project-id
# Application Settings
ENVIRONMENT=development
DEBUG=true
ALLOWED_HOSTS=localhost,127.0.0.1// app.json configuration
{
"expo": {
"name": "Jaskirat Payments",
"slug": "jaskirat-payments",
"version": "1.0.0",
"platforms": ["ios", "android"],
"android": {
"googleServicesFile": "./google-services.json",
"permissions": ["NOTIFICATIONS"]
},
"notification": {
"icon": "./assets/notification-icon.png"
}
}
}- Average Response Time - < 200ms for standard API calls
- Database Query Optimization - Indexed queries with sub-50ms execution
- Concurrent Users - Successfully tested with 100+ simultaneous users
- Rate Limiting - Redis-backed rate limiting with configurable per-endpoint limits
- Memory Usage - < 512MB RAM usage under normal load
- Database Connections - Connection pooling with max 20 concurrent connections
graph LR
Request[API Request] --> Redis[Redis Check]
Redis --> Allow[โ
Allow]
Redis --> Deny[โ Rate Limited]
subgraph "Limits"
Login[Login: 10/min]
Payment[Payments: 10/hr]
Read[Data: 60/min]
end
- App Startup Time - < 3 seconds cold start
- Navigation Performance - Smooth 60fps transitions
- Memory Management - Optimized with lazy loading and image caching
- Offline Capability - Basic caching for previously viewed data
- Network Efficiency - Optimized API calls with request batching
- Microservices Architecture - Break monolith into specialized services
- Advanced Analytics Dashboard - Business intelligence with charts and reports
- Multi-tenant Support - Support multiple textile companies
- Comprehensive Audit Logging - Detailed activity tracking and compliance
- API Versioning Strategy - Backward compatibility and smooth upgrades
- Advanced Performance Monitoring - APM integration with alerts
- Biometric Authentication - Fingerprint and face ID support
- Offline-first Architecture - Comprehensive offline data synchronization
- Advanced Notifications - Rich notifications with action buttons
- Multi-language Support - Internationalization for regional users
- Dark Mode - UI theme customization
- Tablet Optimization - Responsive design for larger screens
- Advanced Reporting - Custom report builder with export options
- Approval Workflows - Configurable multi-step approval processes
- Integration APIs - Connect with accounting software (QuickBooks, etc.)
- Document Management - File attachments for payments and bills
- Automated Reconciliation - Bank statement matching and reconciliation
- Vendor Management - Comprehensive supplier relationship management
- Fork the Repository - Create your own copy
- Create Feature Branch -
git checkout -b feature/amazing-feature - Implement Changes - Write code with comprehensive tests
- Run Test Suite - Ensure all tests pass
- Submit Pull Request - Detailed description of changes
- Backend: Follow PEP 8 Python style guide
- Frontend: ESLint configuration with Airbnb standards
- Testing: Minimum 90% test coverage for new features
- Documentation: Update README and inline comments
# Backend testing (Docker - Recommended)
cd backend
docker-compose exec app pytest tests/ --cov=app --cov-report=html --cov-fail-under=90
# Backend testing (Local - Alternative)
cd backend
pytest tests/ --cov=app --cov-report=html --cov-fail-under=90
# Frontend testing
cd payments
npm test -- --coverage --watchAll=falseThis project is proprietary software developed for Jaskirat Textiles. All rights reserved.
Status: โ Production Ready - Successfully deployed and running on Railway
Last Updated: September 2025
Version: 1.1.0