Developer Documentation

Advanced Developer Guide

Complete internal architecture, logic, and engineering details of the RDA system.

System Architecture

  • Laravel 10 MVC Architecture
  • Service Layer Pattern
  • Repository Pattern (Partial Implementation)
  • Blade + Livewire UI Rendering
app/ ├── Http/Controllers ├── Models ├── Services ├── Repositories ├── Classes (Helpers)

Core Workflow Logic

Application Submitted ↓ Incoming Dak ↓ Forward to Officer ↓ Nothi Processing ↓ Notes + Attachments ↓ Approval Chain ↓ Letter Draft ↓ Final Approved
  • Dynamic forwarding chain
  • Multi-cycle approval application
  • Signature rendering logic

Packages Used

Laravel Sanctum

Authentication system

Docs →

Livewire

Reactive UI components

Docs →

Laratrust

Roles & Permissions

Docs →

MPDF

PDF generation

Docs →

QR Code

Certificate verification

Docs →

Route Structure & System Endpoints

The system primarily uses Laravel Web Routes with middleware protection. It includes payment gateways, internal modules, and authenticated operations.

Payment Gateway Routes

Method Endpoint Description
GET /payment/initiate/temp/{id} Initiate payment session
POST /payment/success Payment success callback
POST /payment/fail Payment failure callback
POST /payment/cancel Payment cancel callback

Betterment & Bank Payment

Method Endpoint Description
POST /betterment/online/{application}/{letter} Initiate online betterment payment
POST /betterment/bank/invoice/{letter} Generate bank invoice
GET /betterment/bank/invoice/pdf/{payment} Download invoice PDF

Authenticated Core System Routes

  • All core operations are protected via auth:sanctum middleware
  • Additional role-based middleware (Laratrust)
  • Activity tracking middleware enabled
Route::middleware(['auth:sanctum', 'track.activity'])->group(function () { Route::prefix('noc-applications')->group(function () { Route::get('/', 'index'); Route::post('/', 'store'); Route::get('/{id}', 'show'); Route::put('/{id}', 'update'); Route::delete('/{id}', 'destroy'); }); });

NOC Approval Workflow Routes

Method Endpoint Description
POST /noc-approval/{id}/approve Approve application
POST /noc-approval/forward/{id} Forward to next officer
POST /noc-approval/submit-note Add note to workflow

Reporting System Routes

Endpoint Description
/report/noc-details NOC approval report
/report/payment-details Payment report
/report/monthly Monthly analytics report

Database Design Overview

Table Description
noc_applications Main application data
noc_approvals Approval workflow tracking
noc_letters Letter tracking
noc_application_archives Archive file management
nothi_nisponnos After approval
plot_applications Plot management
meetings mMeetings system
Payments Payment data
Report Report Details

Internal Modules (Livewire Based)

  • Market Management Module
  • Residential Plot Module
  • Store & Payment Module
  • Report Dashboard Module
Route::get('/market/store', StoreModule::class); Route::get('/report/payment', ReportModule::class);

⚠️ Note: This system is not a pure REST API system. It combines Web Routes, Livewire components, and controller-based logic to handle a complex government workflow system.

Role-Based Access Control (RBAC)

  • Super Admin → Full access
  • Admin → Manage reports & applications
  • Officer → Approval workflow
  • User → Apply & track
if(auth()->user()->hasPermission('approve.noc')){ // Allow approval }

File & Document Handling

  • Stored in storage/app/public
  • Only PDF allowed
  • UUID-based naming
  • Protected access
$fileName = Str::uuid() . '.pdf'; $request->file('doc')->storeAs('noc', $fileName, 'public');

Notification & Event System

  • SMS Notification
  • Email Alerts
  • Event Driven Architecture

Performance Optimization

  • Eager Loading
  • Indexing
  • Cache System
  • Chunk Processing
php artisan optimize:clear

Audit Log System (Tracking & Compliance)

Every action in the system is traceable for accountability.

  • User activity tracking
  • Status change history
  • Approval logs
Log::info('Application Approved', [ 'user_id' => auth()->id(), 'application_id' => $id ]);

Error Handling & Exception Strategy

  • Global Exception Handler
  • Try-Catch Critical Operations
  • Custom Error Messages
try { DB::beginTransaction(); } catch (\Exception $e) { DB::rollBack(); Log::error($e->getMessage()); }

Modular & Scalable Architecture

The system is designed to be scalable and modular for future expansion.

  • Service Layer Separation
  • Reusable Components
  • Future Microservice Ready
app/ ├── Modules/ │ ├── NOC/ │ ├── Payment/ │ ├── Report/

Security Implementation

  • CSRF Protection
  • Validation Layer
  • Database indexing
  • Log system include
  • Role Permission Control
  • Lazy loading relationships
  • Chunk processing for reports
  • Secure File Upload (PDF only)

Automation Features

  • SMS Notification System
  • Email Alerts
  • Status Tracking Engine
  • Auto Fee Calculation

Example Logic (Forwarding)

if ($request->forward_to) { Approval::create([ 'from_user_id' => auth()->id(), 'to_user_id' => $request->forward_to, 'status' => 'pending' ]); }

Database Transactions & Data Consistency

To maintain data integrity across complex operations like approval workflows, payment verification, and multi-step processing, the system uses database transactions.

  • Atomic operations for critical actions
  • Rollback on failure
  • Prevents partial data corruption
  • Ensures consistency across multiple tables
DB::beginTransaction(); try { $application->update(['status' => 'approved']); Approval::create([ 'application_id' => $application->id, 'status' => 'approved' ]); DB::commit(); } catch (\Exception $e) { DB::rollBack(); Log::error($e->getMessage()); }

This approach is critical when handling financial transactions or multi-user approval chains.

System Deployment & Environment Setup

The system is designed for flexible deployment across local, staging, and production environments.

  • Environment-based configuration (.env)
  • Separate database for production
  • Secure APP_KEY & credentials
  • Optimized deployment commands
php artisan migrate --force php artisan config:cache php artisan route:cache php artisan view:cache

Recommended production stack: Nginx + PHP-FPM + MySQL + Redis

Ensure proper permissions: storage/ and bootstrap/cache must be writable.