# Medella v0.6 — Client Portal & Institutional Engagement

## Scope
- Separate client portal sign-in and session namespace, distinct from staff/admin accounts.
- Client account management by authorised workspace staff.
- Client dashboard, projects, engagement requests and secure document centre.
- Consultation, medical supply quotation, technical support, partnership and other request types.
- Admin workflows to create/update client projects, respond to requests and upload client documents.
- Private document storage on Laravel's `local` disk; downloads require authenticated ownership and visibility.
- Portal pages use `noindex,nofollow` and are not a public SEO content surface.

## Required existing foundation
This is an incremental Laravel package and assumes the integrated v0.1–v0.5 application:
- Laravel 12 with MySQL/MariaDB.
- Existing staff `users` table, staff authentication and role middleware.
- Existing `admin.role` and `admin.audit` middleware aliases.
- Existing public site layout, named routes and CMS.
- Existing v0.5 ecommerce/admin routes if that increment is installed.

## Apply
1. Back up application files and database.
2. Merge this package's `app/`, `database/`, `resources/` and `routes/` directories into the existing application.
3. In `routes/web.php`, require both route files:
   ```php
   require __DIR__.'/admin.php';
   require __DIR__.'/client-portal.php';
   ```
   Place these before the catch-all dynamic CMS route.
4. Register the middleware alias in `bootstrap/app.php`:
   ```php
   'client.portal' => \App\Http\Middleware\EnsureClientPortalUser::class,
   ```
   Retain existing `admin.role`, `admin.audit` and (if v0.5 installed) `store.enabled` aliases.
5. Run:
   ```bash
   php artisan migrate
   php artisan optimize:clear
   ```
6. Confirm Laravel's `local` filesystem disk points to private storage outside the public web root.
7. Test with at least two client accounts and verify each can only see its own projects, requests and documents.

## Client account workflow
- No public self-registration in this increment. Workspace staff creates accounts and shares initial passwords securely.
- Passwords must be at least 12 characters.
- Client portal login is separate from staff/admin login.
- Suspended accounts cannot sign in.
- Password reset email, email verification and MFA are not included yet; add these before broad production rollout.
- Do not send initial passwords in ordinary email or expose them in admin notes.

## Engagement workflow
- Clients can submit consultation, medical supply quotation, technical support, partnership and other requests.
- Staff review, update status and add a response visible to the client.
- Staff create projects and assign them to client accounts. Progress, service area, dates and status are visible to clients.
- Internal project notes are not displayed in client views.

## Documents
- Allowed: PDF, DOC/DOCX, XLS/XLSX, CSV, JPG/JPEG and PNG; maximum 10 MB.
- Files are stored on Laravel's private local disk and streamed only after ownership and visibility checks.
- This version does not implement virus scanning, document versioning or expiring download links.

## SSO readiness
The portal has separate client accounts and session middleware, but this is not a completed SSO implementation. SAML 2.0 / OpenID Connect federation, identity-provider configuration, MFA and automated provisioning are future work.

## Security and production readiness
- Use HTTPS and secure session cookie settings.
- Add email verification, password reset, MFA and login anomaly monitoring before production launch.
- Consider organisation-level multi-user memberships in a later version.
- Test cross-client access, suspended accounts, session fixation, file downloads and route throttling.
- This source package has not been deployed to Namecheap or runtime-tested against the complete application/database.
