Developer Guide

This guide is intended for developers working with Securaine, a secure, extensible contact form application built for modern, production-level deployments.


πŸ“ Project Structure


Securaine/
β”œβ”€β”€ app/
β”‚   β”œβ”€β”€ Controllers/      # HTTP and API logic
β”‚   β”œβ”€β”€ Models/           # Data models
β”‚   β”œβ”€β”€ Services/         # Reusable business logic and external integrations
β”‚   β”œβ”€β”€ bootstrap.php     # Bootstrap and app initialization
β”‚   └── config.php        # Centralized configuration
β”‚
β”œβ”€β”€ lang/                 # JSON language files
β”œβ”€β”€ public/               # Public-facing assets (CSS, JS, images)
β”œβ”€β”€ routes/               # Application routing
β”œβ”€β”€ storage/              # Secure files, metadata, caching, and logs
β”œβ”€β”€ vendor/               # Composer dependencies
β”œβ”€β”€ views/
β”‚   β”œβ”€β”€ email/            # Email templates
β”‚   β”œβ”€β”€ layouts/          # Shared Blade layouts
β”‚   └── form.blade.php    # Form rendering template
β”‚
β”œβ”€β”€ .env.example          # Environment variable template
β”œβ”€β”€ .htaccess.example     # Apache rewrite rules template
└── index.php             # Entry point

🧱 Architecture Overview


βš™οΈ Configuration System

All UI and backend behavior is configured via:


/app/config.php

Example settings:

return [
  'form' => [
    'fields' => [
      'name' => ['enabled' => true, 'required' => true],
      'email' => ['enabled' => true, 'required' => true],
      'message' => ['enabled' => true, 'required' => true],
      'attachment' => ['enabled' => true, 'required' => false],
      'captcha' => ['enabled' => true],
    ],
  ],
];

Storage Configuration

File storage is controlled through the storage configuration:

'storage' => [
  'enabled' => true,
  'type' => 'local', // local or s3
],

Supported storage backends:

Files are stored privately and are not exposed through public URLs.

Attachment Delivery Mode

Attachment delivery behavior is controlled through:

'mode' => $_ENV['ATTACHMENT_DELIVERY_MODE'] ?? 'attachment',

Available modes:

attachment
link

πŸ” Security Architecture

1. CSRF Protection


2. CAPTCHA System

Implemented via App\Services\CaptchaService:

{!! $captcha !!}

3. Input Validation

Handled in the App\Services\FormValidationService:


4. Secure File Uploads

Supported storage:

Attachment workflows:

Direct Attachment

attachment
link

πŸ–ΌοΈ Blade Templating

Blade-style templates are used with custom PHP rendering methods.

Main view file:

/views/form.blade.php

πŸ€– AI-Powered Message Generator

Intelligent message drafting with OpenAI integration.

How it works:

Highlights:

To enable:


🌍 Internationalization (i18n)

Language files are JSON-based:

/lang/en.json
/lang/es.json

To add a language:

  1. Copy an existing .json file.

  2. Translate all keys.

  3. Ensure the filename (for example fr.json) matches the language code.

  4. The UI automatically detects available languages.

Add the corresponding language-specific pattern to the form rendering template.

const languagePatterns = {
  fr: {
    subjectLabels: ['sujet'],
    namePlaceholders: ['votre nom']
  },
},

Language switcher types:


πŸ“„ Email Templates

HTML templates are stored in:

/views/email/

Customize the email layout, subject, or message body as needed.

Attachment rendering depends on the configured delivery mode:

Attachment Mode


πŸ“¨ Submission Logic

Located in:

app/Controllers/MailController.php

Responsibilities include:


πŸ§ͺ Testing & Debugging

Enable debug mode in .env:

LOG_LEVEL=DEBUG

Logs are written to:

/storage/logs/

Frontend uses Bootstrap toasts and inline validation for user feedback.


⚑ Scripts & Assets

Frontend JavaScript:

/public/assets/js/contact(.min).js

Frontend Styles:

/public/assets/css/

🧩 Extending the Form

To add a new field:

  1. Update config.php['form']['fields'] to enable the field.

  2. Add form input logic to form.blade.php.

  3. Add language keys to lang/*.json.

  4. Add validation logic to the controller.

  5. Optionally add email template support.


🧼 Deployment Notes


πŸ›  Maintenance Tips

Task

How

Add new field

Edit config.php + form.blade.php

Add new language

Add lang/xx.json

Change theme

Edit CSS and style['mode'] or lang in config

Modify email format

Edit views/email/*.blade.php

Reset logs

Delete files in storage/logs/

Update CAPTCHA keys

Edit .env

Change file storage

Edit storage configuration

Change attachment behavior

Edit attachment_delivery.mode


🀝 Contributing

If you are working as a certified vendor or contractor, follow these standards: