A comprehensive web application enabling two-way communication between farmers and Village Extension Officers (VEOs) in Tanzania's agriculture system. This platform facilitates knowledge sharing, real-time communication, and agricultural information dissemination.
- User Management: Multi-role system (Farmers, VEOs, Administrators)
- Article System: Publish and manage agricultural content with categorization
- Real-time Chat: Direct messaging between users with file sharing
- Notification System: Real-time alerts for new content and interactions
- Activity Logging: Comprehensive audit trail of user actions
- Profile Management: Detailed user profiles with farming information
- Regional Organization: Tanzania-based regional and village structure
- Crop Management: Track farmer crops and agricultural activities
- Farmers: Access relevant articles, participate in discussions, manage profiles
- Village Extension Officers (VEOs): Create articles, manage content, communicate with farmers
- Administrators: Full system management, user administration, analytics
- Backend: Laravel 12.x (PHP 8.2+)
- Database: PostgreSQL / MySQL
- Frontend: Blade Templates, Bootstrap 5, JavaScript
- Real-time: Pusher WebSockets
- Authentication: Laravel Sanctum
- File Handling: Intervention Image
- Activity Logging: Spatie Laravel Activity Log
- Development: Vite, NPM
- PHP 8.2 or higher
- Composer
- Node.js & NPM
- PostgreSQL or MySQL
- Git
- Clone the repository:
git clone <repository-url>
cd agricom- Install PHP dependencies:
composer install- Install frontend dependencies:
npm install
npm install pusher-js laravel-echo- Copy environment file:
cp .env.example .env- Generate application key:
php artisan key:generate- Configure database in
.env:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=agricom
DB_USERNAME=your_username
DB_PASSWORD=your_password- Configure Pusher for real-time features:
PUSHER_APP_ID=your_app_id
PUSHER_APP_KEY=your_app_key
PUSHER_APP_SECRET=your_app_secret
PUSHER_HOST=
PUSHER_PORT=443
PUSHER_SCHEME=https
PUSHER_APP_CLUSTER=mt1php artisan migratephp artisan db:seedphp artisan storage:link# Start Laravel development server
php artisan serve
# Start Vite development server (in another terminal)
npm run dev
# Or run both simultaneously
composer run devapp/Models/
βββ User.php # User authentication and profiles
βββ Article.php # Agricultural articles and content
βββ Comment.php # Article comments and discussions
βββ ChatConversation.php # Chat conversations
βββ ChatMessage.php # Individual chat messages
βββ ChatParticipant.php # Chat participants management
βββ Notification.php # User notifications
βββ ActivityLog.php # System activity logging
βββ FarmerProfile.php # Detailed farmer information
βββ FarmerCrop.php # Farmer crop tracking
βββ Crop.php # Crop catalog
βββ Region.php # Tanzania regions
βββ Village.php # Villages within regions
app/Http/Controllers/
βββ AuthController.php # Authentication (login, register, logout)
βββ DashboardController.php # Dashboard views and statistics
βββ ProfileController.php # User profile management
βββ ArticleController.php # Article CRUD operations
βββ ChatController.php # Real-time chat functionality
βββ NotificationController.php # Notification management
βββ ActivityLogController.php # Activity log viewing
βββ Admin/
βββ UserManagementController.php # Admin user management
app/Services/
βββ ActivityLogService.php # Activity logging service
βββ NotificationService.php # Notification management service
app/Http/Middleware/
βββ AdminMiddleware.php # Admin access control
βββ RoleMiddleware.php # Role-based access control
βββ ActivityLogMiddleware.php # Automatic activity logging
Laravel Sanctum provides a simple authentication system for SPAs, mobile apps, and token-based APIs.
Use cases:
- API token authentication for mobile/frontend apps
- Session-based authentication for SPAs
Key features:
- Issue and manage API tokens easily
- Protect routes using middleware (
auth:sanctum)
composer require laravel/sanctum
php artisan vendor:publish --provider="Laravel\Sanctum\SanctumServiceProvider"
php artisan migratePusher PHP SDK enables real-time WebSocket communication.
Use cases:
- Real-time notifications
- Live chat applications
- Broadcast events to frontend
How it works: Laravel emits events via broadcasting, and Pusher delivers them instantly to connected clients via WebSocket.
composer require pusher/pusher-php-serverIntervention Image provides powerful image handling and manipulation.
Use cases:
- Resize, crop, watermark, or optimize images
- Generate thumbnails
- Process image uploads
composer require intervention/imageSpatie's Activity Log package tracks changes and actions in your Laravel app.
Use cases:
- Track user actions (login, updates, deletions)
- Audit trails and system logs
- View who did what and when
Features:
- Automatically logs model events
- Customizable log names and descriptions
- Stores data in dedicated activity_log table
composer require spatie/laravel-activitylog
php artisan vendor:publish --provider="Spatie\Activitylog\ActivitylogServiceProvider" --tag="activitylog-migrations"
php artisan migrate- users: User accounts and authentication
- articles: Agricultural content and articles
- comments: Article comments and discussions
- chat_conversations: Chat conversation metadata
- chat_messages: Individual chat messages
- chat_participants: Chat participant management
- notifications: User notification system
- activity_logs: System activity tracking
- farmer_profiles: Detailed farmer information
- farmer_crops: Farmer crop tracking and management
- crops: Crop catalog and information
- regions: Tanzania regions
- villages: Villages within regions
- Farmer: Access articles, participate in discussions, manage profile
- VEO: Create articles, manage content, communicate with farmers
- Admin: Full system administration and user management
- Role-based middleware for route protection
- Policy-based authorization for model operations
- Activity logging for security auditing
POST /login- User loginPOST /register- User registrationPOST /logout- User logout
GET /articles- List articlesPOST /articles- Create article (VEO/Admin only)GET /articles/{id}- View articlePUT /articles/{id}- Update articleDELETE /articles/{id}- Delete article
GET /chat- List conversationsPOST /chat/conversations- Create conversationGET /chat/{id}- View conversationPOST /chat/{id}/messages- Send message
GET /notifications- List notificationsPATCH /notifications/{id}/read- Mark as readDELETE /notifications/{id}- Delete notification
- Set environment to production:
APP_ENV=production
APP_DEBUG=false- Optimize for production:
php artisan config:cache
php artisan route:cache
php artisan view:cache
composer install --optimize-autoloader --no-dev- Set up queue workers for background jobs:
php artisan queue:work- PHP 8.2+
- PostgreSQL 12+ or MySQL 8.0+
- Redis (for caching and queues)
- Web server (Apache/Nginx)
# Run all tests
php artisan test
# Run specific test suite
php artisan test --filter=ArticleTest
# Run with coverage
php artisan test --coveragetests/
βββ Feature/ # Feature tests
βββ Unit/ # Unit tests
βββ TestCase.php # Base test case
- Automatic logging of user actions
- Configurable log levels and retention
- Export capabilities for audit purposes
- Laravel's built-in error logging
- Custom error handling for specific scenarios
- Performance monitoring integration
# Clear all data
php artisan db:wipe
# Refresh migrations and seed
php artisan migrate:fresh --seed
# Backup database
php artisan db:backup# Clear all caches
php artisan cache:clear
php artisan config:clear
php artisan route:clear
php artisan view:clear# Create storage link
php artisan storage:link
# Clean up old files
php artisan storage:clean# Check database connection
php artisan tinker
DB::connection()->getPdo();
# Clear config cache
php artisan config:clear# Set proper permissions
chmod -R 755 storage/
chmod -R 755 bootstrap/cache/# Clear composer cache
composer clear-cache
# Reinstall dependencies
rm -rf vendor/
composer install# Clear npm cache
npm cache clean --force
# Reinstall node modules
rm -rf node_modules/
npm install# Create feature branch
git checkout -b feature/new-feature
# Make changes and commit
git add .
git commit -m "Add new feature"
# Push to remote
git push origin feature/new-feature
# Create pull request# Run Laravel Pint (code style)
./vendor/bin/pint
# Run PHPStan (static analysis)
./vendor/bin/phpstan analyse
# Run tests
php artisan test# Generate model with migration
php artisan make:model ModelName -m
# Generate controller with resource methods
php artisan make:controller ControllerName --resource
# Generate policy
php artisan make:policy ModelNamePolicy
# Generate seeder
php artisan make:seeder SeederName
# List all routes
php artisan route:list
# Clear all caches
php artisan optimize:clear- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- Follow PSR-12 coding standards
- Use Laravel conventions
- Write tests for new features
- Update documentation
This project is licensed under the MIT License - see the LICENSE file for details.
For support and questions:
- Create an issue in the repository
- Contact the development team
- Check the documentation
- Initial release with core functionality
- User management and authentication
- Article system with categorization
- Real-time chat functionality
- Notification system
- Activity logging
- Regional organization
- Crop management
Note: This application is designed specifically for Tanzania's agricultural system and includes regional data and crop information relevant to the local context.