Skip to main content

Overview

Flux CRM follows a standard Laravel application structure with additional features such as scheduled tasks (commands), reusable traits, and a hybrid frontend setup that uses both Blade templates and Vue.js components as part of an ongoing migration.

Folder Structure

/project-root

├── /app
│ ├── /Console
│ │ └── Commands
│ ├── /Http
│ │ ├── Controllers
│ │ ├── Middleware
│ │ ├── Resources
│ ├── /Models
│ ├── /Jobs
│ ├── /Services
│ ├── /Traits
│ ├── /Imports
│ ├── /Exports
│ ├── /Rules
│ └── /Providers

├── /config

├── /database
│ ├── /factories
│ ├── /migrations
│ └── /seeders

├── /public
│ ├── /build
│ └── /assets

├── /resources
│ ├── /fonts
│ ├── /js
│ ├── /json
│ ├── /lang
│ ├── /css
│ ├── /scss
│ ├── /views
│ └── /vue

├── /routes
│ ├── api.php
│ └── web.php

├── /tests

├── /vendor

└── /node_modules

Key Directories and Files

/app

The app folder contains the core business logic of the application, including controllers, models, middleware, and services.

  • Controllers: Located in app/Http/Controllers, controllers handle incoming requests and return appropriate responses.
  • Models: Found in app/Models, models represent various entities in the system such as Customer, Product, or Employee and interact with the database.
  • Services: The app/Services directory contains classes that encapsulate complex business logic or external service integrations.
  • Traits: app/Traits contains reusable PHP traits that provide shared functionality across various models and controllers.
  • Console Commands: Custom Laravel commands for scheduled tasks are defined in app/Console/Commands.

/config

The config folder contains configuration files for the application. These files define important settings such as database connections, mail drivers, and other services.

/database

  • Migrations: Define the structure of the database tables and handle schema changes.
  • Seeders: Used to populate the database with initial or test data.
  • Factories: Define model templates for generating test data.

/public

The public folder contains static assets, including the entire build of the application, as well as resources like images and styles. It is also the directory served by the web server in a production environment.

/resources

This folder contains the frontend files:

  • JavaScript: resources/js holds Vue.js components and the JavaScript logic for the frontend.
  • Blade Views: Stored in resources/views, these are Laravel’s Blade templates. However, the system is migrating these to Vue.js components.
  • Sass: All SCSS files for styling are stored in resources/scss.
  • Language Files: This folder also holds localization files (resources/lang) for multi-language support in the Laravel backend. Separate Vue.js $i18n language files are maintained within the JavaScript resources.

/routes

  • web.php: Contains routes for web-based requests, handling frontend routes via Laravel and Vue.js.
  • api.php: Contains routes that handle API calls, including most POST, DELETE, and some GET requests that interact with the backend without direct user interface involvement.

/tests

Currently, no tests have been implemented for the Flux CRM system. However, unit tests and feature tests may be added in a future update to verify the functionality of models, controllers, and services.

Code Flow

  1. Routing: Requests are routed via web.php for frontend interactions or api.php for backend API calls.
  2. Controller: Once routed, the request is processed by a controller in app/Http/Controllers.
  3. Model/Database Interaction: Controllers may interact with models in app/Models to query or update the database.
  4. View Rendering: The response can either be a Blade view (from resources/views) or a Vue.js component, depending on the setup.

Frontend Structure

  • Blade to Vue.js Migration: The frontend structure is transitioning from Laravel Blade templates to a fully component-based Vue.js setup. Currently, the frontend is a mix of both technologies, with Vue.js handling most dynamic content.
  • Vue.js Router: Frontend routes are managed through Vue.js components, but initially routed via Laravel’s web.php.
  • SCSS: Styles are written in Sass and compiled from .scss files in the resources/scss folder.

Scheduled Tasks

Custom scheduled tasks are defined in app/Console/Commands and are run via Laravel's scheduling feature (schedule:run). These tasks automate repetitive processes such as reporting, data synchronization, or sending notifications.

Traits

Reusable traits are defined in app/Traits and are used across multiple models and controllers to avoid code duplication. These might include shared functionality for logging, data validation, or access control.