Skip to content

rafatahmed/FlahaCalc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

628 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FlahaCalc - Modern TypeScript React Web Application

🚨 SECURITY NOTICE - READ BEFORE DEPLOYMENT

CRITICAL: Before deploying to production, read the security guides:

All production credentials have been secured and must be regenerated before deployment.


🌟 Enterprise-Grade Evapotranspiration Calculation Platform

FlahaCalc is a professional web application for calculating evapotranspiration (ETo) using FAO-56 and ASCE methods. Built with modern TypeScript React architecture and enterprise-grade backend infrastructure.


🏗️ Architecture Overview

Modern Tech Stack

Frontend (TypeScript React)

  • React 18 with TypeScript for type-safe development
  • Redux Toolkit for state management
  • React Router for client-side routing
  • Material-UI for professional UI components
  • Axios for API communication

Backend (Node.js + Express)

  • Express.js with TypeScript
  • PostgreSQL with Prisma ORM
  • JWT Authentication with refresh tokens
  • Security Middleware (Helmet, CORS, Rate Limiting)
  • Comprehensive API with OpenAPI documentation

Database & Infrastructure

  • PostgreSQL for production data storage
  • Prisma ORM for type-safe database operations
  • Redis for session management and caching
  • Docker for containerized deployment
  • CI/CD with automated testing and deployment

🎯 Key Features

Calculation Methods

  • FAO-56 Penman-Monteith method
  • ASCE Standardized Reference method
  • Hourly, Daily, Monthly time scales
  • Weather API Integration (OpenWeatherMap)
  • EPW File Import for monthly calculations

User Management

  • JWT Authentication with secure sessions
  • User Profiles with subscription management
  • Role-Based Access Control
  • Password Reset with email verification

Subscription Tiers

  • 🆓 FREE: 50 calculations/month, basic features
  • 💼 PRO: 500 calculations/month, advanced features
  • 🏢 ENTERPRISE: Unlimited calculations, team features

Professional Features

  • Calculation History with export capabilities
  • Usage Analytics and reporting
  • API Access for enterprise users
  • Team Collaboration tools
  • Custom Branding options

🚀 Quick Start

Development Setup

# Clone the repository
git clone https://github.com/rafatahmed/FlahaCalc.git
cd FlahaCalc

# Install dependencies
npm install

# Setup environment (automatically handled by scripts)
# Backend: Uses backend/.env for development
# Frontend: Uses frontend/.env.development automatically

# Start development servers
npm run dev:backend    # Backend on port 3001
npm run dev:frontend   # Frontend on port 3000

# Run tests
npm test

Production Deployment

# Build for production
npm run build

# Start production server
npm start

# Or use Docker
docker-compose up -d

📁 Project Structure

FlahaCalc/
├── backend/                 # Node.js + Express backend
│   ├── src/
│   │   ├── controllers/     # API controllers
│   │   ├── middleware/      # Security & auth middleware
│   │   ├── models/          # Prisma models
│   │   ├── routes/          # API routes
│   │   ├── services/        # Business logic
│   │   └── utils/           # Utility functions
│   ├── prisma/              # Database schema & migrations
│   ├── tests/               # Backend tests
│   └── package.json
├── frontend/                # React TypeScript frontend
│   ├── src/
│   │   ├── components/      # React components
│   │   ├── hooks/           # Custom hooks
│   │   ├── pages/           # Page components
│   │   ├── services/        # API services
│   │   ├── store/           # Redux store
│   │   ├── types/           # TypeScript types
│   │   └── utils/           # Utility functions
│   ├── public/              # Static assets
│   └── package.json
├── docs/                    # Documentation
├── docker/                  # Docker configurations
└── scripts/                 # Build & deployment scripts

🔐 Security Features

Authentication & Authorization

  • JWT tokens with secure headers
  • Password complexity requirements
  • Session management with refresh tokens
  • Protected API endpoints
  • Role-based access control

Input Validation & Sanitization

  • Comprehensive input sanitization
  • XSS attack prevention
  • SQL injection protection
  • Request size limiting
  • User agent validation

Advanced Security

  • Threat detection patterns
  • Progressive rate limiting
  • Security audit logging
  • CORS configuration
  • Security headers enforcement

💳 Subscription Management

Tier System

  1. FREE Tier ($0/month)

    • 50 calculations per month
    • Basic weather data access
    • Standard calculation methods
    • Email support
  2. PRO Tier ($24/month)

    • 500 calculations per month
    • Advanced weather data
    • All calculation methods
    • Priority support
    • Export capabilities
  3. ENTERPRISE Tier (Custom)

    • Unlimited calculations
    • Team collaboration
    • API access
    • Custom branding
    • Dedicated support

📊 API Documentation

Authentication Endpoints

POST /api/auth/login       # User login
POST /api/auth/register    # User registration
POST /api/auth/logout      # User logout
GET  /api/auth/verify      # Verify session

Calculation Endpoints

POST /api/calculations     # Create calculation
GET  /api/calculations     # Get calculation history
GET  /api/calculations/:id # Get specific calculation
DELETE /api/calculations/:id # Delete calculation

User Management

GET  /api/user/profile     # Get user profile
PUT  /api/user/profile     # Update user profile
GET  /api/user/usage       # Get usage statistics
GET  /api/user/subscription # Get subscription status

🧪 Testing

Test Coverage

  • ✅ Unit tests for all components
  • ✅ Integration tests for API endpoints
  • ✅ End-to-end tests for user workflows
  • ✅ Performance tests for calculations
  • ✅ Security tests for vulnerabilities

Running Tests

npm test                   # Run all tests
npm run test:unit         # Unit tests only
npm run test:integration  # Integration tests
npm run test:e2e          # End-to-end tests
npm run test:coverage     # Coverage report

🚀 Deployment

Environment Configuration

  • Development: Local development with hot reload
  • Staging: Pre-production testing environment
  • Production: Optimized production deployment

Deployment Options

  • Native: Direct server deployment with Ansible
  • DigitalOcean: Cloud hosting with automated deployment
  • AWS/Azure: Enterprise cloud deployment
  • On-Premise: Self-hosted deployment with native services

📚 Documentation


🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Submit a pull request

📄 License

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


🏢 About Flaha Agri Tech

Flaha Agri Tech is dedicated to providing innovative agricultural technology solutions. FlahaCalc represents our commitment to precision agriculture and sustainable water management.

Contact: eng.rafatahmed@hotmail.com Website: https://flahacalc.flaha.org

About

FlahaCalc is a cutting-edge web application designed for advanced calculation and analysis.

Topics

Resources

Stars

Watchers

Forks

Contributors