# Kotlin Android Calculator - Complete File Documentation

**Developer**: RSK World  
**Website**: https://rskworld.in  
**Contact**: help@rskworld.in, +91 93305 39277  
**Location**: Nutanhat, Mongolkote, Purba Burdwan, West Bengal, India - 713147  
**Year**: 2026  

---

## 📁 Project Root Directory Structure

### 📄 Core Configuration Files

#### `build.gradle.kts`
- **Purpose**: Top-level Gradle build configuration
- **Content**: Plugin declarations for Android application, Kotlin, and Compose
- **Dependencies**: Defines plugins used across all modules
- **Importance**: Controls build tools and plugin versions for the entire project

#### `settings.gradle.kts`
- **Purpose**: Gradle settings configuration
- **Content**: Project name and module inclusion settings
- **Function**: Defines the project structure and module dependencies
- **Key Settings**: `rootProject.name = "kotlin-android-calculator"`

#### `gradle.properties`
- **Purpose**: Gradle build properties and optimizations
- **Content**: Build performance settings, memory allocation, and Android build options
- **Optimizations**: Includes settings for AndroidX, R8 full mode, and build caching
- **Importance**: Affects build speed and output quality

#### `gradlew` & `gradlew.bat`
- **Purpose**: Gradle wrapper scripts for Unix and Windows systems
- **Function**: Allows building the project without installing Gradle globally
- **Cross-Platform**: `gradlew` for Linux/macOS, `gradlew.bat` for Windows
- **Usage**: `./gradlew build` or `gradlew.bat build`

#### `local.properties`
- **Purpose**: Local development environment configuration
- **Content**: SDK paths and local machine-specific settings
- **Security**: Should not be committed to version control
- **Function**: Points to Android SDK installation

#### `.gitignore`
- **Purpose**: Git version control ignore rules
- **Content**: Patterns for files and directories to exclude from version control
- **Exclusions**: Build outputs, IDE files, local properties, and temporary files
- **Importance**: Keeps repository clean and avoids committing sensitive data

---

## 📱 App Module Structure (`/app`)

### 🏗️ Build Configuration

#### `app/build.gradle.kts`
- **Purpose**: App-level Gradle build configuration
- **Key Sections**:
  - **Plugins**: Android application, Kotlin, and Compose plugins
  - **Android Configuration**: 
    - Namespace: `com.rskworld.kotlin_android_calculator`
    - Compile SDK: 36 (Android 14)
    - Min SDK: 24 (Android 7.0)
    - Target SDK: 36
    - Version Code: 1, Version Name: "1.0"
  - **Build Types**: Debug and release configurations
  - **Compile Options**: Java 11 compatibility
  - **Compose Features**: Enables Jetpack Compose
- **Dependencies**: 
  - AndroidX libraries
  - Jetpack Compose BOM and components
  - Material Design 3
  - Gson for JSON parsing
  - Testing frameworks (JUnit, Espresso)

#### `app/proguard-rules.pro`
- **Purpose**: ProGuard/R8 optimization rules for release builds
- **Function**: Code obfuscation and optimization settings
- **Importance**: Reduces APK size and protects source code

---

### 📋 Android Manifest

#### `app/src/main/AndroidManifest.xml`
- **Purpose**: Android application manifest file
- **Key Declarations**:
  - **Application**: Backup rules, data extraction rules, icons, theme
  - **MainActivity**: Launch activity configuration
  - **Intent Filter**: Makes the app appear in launcher
- **Permissions**: None required (basic calculator app)
- **Theme**: `@style/Theme.Kotlinandroidcalculator`

---

### 💻 Source Code (`/app/src/main/java/com/rskworld/kotlin_android_calculator/`)

#### 🏠 `MainActivity.kt`
- **Purpose**: Main entry point and navigation controller
- **Key Features**:
  - Premium glass morphism design
  - Bottom navigation with 5 tabs
  - Animated background effects
  - Tab switching between different calculators
- **Navigation Tabs**:
  1. Calculator (`RealCalculatorScreen`)
  2. Converter (`RedesignedUnitConverterScreen`)
  3. Financial (`FinancialCalculatorScreen`)
  4. Health (`HealthCalculatorScreen`)
  5. Extras (`ExtrasScreen`)
- **UI Components**: Custom navigation bar with animations and haptic feedback
- **Design**: Material Design 3 with custom glass effects

#### 🧮 `RealCalculatorScreen.kt`
- **Purpose**: Advanced calculator with scientific functions
- **Features**:
  - **Basic Operations**: Addition, subtraction, multiplication, division
  - **Scientific Functions**: sin, cos, tan, log, ln, √, x², x^y, n!, π
  - **Memory Operations**: MC, MR, M+, M-, MS
  - **Display**: Large display with expression and result
  - **History**: Calculation history with tap-to-use functionality
  - **Modes**: Toggle between Standard and Scientific modes
- **UI Design**:
  - Glass morphism effects
  - Animated buttons with haptic feedback
  - Scrollable layout for portrait mode
  - Professional calculator color scheme
- **State Management**: React state for display, operations, memory, and history

#### 🔄 `RedesignedUnitConverterScreen.kt`
- **Purpose**: Comprehensive unit converter with real-time conversion
- **Conversion Categories**:
  - **Length**: Meter, Kilometer, Centimeter, Millimeter, Mile, Yard, Foot, Inch
  - **Weight**: Kilogram, Gram, Milligram, Pound, Ounce, Ton
  - **Temperature**: Celsius, Fahrenheit, Kelvin
  - **Volume**: Liter, Milliliter, Gallon, Quart, Pint, Cup
  - **Area**: Square Meter, Square Kilometer, Square Foot, Square Yard, Acre, Hectare
  - **Speed**: Meter/Second, Kilometer/Hour, Mile/Hour, Knot
  - **Data**: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte
  - **Time**: Second, Minute, Hour, Day, Week, Month, Year
- **Features**:
  - Real-time conversion as you type
  - Quick conversion examples for each category
  - Animated swap button for units
  - Custom dropdown menus with search
  - Responsive design with glass effects
- **UI Components**: Category chips, unit selectors, result display, quick conversions panel

#### 💰 `FinancialCalculatorScreen.kt`
- **Purpose**: Financial calculations for EMI and GST
- **EMI Calculator**:
  - Loan amount input
  - Interest rate (annual)
  - Tenure in years
  - Monthly EMI calculation using standard formula
- **GST Calculator**:
  - Original amount
  - GST rate percentage
  - GST amount calculation
  - Total amount including GST
- **Features**:
  - Segmented control for switching between EMI and GST
  - Input validation
  - Professional result display with breakdown
  - Haptic feedback on calculations

#### ❤️ `HealthCalculatorScreen.kt`
- **Purpose**: Health and fitness calculations
- **BMI Calculator**:
  - Weight input (kg)
  - Height input (cm)
  - BMI calculation and categorization
  - BMI reference ranges display
- **BMR Calculator**:
  - Gender selection (Male/Female)
  - Weight, height, and age inputs
  - Basal Metabolic Rate calculation
  - Daily calorie estimation for sedentary lifestyle
- **Features**:
  - Segmented control for switching between BMI and BMR
  - Health category indicators
  - Professional medical calculation formulas
  - Educational health information

#### ➕ `ExtrasScreen.kt`
- **Purpose**: Additional utility calculators
- **Age Calculator**:
  - Date of birth input (YYYY-MM-DD format)
  - Age calculation in years, months, and days
  - Future date validation
- **Discount Calculator**:
  - Original price input
  - Discount percentage
  - Final price and savings calculation
- **Navigation**: Two-level segmented control for organizing multiple tools
- **Integration**: Links to Student Calculator, Advanced Finance, and Settings screens

#### 🛠️ `Utils.kt`
- **Purpose**: Utility functions and validation helpers
- **CalculatorUtils**:
  - Number formatting with proper decimal handling
  - Input validation and sanitization
  - Factorial calculation for scientific functions
- **FinancialUtils**:
  - EMI calculation using standard formula
  - GST calculation helper
- **HealthUtils**:
  - BMI calculation and categorization
  - BMI category determination
- **ConversionUtils**:
  - Input validation for unit conversions
  - Result formatting with scientific notation
- **ErrorHandler**:
  - Error message generation for calculator operations
  - Conversion error handling

---

### 🎨 UI Theme System (`/app/src/main/java/com/rskworld/kotlin_android_calculator/ui/theme/`)

#### `Theme.kt`
- **Purpose**: Material Design 3 theme configuration
- **Components**:
  - Custom color schemes for calculator interface
  - Typography definitions
  - Shape definitions for buttons and cards
  - Glass morphism theme components
- **Features**:
  - Dark/light theme support
  - Calculator-specific color palette
  - Custom component themes

#### `Color.kt`
- **Purpose**: Color definitions for the app
- **Color Categories**:
  - Calculator button colors (Number, Operator, Function, Clear, Equals)
  - Glass effect colors and borders
  - Display and text colors
  - Background gradients
  - Accent colors for highlights

#### `Type.kt`
- **Purpose**: Typography definitions
- **Font Styles**:
  - Display text styles
  - Calculator display fonts
  - Button text styles
  - Heading and body text styles
- **Features**: Custom font sizes and weights for different UI elements

---

### 🖼️ Resources (`/app/src/main/res/`)

#### `drawable/`
- **`ic_calculator.xml`**: Custom calculator icon for the app
- **`ic_launcher_background.xml`**: Launcher icon background
- **`ic_launcher_foreground.xml`**: Launcher icon foreground

#### `mipmap*/`
- **Purpose**: App launcher icons in different densities
- **Densities**: mdpi, hdpi, xhdpi, xxhdpi, xxxhdpi
- **Variants**: Regular and round launcher icons

#### `values/`
- **`strings.xml`**: App strings and text resources
- **`colors.xml`**: Additional color resources
- **`themes.xml`**: Android theme definitions

#### `xml/`
- **`backup_rules.xml`**: Android backup configuration
- **`data_extraction_rules.xml`**: Data extraction policies

---

### 🧪 Test Files

#### `app/src/test/java/com/rskworld/kotlin_android_calculator/ExampleUnitTest.kt`
- **Purpose**: Unit tests for calculator logic
- **Framework**: JUnit
- **Coverage**: Basic mathematical operations and utility functions

#### `app/src/androidTest/java/com/rskworld/kotlin_android_calculator/ExampleInstrumentedTest.kt`
- **Purpose**: Instrumentation tests for UI interactions
- **Framework**: AndroidX Test and Espresso
- **Coverage**: UI component testing and user interactions

---

## 📄 Documentation Files

### `README.md`
- **Purpose**: Project overview and getting started guide
- **Contents**: 
  - Project information and developer details
  - Feature descriptions
  - Installation instructions
  - Usage guidelines
  - Technical specifications
  - Educational value and contribution guidelines

### `LICENSE`
- **Purpose**: MIT License with educational use provisions
- **Contents**:
  - Standard MIT license terms
  - Third-party library licenses
  - Educational use permissions
  - Contact and attribution information

### `index.html`
- **Purpose**: Demo and documentation website
- **Features**:
  - Responsive design with Tailwind CSS
  - Interactive feature showcase
  - Installation guide
  - Technology stack overview
  - Contact information
  - Smooth animations and transitions

### `FILE_DOCUMENTATION.md` (This File)
- **Purpose**: Comprehensive file and folder documentation
- **Contents**: Detailed explanation of every file and directory in the project

---

## 📊 Project Summary

### Total Files Count
- **Kotlin Files**: 15 main source files + 3 theme files + 2 test files = 20
- **XML Files**: 11 resource files
- **Configuration Files**: 6 Gradle and build files
- **Documentation Files**: 4 (README, LICENSE, index.html, this file)
- **Total**: ~41 files

### Code Complexity
- **Lines of Code**: ~4,000+ lines of Kotlin code
- **UI Components**: 50+ Compose components
- **Features**: 5 main calculator modules with 20+ sub-features
- **Supported Conversions**: 8 categories with 50+ unit types

### Architecture Highlights
- **Modern Android**: Jetpack Compose, Material Design 3, Kotlin Coroutines
- **Clean Architecture**: Separated concerns with utility classes
- **Responsive Design**: Adaptive layouts for different screen sizes
- **Professional UI**: Glass morphism effects, animations, haptic feedback
- **Comprehensive Testing**: Unit tests and instrumentation tests

---

## 🚀 Build and Deployment

### Build Commands
```bash
# Debug build
./gradlew assembleDebug

# Release build
./gradlew assembleRelease

# Clean build
./gradlew clean

# Run tests
./gradlew test
./gradlew connectedAndroidTest
```

### Output Files
- **Debug APK**: `app/build/outputs/apk/debug/app-debug.apk`
- **Release APK**: `app/build/outputs/apk/release/app-release.apk`
- **Bundle**: `app/build/outputs/bundle/release/app-release.aab`

---

## 📞 Support and Contact

For any questions about the project structure, implementation details, or technical support:

- **Developer**: RSK World
- **Email**: help@rskworld.in
- **Phone**: +91 93305 39277
- **Website**: https://rskworld.in
- **Location**: Nutanhat, Mongolkote, Purba Burdwan, West Bengal, India - 713147

---

**© 2026 RSK World. All rights reserved.**  
This documentation is part of the Kotlin Android Calculator App project, provided as a free educational resource for developers worldwide.
