# Module Planning: Cooperative Module ## Overview The Cooperative Module manages associations of users (members) who work together, typically in agriculture. It integrates deeply with `user_infos` to provide a complete picture of each member. ## Data Models ### `Organization` (existing) Used to store the cooperative's main details. - `id` (Primary Key) - `hashkey` (String, Unique) - `name` (String) - `type` (Enum: `COOPERATIVE`, `ASSOCIATION`, `COMPANY`) - `address` (Text) - `is_active` (Boolean) ### `CooperativeMember` [NEW] Links users to cooperatives. - `id` (Primary Key) - `hashkey` (String, Unique) - `organization_id` (Foreign Key to `organizations`) - `user_id` (Foreign Key to `users`) - `role` (String: `MEMBER`, `OFFICER`, `ADMIN`) - `joined_at` (DateTime) - `is_active` (Boolean) - `created_by` (Foreign Key to `users`) - `updated_by` (Foreign Key to `users`) ### `UserInfo` [NEW] Detailed personal information for users, expanding the core `users` table. - `id` (Primary Key) - `hashkey` (String, Unique) - `user_id` (Foreign Key to `users`) - `firstname` (String) - `middlename` (String) - `lastname` (String) - `fullname` (String) - Generated or stored - `landline` (String) - `mobile` (String) - `email` (String) - `alt_email` (String) - `alt_landline` (String) - `alt_mobile` (String) - `facebook_url` (String) - `bank_details` (JSON) - `addresses` (JSON) - Array of address objects - `other_details` (JSON) - `is_active` (Boolean) - `created_by` (Foreign Key to `users`) - `updated_by` (Foreign Key to `users`) ## Core Workflows 1. **Cooperative Management**: Creating and updating cooperative profiles (using `organizations` table). 2. **Member Enrollment**: Adding users to a cooperative and assigning roles. 3. **User Profile Completion**: Linking users to their detailed `userinfo` record. ## API Endpoints (Proposed) | Endpoint | Method | Description | |----------|--------|-------------| | `/api/cooperatives` | GET | List all cooperatives | | `/api/cooperatives/{hashkey}/members` | GET | List members of a cooperative | | `/api/cooperatives/{hashkey}/join` | POST | Request to join or add a member | | `/api/user-info/{user_hashkey}` | GET | Get detailed user info | | `/api/user-info/{user_hashkey}` | POST/PUT | Update detailed user info | ## UI Components (Vue) - **CooperativeList.vue**: Standard list of cooperatives. - **CooperativeDetail.vue**: detailed view with member list. - **UserInfoEdit.vue**: Comprehensive form for editing personal details.