How danielcriollo/pharmacovigilance-lifefile works
1. Overall shape
This is a split frontend/backend Laravel application. Laravel serves a single Blade entry page for the UI, while all domain interaction happens through /api/* endpoints consumed by a Vue 3 SPA.
2. Frontend boundary
The frontend lives under resources/js/pharmacovigilance and is a standalone SPA built with Vue Router and Pinia. Main screens are LoginView and DashboardView, with reusable components for orders, customers, alerts, search, and modals. api.js is the HTTP client layer that centralizes API calls and token handling.
3. Backend API layer
HTTP requests enter through API controllers in app/Http/Controllers/Api/* for auth, customers, medications, orders, and alerts. Controllers are intentionally thin: they accept validated requests, call services, and return standardized JSON through ApiResponse.
4. Validation and request boundaries
FormRequest classes in app/Http/Requests/* enforce inbound validation before business logic runs. This is a clear boundary between untrusted API input and internal service logic, and it is used for login, search, export, and alert-sending flows.
5. Business logic layer
The core domain behavior sits in app/Services. OrderService appears to handle the affected-order search/export workflow, AlertService manages alert creation and dispatch, AuthService handles login/session behavior, and SmsService encapsulates external SMS delivery. Controllers do not talk directly to the database.
6. Persistence and repository pattern
Data access is isolated behind repositories in app/Repositories, with contracts in app/Repositories/Contracts. RepositoryServiceProvider binds interfaces to implementations, so services depend on abstractions rather than Eloquent models directly. This is the main decoupling layer between domain logic and MySQL storage.
7. Domain model
The primary entities are User, Customer, Medication, Order, OrderItem, and Alert. The data model suggests the central use case is tracing customers from orders and medications back to specific recalled lots, then recording who was notified and by which channel.
8. Alerting workflow
The alert path likely starts from a matching order search, then records an Alert and sends notifications. The system supports both single and bulk alerting, and SendAlertForOrderJob indicates bulk notifications are pushed into the queue to avoid request timeouts and to process multiple recipients asynchronously.
9. External integration
SMS delivery is integrated through Vonage, configured via environment variables and wrapped by SmsService. The app also has an email notification template under resources/views/emails/pharmacovigilance/alert.blade.php, so alerting is multi-channel rather than SMS-only.
10. Authentication and access control
Authentication is token-based through Laravel Sanctum, with login handled by AuthController. Role-based protection is enforced by EnsureUserHasRole, which is important for privileged operations such as exports and alert dispatching.
11. Serving model
routes/web.php likely serves the SPA shell at one route, while routes/api.php exposes the functional backend. This means the browser route is mostly a container for Vue, and the actual app state is driven by API responses rather than server-rendered pages.
12. Operational concerns
Background execution uses Laravel’s queue infrastructure, backed by the configured queue system in config/queue.php and the jobs table migration. Docker support via compose.yaml suggests local deployment includes PHP and MySQL services. The database is seeded for test/demo usage, and PHPUnit feature tests cover key API and authorization flows.
Main entry points: api.php API routes · RepositoryServiceProvider.php Repo bindings · OrderController.php Orders API · AlertController.php Alerts API
Components 34
Vue SPA
Single-page frontend for pharmacovigilance workflows.
- SPA shell · Serves the single-page application container for the frontend.
resources/views/pharmacovigilance/index.blade.php - App entry · Bootstraps the pharmacovigilance SPA.
resources/js/pharmacovigilance/main.js - Router · Defines SPA navigation between login and dashboard.
resources/js/pharmacovigilance/router.js - Store · Shared client state for auth and app data.
resources/js/pharmacovigilance/store.js - API client · Centralized API calls and token handling for the SPA.
resources/js/pharmacovigilance/api.js - Login view · Authentication screen.
resources/js/pharmacovigilance/views/LoginView.vue - Dashboard · Main operational screen for searches and alerts.
resources/js/pharmacovigilance/views/DashboardView.vue - UI widgets · Reusable search, order, customer, and alert modals/tables.
resources/js/pharmacovigilance/components
HTTP boundary
Laravel entrypoints, controllers, requests, and middleware.
- Web routes · Serves the SPA shell.
routes/web.php - API routes · Exposes authenticated pharmacovigilance endpoints.
routes/api.php - Auth API · Handles login and auth-related API requests.
app/Http/Controllers/Api/Auth/AuthController.php - Orders API · Search, index, and export order workflows.
app/Http/Controllers/Api/Orders/OrderController.php - Customers API · Customer lookup and retrieval endpoints.
app/Http/Controllers/Api/Customers/CustomerController.php - Medications API · Medication search endpoints.
app/Http/Controllers/Api/Medications/MedicationController.php - Alerts API · Alert creation and bulk dispatch endpoints.
app/Http/Controllers/Api/Alerts/AlertController.php - API response · Standard JSON response helper.
app/Helpers/ApiResponse.php - Role guard · Enforces role-based access for privileged actions.
app/Http/Middleware/EnsureUserHasRole.php - Login request · Validates inbound login payloads.
app/Http/Requests/Auth/LoginRequest.php - Order requests · Validates order search and export inputs.
app/Http/Requests/Orders/OrderIndexRequest.php - Medication request · Validates medication search inputs.
app/Http/Requests/Medications/SearchMedicationRequest.php - Alert requests · Validates single and bulk alert payloads.
app/Http/Requests/Alerts/SendAlertRequest.php
Domain services
Business logic and notification orchestration.
- Auth service · Implements login and session/token behavior.
app/Services/AuthService.php - Order service · Coordinates affected-order search and export workflows.
app/Services/OrderService.php - Customer service · Encapsulates customer-facing domain logic.
app/Services/CustomerService.php - Medication service · Encapsulates medication lookup logic.
app/Services/MedicationService.php - Alert service · Creates alerts and orchestrates notification dispatch.
app/Services/AlertService.php - SMS service · Wraps external SMS delivery.
app/Services/SmsService.php - Alert job · Asynchronous bulk alert dispatch.
app/Jobs/SendAlertForOrderJob.php
Data layer
Repositories, models, and database-backed persistence.
- Repo bindings · Binds repository contracts to implementations.
app/Providers/RepositoryServiceProvider.php - Order repo · Order persistence and query access.
app/Repositories/OrderRepository.php - Customer repo · Customer persistence and query access.
app/Repositories/CustomerRepository.php - Medication repo · Medication persistence and query access.
app/Repositories/MedicationRepository.php - Alert repo · Alert persistence and lookup access.
app/Repositories/AlertRepository.php - User repo · User persistence and lookup access.
app/Repositories/UserRepository.php
Connections 45
- Web routes → SPA shell: serves · Web route returns the SPA entry page.
- API routes → Auth API: maps · Auth endpoints are routed to the auth controller.
- API routes → Orders API: maps · Order endpoints are routed to the order controller.
- API routes → Customers API: maps · Customer endpoints are routed to the customer controller.
- API routes → Medications API: maps · Medication endpoints are routed to the medication controller.
- API routes → Alerts API: maps · Alert endpoints are routed to the alert controller.
- App entry → Router: uses · SPA entry initializes navigation.
- App entry → Store: uses · SPA entry initializes shared state.
- App entry → API client: uses · SPA entry wires the HTTP client.
- Router → Login view: loads · Router exposes the login screen.
- Router → Dashboard: loads · Router exposes the dashboard screen.
- Dashboard → UI widgets: composes · Dashboard assembles reusable workflow components.
- Login view → API client: calls · Login submits credentials through the API client.
- Dashboard → API client: calls · Dashboard issues searches and alert actions through the API client.
- Auth API → Login request: validates · Login input is validated before auth logic runs.
- Auth API → Auth service: delegates · Controller delegates authentication work to the service layer.
- Auth API → API response: returns · Controller standardizes JSON output.
- Orders API → Order requests: validates · Order query and export input are validated first.
- Orders API → Order service: delegates · Order controller delegates business logic.
- Orders API → API response: returns · Controller standardizes JSON output.
- Customers API → Customer service: delegates · Customer controller delegates business logic.
- Customers API → API response: returns · Controller standardizes JSON output.
- Medications API → Medication request: validates · Medication search input is validated.
- Medications API → Medication service: delegates · Medication controller delegates business logic.
- Medications API → API response: returns · Controller standardizes JSON output.
- Alerts API → Alert requests: validates · Single and bulk alert input is validated.
- Alerts API → Alert service: delegates · Alert controller delegates notification workflows.
- Alerts API → API response: returns · Controller standardizes JSON output.
- Orders API → Role guard: guards · Privileged order exports and related actions are role protected.
- Alerts API → Role guard: guards · Alert dispatch is role protected.
- Auth service → User repo: uses · Authentication depends on user lookup through repository abstractions.
- Order service → Order repo: uses · Order workflows query persistence through repositories.
- Order service → Customer repo: uses · Order search correlates customers through repositories.
- Order service → Medication repo: uses · Order search correlates medications through repositories.
- Customer service → Customer repo: uses · Customer logic uses repository access.
- Medication service → Medication repo: uses · Medication logic uses repository access.
- Alert service → Alert repo: uses · Alert records are persisted through repositories.
- Alert service → Order repo: uses · Alert workflows need order context.
- Alert service → SMS service: uses · Alert service triggers SMS delivery.
- Alert service → Alert job: dispatches · Bulk alerting is pushed to the queue.
- Repo bindings → Order repo: binds · Registers the order repository implementation.
- Repo bindings → Customer repo: binds · Registers the customer repository implementation.
- Repo bindings → Medication repo: binds · Registers the medication repository implementation.
- Repo bindings → Alert repo: binds · Registers the alert repository implementation.
- Repo bindings → User repo: binds · Registers the user repository implementation.