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