Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
232 changes: 232 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
# FARM Management System

## Project Description

FARM Management System is a comprehensive desktop application built with JavaFX for managing agricultural operations. The system provides tools for tracking production, managing employees, suppliers, and sales operations with an intuitive graphical user interface.

## Features

### Core Functionality
- **User Authentication**: Secure login/signup system for admin users
- **Production Management**: Track farm production with detailed records including:
- Crop types and quantities
- Pricing and dates
- Employee assignments
- Supplier information
- **Employee Management**: Manage farm workforce and track employee activities
- **Supplier Management**: Maintain supplier relationships and records
- **Sales Operations**: Handle sales transactions and tracking
- **Production Monitoring**: Daily production tracking and consumption monitoring
- **Dashboard**: Visual analytics with charts and real-time counters
- **Profile Management**: User profile and account management

### Technical Features
- **Secure Database Operations**: SQL injection prevention with parameterized queries
- **Connection Pooling**: Efficient database connection management
- **Input Validation**: Comprehensive form validation and sanitization
- **Error Handling**: User-friendly error messages and exception handling
- **Configuration Management**: Centralized configuration system

## Technology Stack

- **Frontend**: JavaFX 17 for desktop GUI
- **Backend**: Java 17
- **Database**: MySQL 8.0
- **Build Tool**: Maven 3.6+
- **Architecture**: Model-View-Controller (MVC) pattern

## Database Schema

The system uses three main tables:

### `admin` Table
- User authentication and profile information
- Fields: id, email, password, full_name, NTele, DateBird, Age, image_path

### `production` Table
- Production records and tracking
- Fields: id, metrage, Nom_de_race, Quantite, Qantite_Finale, Prix, Date_dentre, Nom_de_lemploye, nom_de_fournisseur, origine

### `suivi_production` Table
- Daily production monitoring
- Fields: id, quantite_par_jour, date, consomation, emploiyee

## Installation and Setup

### Prerequisites
- Java 17 or higher
- Maven 3.6 or higher
- MySQL 8.0 or higher

### Database Setup
1. Install and start MySQL server
2. Create a database named `myprojectjavafx`
3. Import the provided SQL file:
```bash
mysql -u root -p myprojectjavafx < myprojectjavafx.sql
```

### Application Setup
1. Clone the repository:
```bash
git clone https://github.com/Saidgarnit/FARM.git
cd FARM
```

2. Configure database connection in `src/main/resources/config.properties`:
```properties
db.url=jdbc:mysql://localhost:3306/myprojectjavafx
db.username=root
db.password=your_password
```

3. Build the project:
```bash
mvn clean compile
```

4. Run the application:
```bash
mvn javafx:run
```

## Configuration

The application uses a configuration file located at `src/main/resources/config.properties`. Key settings include:

- Database connection parameters
- Connection pool settings
- Application metadata
- Session timeout settings

## Security Features

### Implemented Security Measures
- **SQL Injection Prevention**: All database queries use parameterized statements
- **Input Sanitization**: User inputs are sanitized before processing
- **Password Security**: Secure password hashing with salt (for new implementations)
- **Connection Security**: Secure database connection management
- **Session Management**: Proper session handling and timeout

### Recommended Security Enhancements
- Implement password hashing for existing user accounts
- Add role-based access control (RBAC)
- Implement audit logging
- Add data encryption for sensitive information
- Enable HTTPS for any future web components

## Development

### Project Structure
```
src/
β”œβ”€β”€ main/
β”‚ β”œβ”€β”€ java/com/example/login/
β”‚ β”‚ β”œβ”€β”€ Controllers/ # UI Controllers
β”‚ β”‚ β”‚ └── Farmer/ # Farm-specific controllers
β”‚ β”‚ β”œβ”€β”€ Models/ # Data models
β”‚ β”‚ β”œβ”€β”€ Views/ # View management
β”‚ β”‚ β”œβ”€β”€ ConfigManager.java # Configuration management
β”‚ β”‚ β”œβ”€β”€ DatabaseManager.java # Database operations
β”‚ β”‚ β”œβ”€β”€ SecurityUtils.java # Security utilities
β”‚ β”‚ └── App.java # Main application class
β”‚ └── resources/
β”‚ β”œβ”€β”€ Fxml/ # FXML layout files
β”‚ β”œβ”€β”€ Images/ # Application images
β”‚ β”œβ”€β”€ Styles/ # CSS stylesheets
β”‚ └── config.properties # Configuration file
```

### Code Quality Guidelines
- Follow Java naming conventions
- Use parameterized queries for database operations
- Implement proper exception handling
- Add input validation for all user inputs
- Use the provided utility classes for security operations

## Testing

### Running Tests
```bash
mvn test
```

### Manual Testing
1. Start the application
2. Test user authentication
3. Verify CRUD operations for production records
4. Test search and filtering functionality
5. Validate input validation and error handling

## Recent Improvements

### Build and Configuration
- βœ… Fixed Maven build configuration (Java 17 compatibility)
- βœ… Removed duplicate JavaFX dependencies
- βœ… Added proper MySQL connector dependency
- βœ… Updated to stable JavaFX versions
- βœ… Added configuration management system

### Security Enhancements
- βœ… Fixed SQL injection vulnerabilities
- βœ… Added input validation and sanitization
- βœ… Implemented proper database connection pooling
- βœ… Added comprehensive error handling
- βœ… Created security utilities for password management

### Code Quality
- βœ… Improved database connection management
- βœ… Added proper resource cleanup
- βœ… Enhanced user feedback with alerts
- βœ… Implemented validation for user inputs
- βœ… Added confirmation dialogs for destructive operations

## Future Enhancements

### Planned Features
- [ ] Implement proper password hashing for existing accounts
- [ ] Add role-based access control
- [ ] Create comprehensive unit tests
- [ ] Add internationalization support
- [ ] Implement data export/import functionality
- [ ] Add reporting and analytics features
- [ ] Create mobile-responsive web interface
- [ ] Implement real-time notifications

### Technical Improvements
- [ ] Add logging framework (SLF4J + Logback)
- [ ] Implement dependency injection
- [ ] Add caching mechanisms
- [ ] Create REST API endpoints
- [ ] Add automated testing pipeline
- [ ] Implement continuous integration/deployment

## Contributing

1. Fork the repository
2. Create a feature branch (`git checkout -b feature/new-feature`)
3. Commit your changes (`git commit -am 'Add new feature'`)
4. Push to the branch (`git push origin feature/new-feature`)
5. Create a Pull Request

## License

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

## Support

For support and questions, please:
1. Check the documentation above
2. Search existing issues on GitHub
3. Create a new issue with detailed information about your problem

## Authors

- **Said** - Initial work and development
- **Contributors** - See GitHub contributors list

## Acknowledgments

- JavaFX community for excellent desktop application framework
- MySQL team for robust database system
- Maven community for build automation tools
Empty file modified mvnw
100644 β†’ 100755
Empty file.
21 changes: 10 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,30 +12,29 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<junit.version>5.9.2</junit.version>
<javafx.version>17.0.2</javafx.version>
<mysql.version>8.0.33</mysql.version>
</properties>

<dependencies>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>21-ea+24</version>
<version>${javafx.version}</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>21-ea+24</version>
<version>${javafx.version}</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.openjfx/javafx-fxml -->
<!-- MySQL Connector -->
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>21-ea+24</version>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>${mysql.version}</version>
</dependency>


<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->


<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
Expand All @@ -62,8 +61,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>21</source>
<target>21</target>
<source>17</source>
<target>17</target>
</configuration>
</plugin>
<plugin>
Expand Down
90 changes: 90 additions & 0 deletions src/main/java/com/example/login/ConfigManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package com.example.login;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
* Configuration manager for application settings
*/
public class ConfigManager {
private static ConfigManager instance;
private Properties properties;

private ConfigManager() {
loadConfiguration();
}

public static ConfigManager getInstance() {
if (instance == null) {
instance = new ConfigManager();
}
return instance;
}

private void loadConfiguration() {
properties = new Properties();
try (InputStream input = getClass().getClassLoader().getResourceAsStream("config.properties")) {
if (input != null) {
properties.load(input);
} else {
// Load default configuration if file doesn't exist
loadDefaultConfiguration();
}
} catch (IOException e) {
System.err.println("Error loading configuration: " + e.getMessage());
loadDefaultConfiguration();
}
}

private void loadDefaultConfiguration() {
// Default database configuration
properties.setProperty("db.url", "jdbc:mysql://localhost:3306/myprojectjavafx");
properties.setProperty("db.username", "root");
properties.setProperty("db.password", "");
properties.setProperty("db.driver", "com.mysql.cj.jdbc.Driver");
properties.setProperty("db.pool.max.connections", "10");
properties.setProperty("db.pool.min.connections", "2");

// Application settings
properties.setProperty("app.title", "FARM Management System");
properties.setProperty("app.version", "1.0");
properties.setProperty("app.session.timeout", "30");
}

public String getDatabaseUrl() {
return properties.getProperty("db.url");
}

public String getDatabaseUsername() {
return properties.getProperty("db.username");
}

public String getDatabasePassword() {
return properties.getProperty("db.password");
}

public String getDatabaseDriver() {
return properties.getProperty("db.driver");
}

public int getMaxConnections() {
return Integer.parseInt(properties.getProperty("db.pool.max.connections", "10"));
}

public int getMinConnections() {
return Integer.parseInt(properties.getProperty("db.pool.min.connections", "2"));
}

public String getAppTitle() {
return properties.getProperty("app.title");
}

public String getAppVersion() {
return properties.getProperty("app.version");
}

public int getSessionTimeout() {
return Integer.parseInt(properties.getProperty("app.session.timeout", "30"));
}
}
Loading