Compare commits
10
Commits
c83aa465ad
...
bb97be7727
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bb97be7727 | ||
|
|
293defb15b | ||
|
|
3355ac57bb | ||
|
|
b4ed12e878 | ||
|
|
7e3b6e2380 | ||
|
|
d5c39a2bd7 | ||
|
|
6fdf4b63b9 | ||
|
|
29c06b56dd | ||
|
|
fee88383da | ||
|
|
1dc1b62d01 |
No files matched your search
@@ -0,0 +1,31 @@
|
||||
.git
|
||||
.gitattributes
|
||||
.gitignore
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
.agents
|
||||
.codex
|
||||
.cursor
|
||||
.idea
|
||||
.junie
|
||||
.nova
|
||||
.vscode
|
||||
.zed
|
||||
AGENTS.md
|
||||
README.md
|
||||
docs
|
||||
node_modules
|
||||
vendor
|
||||
public/build
|
||||
public/hot
|
||||
storage/logs/*
|
||||
storage/framework/cache/data/*
|
||||
storage/framework/sessions/*
|
||||
storage/framework/testing/*
|
||||
storage/framework/views/*
|
||||
tests
|
||||
phpunit.xml
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
+12
-13
@@ -1,8 +1,8 @@
|
||||
APP_NAME=Laravel
|
||||
APP_ENV=local
|
||||
APP_NAME=BankFlow
|
||||
APP_ENV=production
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost
|
||||
APP_DEBUG=false
|
||||
APP_URL=http://127.0.0.1:8080
|
||||
|
||||
APP_LOCALE=en
|
||||
APP_FALLBACK_LOCALE=en
|
||||
@@ -15,17 +15,17 @@ APP_MAINTENANCE_DRIVER=file
|
||||
|
||||
BCRYPT_ROUNDS=12
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_CHANNEL=stderr
|
||||
LOG_STACK=single
|
||||
LOG_DEPRECATIONS_CHANNEL=null
|
||||
LOG_LEVEL=debug
|
||||
LOG_LEVEL=info
|
||||
|
||||
DB_CONNECTION=sqlite
|
||||
# DB_HOST=127.0.0.1
|
||||
# DB_PORT=3306
|
||||
# DB_DATABASE=laravel
|
||||
# DB_USERNAME=root
|
||||
# DB_PASSWORD=
|
||||
DB_CONNECTION=pgsql
|
||||
DB_HOST=postgres
|
||||
DB_PORT=5432
|
||||
DB_DATABASE=bankflow
|
||||
DB_USERNAME=bankflow
|
||||
DB_PASSWORD=
|
||||
|
||||
SESSION_DRIVER=database
|
||||
SESSION_LIFETIME=120
|
||||
@@ -64,4 +64,3 @@ AWS_USE_PATH_STYLE_ENDPOINT=false
|
||||
|
||||
VITE_APP_NAME="${APP_NAME}"
|
||||
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
# طراحی BankFlow
|
||||
|
||||
[English](DESIGN.md) | [فارسی](DESIGN.fa.md)
|
||||
|
||||
## معماری
|
||||
|
||||
BankFlow از معماری لایهای Laravel با تمرکز بر دامنه تسهیلات استفاده میکند:
|
||||
|
||||
```text
|
||||
HTTP Request
|
||||
-> Form Request / Filament Page
|
||||
-> Action تکمنظوره
|
||||
-> WorkflowEngine یا Eloquent Query
|
||||
-> PostgreSQL
|
||||
```
|
||||
|
||||
لایه HTTP مسئول ملاحظات Transport و JSON Resourceها است. Actionها Use Caseها و مرز Transactionها را نمایش میدهند. مسیر `app/Domain/Loan` شامل مقادیر دامنه و رفتار Workflow با کمترین وابستگی به Framework است. مدلهای Eloquent مسئول Relationshipها و ماندگاری هستند، اما پردازش را هماهنگ نمیکنند.
|
||||
|
||||
API عمومی زیر مسیر `/api/v1` نسخهبندی شده است. Filament رابط مدیریتی احرازهویتشده را برای مشاهده تسهیلات، انواع تسهیلات، تعریف Stageها و نسخههای Workflow فراهم میکند.
|
||||
|
||||
## مدل و اجرای Workflow
|
||||
|
||||
هر `LoanType` چند نسخه `WorkflowConfiguration` دارد. هر پیکربندی شامل ردیفهای مرتب `WorkflowConfigurationStep` است و هر Step به یک `StageDefinition` و یک شیء JSON حاوی قوانین اشاره میکند. فقط Workflow با وضعیت `PUBLISHED` به درخواست جدید اختصاص مییابد. شناسه همان پیکربندی در Loan نگهداری میشود؛ بنابراین تغییرات مدیریتی بعدی نمیتوانند تصمیم در حال اجرا یا تاریخی را تغییر دهند.
|
||||
|
||||
فایل `config/workflow-stages.php` Registry امن پیادهسازی است. این فایل کد پایدار هر Stage را به یک کلاس PHP پیادهساز `StageInterface` نگاشت میکند؛ مقادیر پایگاه داده هرگز کلاس دلخواه یا عبارت اجرایی را انتخاب نمیکنند. Handlerهای Stage بدون State هستند و یک `ExecutionResult` تغییرناپذیر شامل `PASS`، `FAIL` یا `MANUAL_REVIEW` و کد دلیل برمیگردانند.
|
||||
|
||||
پردازش بهصورت همزمان انجام میشود:
|
||||
|
||||
1. `ProcessLoanAction` یک Transaction پایگاه داده باز و ردیف Loan را قفل میکند.
|
||||
2. Loan دارای وضعیت نهایی بدون اجرای دوباره بازگردانده میشود.
|
||||
3. `WorkflowEngine` مراحل فعال را بر اساس `position` میخواند.
|
||||
4. مراحلی که قبلاً در تاریخچه ثبت شدهاند نادیده گرفته میشوند.
|
||||
5. Handler مشروط میتواند اعلام کند که قابل اجرا نیست؛ برای Stage ردشده تاریخچهای ایجاد نمیشود.
|
||||
6. Handler با قوانین اعتبارسنجیشده Step اجرا میشود.
|
||||
7. یک ردیف تاریخچه شامل Stage، نتیجه، دلیل، زمان اجرا و Snapshot قوانین ذخیره میشود.
|
||||
8. نتیجه `FAIL` وضعیت `REJECTED` و نتیجه `MANUAL_REVIEW` وضعیت `MANUAL_REVIEW` را ایجاد میکند؛ در غیر این صورت Step مرتب بعدی انتخاب میشود.
|
||||
9. عبور موفق از تمام مراحل قابل اجرا، وضعیت `APPROVED` را ایجاد میکند.
|
||||
|
||||
بنابراین Stage فعلی در یک Switch مربوط به Transitionها Hard-code نشده است؛ بلکه اولین Step فعال، قابل اجرا و اجرانشده در نسخه مرتب Workflow مربوط به Loan است.
|
||||
|
||||
## قوانین و چرخه عمر پیکربندی
|
||||
|
||||
آستانهها و Prefixهای کسبوکار در ستون JSON با نام `rules` برای هر Step قرار دارند. Workflowهای Seedشده، مقادیر پیشفرض چالش را تأمین میکنند. اعتبارسنجی اختصاصی هر Stage هنگام ایجاد یا ویرایش Draft توسط مدیر و بار دیگر پیش از انتشار اجرا میشود. Registry امن یک فایل پیکربندی PHP باقی میماند، زیرا Handlerهای اجرایی بخشی از کد برنامه هستند؛ در مقابل، مقادیر کسبوکار و ترتیب مراحل بهصورت دادههای نسخهبندیشده در پایگاه داده قرار دارند.
|
||||
|
||||
نسخههای Workflow چرخه `DRAFT -> PUBLISHED -> ARCHIVED` را طی میکنند. Draft قابل ویرایش است. انتشار، کل Workflow را اعتبارسنجی و نسخه منتشرشده قبلی همان نوع تسهیلات را بهصورت اتمیک Archive میکند. نسخههای Published و Archived تغییرناپذیر هستند.
|
||||
|
||||
## ماندگاری، وضعیت و تاریخچه ممیزی
|
||||
|
||||
Eloquent انواع تسهیلات، تعریف Stageها، نسخهها و مراحل Workflow، درخواستهای تسهیلات و تاریخچهها را ذخیره میکند. Backed Enumها سه مفهوم را از هم جدا میکنند:
|
||||
|
||||
- وضعیت Loan: `SUBMITTED`، `IN_PROGRESS`، `MANUAL_REVIEW`، `APPROVED` و `REJECTED`؛
|
||||
- Stage قابل اجرا: `VALIDATION`، `FRAUD_CHECK`، `GUARANTOR_CHECK`، `CREDIT_CHECK` و `MANAGER_APPROVAL`؛
|
||||
- نتیجه Stage: `PASS`، `FAIL` و `MANUAL_REVIEW`.
|
||||
|
||||
فیلد `loans.current_workflow_configuration_step_id` پیشرفت فعلی را نشان میدهد و `loan_histories` تاریخچه پایدار کسبوکار است. Snapshot قوانین در تاریخچه، ورودی دقیق هر تصمیم را حتی در صورت استفاده Workflowهای آینده از قوانین متفاوت حفظ میکند. Exceptionهای پیشبینینشده با Logging استاندارد Laravel ثبت میشوند و Transaction پردازش را Rollback میکنند.
|
||||
|
||||
درخواستهای دارای وضعیت بررسی دستی میتوانند بعداً در Filament توسط مدیر مجاز تأیید شوند. این عملیات Loan را قفل و مدیر تأییدکننده، زمان و یادداشت را ثبت میکند.
|
||||
|
||||
## جلوگیری از پردازش تکراری و همزمان
|
||||
|
||||
Idempotency در چند سطح اعمال میشود:
|
||||
|
||||
- وضعیت نهایی باعث بازگشت فوری و بدون عملیات میشود؛
|
||||
- شناسه Stepهای اجراشده از تاریخچه استخراج میشود و دوباره اجرا نمیشوند؛
|
||||
- Unique Constraint روی `(loan_id, workflow_configuration_step_id)` از ایجاد تاریخچه تکراری جلوگیری میکند؛
|
||||
- `SELECT ... FOR UPDATE` پردازشهای همزمان یک Loan را سریالی میکند؛
|
||||
- اجرای کامل Workflow و همه تاریخچهها در یک Transaction با حداکثر سه بار تلاش مجدد قرار دارند.
|
||||
|
||||
Constraintهای پایگاه داده نیز سازگاری نوع تسهیلات، Workflow و Step فعلی Loan را حفظ میکنند. PostgreSQL با یک Partial Unique Index اجازه میدهد برای هر نوع تسهیلات فقط یک Workflow منتشرشده وجود داشته باشد.
|
||||
|
||||
## افزودن `AML_CHECK`
|
||||
|
||||
افزودن یک Stage به تغییرات زیر نیاز دارد:
|
||||
|
||||
1. افزودن `AmlCheck` به `LoanStage`؛
|
||||
2. پیادهسازی `StageInterface` و در صورت قابل ردشدن بودن، `ConditionalStageInterface`؛
|
||||
3. ثبت `AML_CHECK` در `config/workflow-stages.php`؛
|
||||
4. تعریف و اعتبارسنجی Schema قوانین آن در `ValidateWorkflowStepDataAction`؛
|
||||
5. ایجاد یا Seed کردن `StageDefinition` و افزودن آن به یک نسخه Draft جدید؛
|
||||
6. افزودن Unit Test برای Stage و Feature Test برای ترتیب، نتایج، تاریخچه و Idempotency.
|
||||
|
||||
Engine و کلاسهای Stage موجود تغییر نمیکنند. انتشار نسخه جدید فقط بر Loanهایی اثر میگذارد که پس از آن ساخته شوند.
|
||||
|
||||
## Trade-offهای اصلی
|
||||
|
||||
اجرای همزمان در محدوده یک Transaction، استدلال درباره صحت و رفتار API را ساده میکند؛ اما بررسیهای خارجی طولانی، Request و قفل پایگاه داده را برای مدت زیادی نگه میدارند. ترتیب Workflow مدیریتشده در پایگاه داده، مدیریت امن و بازتولید تصمیمهای تاریخی را فراهم میکند؛ در مقابل نسبت به پیکربندی ثابت به Schema و اعتبارسنجی انتشار بیشتری نیاز دارد. دسترسی مستقیم Eloquent برنامه را کوچک و منطبق با Laravel نگه میدارد، اما افزودن یک پیادهسازی ماندگاری دوم را پرهزینهتر میکند.
|
||||
@@ -0,0 +1,86 @@
|
||||
# BankFlow Design
|
||||
|
||||
[English](DESIGN.md) | [فارسی](DESIGN.fa.md)
|
||||
|
||||
## Architecture
|
||||
|
||||
BankFlow uses a layered Laravel architecture grouped around the loan domain:
|
||||
|
||||
```text
|
||||
HTTP request
|
||||
-> Form Request / Filament page
|
||||
-> single-purpose Action
|
||||
-> WorkflowEngine or Eloquent query
|
||||
-> PostgreSQL
|
||||
```
|
||||
|
||||
The HTTP layer owns transport concerns and JSON resources. Actions represent use cases and transaction boundaries. `app/Domain/Loan` contains framework-light domain values and workflow behavior. Eloquent models own relationships and persistence, but do not orchestrate processing.
|
||||
|
||||
The public API is versioned under `/api/v1`. Filament provides the authenticated administrative interface for loan inspection, loan types, stage definitions, and workflow versions.
|
||||
|
||||
## Workflow model and execution
|
||||
|
||||
A `LoanType` has multiple `WorkflowConfiguration` versions. Each configuration has ordered `WorkflowConfigurationStep` rows, and each step points to a `StageDefinition` plus a JSON rules object. Only a `PUBLISHED` workflow is assigned to a new loan. The loan retains that configuration ID, so later administrative changes cannot alter an in-flight or historical decision.
|
||||
|
||||
`config/workflow-stages.php` is the trusted implementation registry. It maps a stable stage code to a PHP class implementing `StageInterface`; database values never select arbitrary classes or executable expressions. Stage handlers are stateless and return an immutable `ExecutionResult` containing `PASS`, `FAIL`, or `MANUAL_REVIEW` and a reason code.
|
||||
|
||||
Processing is synchronous:
|
||||
|
||||
1. `ProcessLoanAction` opens a database transaction and locks the loan row.
|
||||
2. A terminal loan is returned without further work.
|
||||
3. `WorkflowEngine` reads enabled steps in `position` order.
|
||||
4. Steps already present in loan history are skipped.
|
||||
5. A conditional handler may declare that it does not apply; skipped stages create no history.
|
||||
6. The handler executes with the step's validated rules.
|
||||
7. A history row stores the stage, result, reason, execution time, and rules snapshot.
|
||||
8. `FAIL` produces `REJECTED`; `MANUAL_REVIEW` produces `MANUAL_REVIEW`; otherwise the next ordered step is selected.
|
||||
9. Passing all applicable steps produces `APPROVED`.
|
||||
|
||||
The current stage is therefore not hard-coded in a transition switch. It is the first enabled, applicable, unexecuted step in the loan's ordered workflow version.
|
||||
|
||||
## Rules and configuration lifecycle
|
||||
|
||||
Business thresholds and prefixes live in the `rules` JSON column on each configured step. Seeded workflows provide the challenge defaults. Stage-specific validation runs when an administrator creates or updates a draft and again before publication. The trusted registry remains a PHP configuration file because executable handlers are application code, while business values and order remain versioned database data.
|
||||
|
||||
Workflow versions move through `DRAFT -> PUBLISHED -> ARCHIVED`. Drafts are editable. Publishing validates the entire workflow and atomically archives the previous published version for that loan type. Published and archived versions are immutable.
|
||||
|
||||
## Persistence, state, and audit history
|
||||
|
||||
Eloquent persists loan types, stage definitions, workflow versions and steps, loans, and histories. Backed enums distinguish three concepts:
|
||||
|
||||
- loan status: `SUBMITTED`, `IN_PROGRESS`, `MANUAL_REVIEW`, `APPROVED`, `REJECTED`;
|
||||
- executable stage: `VALIDATION`, `FRAUD_CHECK`, `GUARANTOR_CHECK`, `CREDIT_CHECK`, `MANAGER_APPROVAL`;
|
||||
- stage result: `PASS`, `FAIL`, `MANUAL_REVIEW`.
|
||||
|
||||
`loans.current_workflow_configuration_step_id` exposes current progress, while `loan_histories` is the durable business audit trail. The history's rule snapshot preserves the exact inputs to a decision even if a future workflow uses different rules. Unexpected exceptions use normal Laravel logging and roll back the processing transaction.
|
||||
|
||||
Manual-review loans may later be approved by an authorized manager in Filament. That operation locks the loan and records the approver, timestamp, and note.
|
||||
|
||||
## Duplicate and concurrent processing
|
||||
|
||||
Idempotency is enforced at multiple levels:
|
||||
|
||||
- terminal statuses cause an immediate no-op response;
|
||||
- executed workflow step IDs are derived from history and not run again;
|
||||
- a unique constraint on `(loan_id, workflow_configuration_step_id)` prevents duplicate history rows;
|
||||
- `SELECT ... FOR UPDATE` serializes concurrent processing of one loan;
|
||||
- the complete workflow run and all history writes share one transaction, retried up to three times.
|
||||
|
||||
Database constraints also keep a loan's type, workflow, and current step consistent. PostgreSQL adds a partial unique index allowing only one published workflow per loan type.
|
||||
|
||||
## Adding `AML_CHECK`
|
||||
|
||||
Adding a stage requires:
|
||||
|
||||
1. add `AmlCheck` to `LoanStage`;
|
||||
2. implement `StageInterface` (and `ConditionalStageInterface` if it can be skipped);
|
||||
3. register `AML_CHECK` in `config/workflow-stages.php`;
|
||||
4. define and validate its rule schema in `ValidateWorkflowStepDataAction`;
|
||||
5. create/seed its `StageDefinition` and add it to a new draft workflow version;
|
||||
6. add stage unit tests and feature tests for ordering, outcomes, history, and idempotency.
|
||||
|
||||
The engine and existing stage classes do not change. Publishing the new version affects only loans created afterward.
|
||||
|
||||
## Principal trade-offs
|
||||
|
||||
Synchronous, transaction-scoped execution makes correctness and API behavior easy to reason about, but long-running external checks would hold a request and database lock too long. Database-managed workflow order enables safe administration and historical reproducibility, at the cost of more schema and publication validation than static configuration. Direct Eloquent access keeps this application small and idiomatic, but would make a second persistence implementation more expensive.
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
ARG PHP_VERSION=8.4
|
||||
ARG NODE_VERSION=24
|
||||
|
||||
FROM php:${PHP_VERSION}-apache-bookworm AS php-base
|
||||
|
||||
ENV APACHE_DOCUMENT_ROOT=/var/www/html/public \
|
||||
APACHE_HTTP_PORT=8080
|
||||
|
||||
RUN set -eux; \
|
||||
apt-get update; \
|
||||
apt-get install -y --no-install-recommends \
|
||||
gosu \
|
||||
libicu-dev \
|
||||
libonig-dev \
|
||||
libpq-dev \
|
||||
libsqlite3-dev \
|
||||
libxml2-dev \
|
||||
libzip-dev; \
|
||||
docker-php-ext-install -j"$(nproc)" \
|
||||
dom \
|
||||
intl \
|
||||
mbstring \
|
||||
opcache \
|
||||
pdo_mysql \
|
||||
pdo_pgsql \
|
||||
pdo_sqlite \
|
||||
xmlreader \
|
||||
zip; \
|
||||
a2enmod rewrite; \
|
||||
sed -ri 's!Listen 80!Listen 8080!' /etc/apache2/ports.conf; \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
WORKDIR /var/www/html
|
||||
|
||||
FROM php-base AS composer-dependencies
|
||||
|
||||
COPY --from=composer:2 /usr/bin/composer /usr/local/bin/composer
|
||||
|
||||
COPY composer.json composer.lock ./
|
||||
|
||||
RUN composer install \
|
||||
--classmap-authoritative \
|
||||
--no-ansi \
|
||||
--no-dev \
|
||||
--no-interaction \
|
||||
--no-progress \
|
||||
--no-scripts \
|
||||
--prefer-dist
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN composer dump-autoload \
|
||||
--classmap-authoritative \
|
||||
--no-ansi \
|
||||
--no-dev \
|
||||
--no-interaction; \
|
||||
composer check-platform-reqs --no-dev
|
||||
|
||||
FROM node:${NODE_VERSION}-bookworm-slim AS frontend-assets
|
||||
|
||||
WORKDIR /var/www/html
|
||||
|
||||
COPY package.json package-lock.json .npmrc ./
|
||||
|
||||
RUN npm ci
|
||||
|
||||
COPY --from=composer-dependencies /var/www/html/vendor ./vendor
|
||||
COPY app ./app
|
||||
COPY public ./public
|
||||
COPY resources ./resources
|
||||
COPY vite.config.js ./
|
||||
|
||||
RUN npm run build
|
||||
|
||||
FROM php-base AS runtime
|
||||
|
||||
ENV APP_ENV=production \
|
||||
APP_DEBUG=false \
|
||||
APP_URL=http://localhost:8080 \
|
||||
LOG_CHANNEL=stderr \
|
||||
LOG_LEVEL=info \
|
||||
SESSION_DRIVER=database \
|
||||
CACHE_STORE=database \
|
||||
QUEUE_CONNECTION=database
|
||||
|
||||
COPY apache-vhost.conf /etc/apache2/sites-available/000-default.conf
|
||||
COPY --from=composer-dependencies /var/www/html /var/www/html
|
||||
COPY --from=frontend-assets /var/www/html/public/build /var/www/html/public/build
|
||||
COPY docker-entrypoint.sh /usr/local/bin/bankflow-entrypoint
|
||||
|
||||
RUN set -eux; \
|
||||
cp "$PHP_INI_DIR/php.ini-production" "$PHP_INI_DIR/php.ini"; \
|
||||
chmod +x /usr/local/bin/bankflow-entrypoint; \
|
||||
touch database/database.sqlite; \
|
||||
chown www-data:www-data database database/database.sqlite; \
|
||||
chown -R www-data:www-data storage bootstrap/cache; \
|
||||
chmod -R ug+rwX storage bootstrap/cache
|
||||
|
||||
EXPOSE 8080
|
||||
|
||||
HEALTHCHECK --interval=30s --timeout=5s --start-period=30s --retries=3 \
|
||||
CMD php -r 'exit(@file_get_contents("http://127.0.0.1:8080/health") === false ? 1 : 0);'
|
||||
|
||||
ENTRYPOINT ["bankflow-entrypoint"]
|
||||
|
||||
CMD ["apache2-foreground"]
|
||||
@@ -0,0 +1,59 @@
|
||||
# تصمیمهای مهندسی BankFlow
|
||||
|
||||
[English](ENGINEERING_DECISIONS.md) | [فارسی](ENGINEERING_DECISIONS.fa.md)
|
||||
|
||||
## ۱. معماری لایهای Laravel
|
||||
|
||||
**گزینههای بررسیشده:** Controllerهای دارای منطق داخلی، Laravel لایهای با Actionها، یا معماری کامل Clean/Hexagonal با Repository و Port.
|
||||
|
||||
**تصمیم:** استفاده از Controllerهای کمحجم، Actionهای تکمنظوره، ماژول دامنه تسهیلات و مدلهای Eloquent. این ساختار Use Caseها و مرز Transactionها را بدون افزودن Abstractionهای غیرضروری صریح نگه میدارد. برای توسعهدهندگان Laravel آشنا و بهسادگی قابل تست است. محدودیت آن، وابستگی بیشتر به Laravel و Eloquent در مقایسه با معماری Ports and Adapters است.
|
||||
|
||||
## ۲. Pipeline مرتب Stageها بهجای انشعاب Hard-codeشده
|
||||
|
||||
**گزینههای بررسیشده:** شرطهای تو در تو در یک Service، Rule Engine عمومی، یا Handlerهای مرتب و بدون State.
|
||||
|
||||
**تصمیم:** مدلسازی Workflow بهصورت Stepهای مرتب و نسخهبندیشده پایگاه داده که از طریق Registry امن PHP Resolve میشوند. هر Handler نتیجهای Type-safe برمیگرداند و Engine مسئول حرکت بین مراحل است. افزودن Stage موجب تغییر Enum، Handler، Registry، اعتبارسنجی قوانین، تعریف Stage یا نسخه Workflow و تستها میشود؛ Engine و Handlerهای موجود بدون تغییر باقی میمانند.
|
||||
|
||||
این طراحی بدون پذیرش ورودی اجرایی مدیر، توسعهپذیر و قابل ممیزی است. در مقایسه با Graph یا زبان قوانین عمومی انعطاف کمتری دارد: Engine فعلی یک Pipeline خطی و مرتب با Skip مشروط و نتایج نهایی را پشتیبانی میکند، نه Branch یا Cycle دلخواه.
|
||||
|
||||
## ۳. مالکیت قوانین توسط پایگاه داده و مالکیت Handlerها توسط کد
|
||||
|
||||
**گزینههای بررسیشده:** همه قوانین در فایلهای پیکربندی PHP، همه رفتار در پایگاه داده، یا رویکرد ترکیبی.
|
||||
|
||||
**تصمیم:** ترتیب Workflow و مقادیر کسبوکار بهشکل JSON اعتبارسنجیشده در Stepهای نسخهبندیشده پایگاه داده ذخیره میشوند و `config/workflow-stages.php` کدهای امن را به کلاسهای پیادهسازی نگاشت میکند. مدیران میتوانند آستانهها و ترتیب را بدون Deploy کد تغییر دهند، اما امکان تزریق PHP، SQL یا Expression ندارند.
|
||||
|
||||
مزیت این روش، انعطاف عملیاتی همراه با مرز امنیتی کنترلشده است. هزینه آن، نگهداری اعتبارسنجی اختصاصی هر Stage و چرخه انتشار مدیریتی است. با اینکه متن چالش خواندن قوانین از Configuration را مطرح میکند، پایگاه داده عمداً منبع نسخهبندیشده پیکربندی کسبوکار است و فایل پیکربندی PHP فقط Handlerهای امن را ثبت میکند.
|
||||
|
||||
## ۴. تخصیص Workflow تغییرناپذیر و تاریخچه پایدار
|
||||
|
||||
**گزینههای بررسیشده:** Resolve کردن همیشگی آخرین Workflow، کپی کامل اطلاعات Workflow روی هر Loan، یا ارجاع به یک پیکربندی نسخهبندیشده.
|
||||
|
||||
**تصمیم:** هنگام ایجاد Loan، مقدار `workflow_configuration_id` مربوط به نسخه منتشرشده فعلی به آن اختصاص مییابد. نسخه منتشرشده تغییرناپذیر است و هر رکورد تاریخچه، Step اجراشده و Snapshot قوانین را نگه میدارد. این کار تصمیمهای قدیمی را بدون تکرار کل پیکربندی برای هر Loan قابل بازتولید میکند. در مقابل، نسخههای دارای ارجاع باید حفظ شوند و حذف مخرب آنها مجاز نیست.
|
||||
|
||||
## ۵. پردازش همزمان و اتمیک
|
||||
|
||||
**گزینههای بررسیشده:** یک Request همزمان، یک Job صف برای هر Stage، یا هماهنگسازی Event-driven.
|
||||
|
||||
**تصمیم:** همه مراحل باقیمانده در یک Request و یک Transaction پایگاه داده پردازش میشوند. API بلافاصله وضعیت نهایی پردازش خودکار را برمیگرداند و خطا نمیتواند State ناقص باقی بگذارد. قفل ردیف، بررسی وضعیت نهایی، جستوجوی تاریخچه و Unique Constraint تاریخچه از اجرای تکراری یا همزمان جلوگیری میکنند.
|
||||
|
||||
این راهکار سادهترین انتخاب قابل اتکا برای بررسیهای سریع و Mockشده است. محدودیت اصلی آن مدت Transaction است: Integration واقعی اعتبار، تقلب یا AML ممکن است کند یا خارج از دسترس باشد. در آینده چنین Stageهایی باید به یک State Machine قابل ادامه روی Queue، همراه با Transactionهای کوتاه، سیاست Retry صریح، Timeout و Idempotency Key منتقل شوند.
|
||||
|
||||
## ۶. Eloquent و PostgreSQL
|
||||
|
||||
**گزینههای بررسیشده:** ذخیرهسازی درون حافظه، Abstraction مبتنی بر Repository، یا ماندگاری مستقیم Eloquent روی پایگاه داده رابطهای.
|
||||
|
||||
**تصمیم:** استفاده از Eloquent و PostgreSQL در محیط تولید Compose. Foreign Keyهای رابطهای، Composite Constraintها، قفل ردیف، ذخیره قوانین JSON و Partial Unique Index سازگاری و ماندگاری پس از Restart را فراهم میکنند. SQLite برای تستها و Image مستقل چالش باقی میماند.
|
||||
|
||||
مزیت، ماندگاری قوی با زیرساخت سفارشی اندک است. Trade-off این است که برخی تضمینهای تولید، بهویژه Partial Unique Index و رفتارهای Concurrency، مخصوص PostgreSQL هستند و تستهای SQLite آنها را بهطور کامل پوشش نمیدهند.
|
||||
|
||||
## سه Trade-off تعیینکننده
|
||||
|
||||
1. **سادگی در برابر Throughput:** پردازش همزمان شفاف و اتمیک است، اما برای وابستگی خارجی کند مناسب نیست.
|
||||
2. **پیکربندیپذیری در برابر سادگی Schema:** جدولهای Workflow نسخهبندیشده تغییرات امن و ممیزی را ممکن میکنند، اما به اعتبارسنجی و مدیریت چرخه عمر نیاز دارند.
|
||||
3. **Convention فریمورک در برابر قابلیت انتقال:** Actionها و Eloquent Boilerplate را کاهش میدهند، اما عمداً استقلال از پیادهسازی ماندگاری را کنار میگذارند.
|
||||
|
||||
## محدودیتها و بهبودهای بعدی
|
||||
|
||||
بزرگترین محدودیت معماری، Workflow خطی و همزمان است. با یک هفته زمان بیشتر، اولویتها شامل تست Concurrency روی PostgreSQL، تست تزریق خطا و Rollback، احراز هویت و Rate Limiting برای API، نقشهای Authorization غنیتر، تولید OpenAPI، مشاهدهپذیری Latency و خطای Stageها و طراحی Queue قابل ادامه برای بررسیهای خارجی واقعی خواهد بود.
|
||||
|
||||
با این حال، معماری فعلی از رشد آینده پشتیبانی میکند: قرارداد پایدار Stageها بررسیهای جدید را مستقل میسازد، نسخههای تغییرناپذیر از Loanهای موجود محافظت میکنند، قوانین JSON سیاست اختصاصی هر Stage را ممکن میسازند و Actionها نقاط اتصال شفافی برای Queue یا Adapterهای خارجی فراهم میکنند.
|
||||
@@ -0,0 +1,59 @@
|
||||
# BankFlow Engineering Decisions
|
||||
|
||||
[English](ENGINEERING_DECISIONS.md) | [فارسی](ENGINEERING_DECISIONS.fa.md)
|
||||
|
||||
## 1. Layered Laravel architecture
|
||||
|
||||
**Options considered:** controllers with embedded logic, layered Laravel with Actions, or full Clean/Hexagonal architecture with repositories and ports.
|
||||
|
||||
**Decision:** use thin controllers, single-purpose Actions, a loan domain module, and Eloquent models. This keeps use cases and transaction boundaries explicit without adding abstractions that the current service does not need. It is familiar to Laravel developers and straightforward to test. The limitation is tighter coupling to Laravel and Eloquent than a ports-and-adapters design.
|
||||
|
||||
## 2. Ordered stage pipeline instead of hard-coded branching
|
||||
|
||||
**Options considered:** nested conditionals in a service, a generic rule engine, or ordered stateless stage handlers.
|
||||
|
||||
**Decision:** model a workflow as versioned, ordered database steps resolved through a trusted PHP registry. Each handler returns a typed result and the engine owns progression. Adding a stage changes the enum, handler, registry, rule validation, stage definition/workflow version, and tests; the engine and existing handlers remain unchanged.
|
||||
|
||||
This design is extensible and auditable without accepting executable administrator input. It is less expressive than a general graph or rule language: the current engine supports a linear ordered pipeline with conditional skips and terminal results, not arbitrary branches or cycles.
|
||||
|
||||
## 3. Database-owned rules with code-owned handlers
|
||||
|
||||
**Options considered:** all rules in PHP configuration files, all behavior in the database, or a hybrid.
|
||||
|
||||
**Decision:** store workflow order and business values as validated JSON on versioned database steps, while `config/workflow-stages.php` maps trusted codes to implementation classes. Administrators can change thresholds and ordering without deploying code, but cannot inject PHP, SQL, or expressions.
|
||||
|
||||
The benefit is operational flexibility with a controlled security boundary. The cost is maintaining per-stage validation and an administrative publication lifecycle. Although the challenge describes reading rules from configuration, the database is deliberately the versioned business configuration source; the PHP config file only registers trusted handlers.
|
||||
|
||||
## 4. Immutable workflow assignment and durable history
|
||||
|
||||
**Options considered:** always resolve the latest workflow, copy all workflow data onto each loan, or reference a versioned configuration.
|
||||
|
||||
**Decision:** assign the current published `workflow_configuration_id` when a loan is created. Published versions are immutable and each history record stores the executed step and rule snapshot. This makes old decisions reproducible without duplicating the complete configuration per loan. It requires retaining referenced workflow versions and prevents destructive deletion.
|
||||
|
||||
## 5. Synchronous atomic processing
|
||||
|
||||
**Options considered:** one synchronous request, a queued job per stage, or event-driven orchestration.
|
||||
|
||||
**Decision:** process all remaining stages in one request and one database transaction. The API immediately returns a terminal automatic-processing status, and failures cannot leave partial state. A row lock, terminal-status guard, history lookup, and unique history constraint prevent repeated or concurrent execution.
|
||||
|
||||
This is the simplest reliable fit for fast, mocked checks. Its main limitation is transaction duration: real credit, fraud, or AML integrations could be slow or unavailable. Those stages should eventually move to a resumable queued state machine with short transactions, explicit retry policy, timeouts, and idempotency keys.
|
||||
|
||||
## 6. Eloquent and PostgreSQL
|
||||
|
||||
**Options considered:** in-memory storage, a repository abstraction, or direct Eloquent persistence backed by a relational database.
|
||||
|
||||
**Decision:** use Eloquent with PostgreSQL in the production Compose setup. Relational foreign keys, composite constraints, row locks, JSON rule storage, and a partial unique index provide the required consistency and restart durability. SQLite remains useful for tests and the self-contained challenge image.
|
||||
|
||||
The advantage is strong persistence with little custom infrastructure. The trade-off is that some production guarantees—especially the partial unique index and concurrency semantics—are PostgreSQL-specific and are not fully exercised by SQLite tests.
|
||||
|
||||
## Three defining trade-offs
|
||||
|
||||
1. **Simplicity over throughput:** synchronous processing is clear and atomic, but not suitable for slow external dependencies.
|
||||
2. **Configurability over schema simplicity:** versioned workflow tables support safe changes and audits, but require validation and lifecycle management.
|
||||
3. **Framework convention over portability:** Actions plus Eloquent reduce boilerplate, but deliberately avoid persistence independence.
|
||||
|
||||
## Limitations and next improvements
|
||||
|
||||
The largest architectural limit is the synchronous linear workflow. With another week, the priorities would be PostgreSQL-backed concurrency tests, failure-injection and rollback tests, API authentication and rate limiting, richer authorization roles, OpenAPI generation, observability around stage latency/failures, and a resumable queue design for genuine external checks.
|
||||
|
||||
Future growth is still supported: stable stage contracts isolate new checks; immutable versions protect existing loans; JSON rules permit stage-specific policies; and Actions provide clear seams for queues or external adapters when those needs become real.
|
||||
+139
@@ -0,0 +1,139 @@
|
||||
# BankFlow
|
||||
|
||||
[English](README.md) | [فارسی](README.fa.md)
|
||||
|
||||
BankFlow یک سرویس Laravel برای ثبت و پردازش درخواستهای تسهیلات شخصی و تجاری است. به هر درخواست، یک Workflow نسخهبندیشده و تغییرناپذیر اختصاص داده میشود؛ پردازش، Stageهای پیکربندیشده را بهصورت همزمان اجرا میکند و برای هر Stage اجراشده نتیجهای قابل ممیزی ثبت میکند.
|
||||
|
||||
این مخزن شامل JSON API نسخهبندیشده، پنل مدیریت Filament برای تسهیلات و پیکربندی Workflow، محیط تولید مبتنی بر PostgreSQL و مجموعه تست Pest است.
|
||||
|
||||
## قابلیتهای اصلی
|
||||
|
||||
- ثبت و مشاهده درخواستهای تسهیلات از طریق `/api/v1/loans`؛
|
||||
- اجرای مراحل اعتبارسنجی، تقلب، ضامن، اعتبار مالی و تأیید مشروط مدیر؛
|
||||
- توقف پردازش در حالت رد یا بررسی دستی و بازگرداندن امن نتیجه نهایی در درخواستهای تکراری؛
|
||||
- پیکربندی و انتشار Workflowهای نسخهبندیشده برای هر نوع تسهیلات از طریق پنل مدیریت؛
|
||||
- نگهداری نتیجه مراحل و Snapshot دقیق قوانین استفادهشده برای هر تصمیم؛
|
||||
- بررسی آمادگی سرویس از طریق `GET /health`.
|
||||
|
||||
قرارداد کامل HTTP در [docs/api-routes.md](docs/api-routes.md) قرار دارد.
|
||||
|
||||
## فناوریها
|
||||
|
||||
- PHP 8.4 و Laravel 13
|
||||
- Filament 5 و Livewire 4
|
||||
- PostgreSQL 17 در محیط Compose؛ پشتیبانی از SQLite برای تستها و Image مستقل
|
||||
- Eloquent ORM
|
||||
- Pest 4 و PHPUnit 12
|
||||
- Tailwind CSS 4 و Vite 8
|
||||
- Apache در Container تولید
|
||||
|
||||
## اجرا با Docker
|
||||
|
||||
Image مستقل و سازگار با قرارداد چالش از پایگاه داده SQLite داخلی استفاده میکند. Entrypoint هنگام راهاندازی Migrationها و Seederها را اجرا میکند.
|
||||
|
||||
```bash
|
||||
docker build -t bankflow .
|
||||
docker run --rm -p 8080:8080 bankflow
|
||||
```
|
||||
|
||||
پس از اجرا، سرویس روی پورت `8080` در دسترس است. برای بررسی سلامت آن اجرا کنید:
|
||||
|
||||
```bash
|
||||
curl http://127.0.0.1:8080/health
|
||||
```
|
||||
|
||||
برای اجرا با PostgreSQL، فایل محیطی را کپی کنید، مقادیر `APP_KEY` و `DB_PASSWORD` را تنظیم کنید و سپس Compose را اجرا کنید:
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
docker compose up --build
|
||||
```
|
||||
|
||||
Compose دادههای PostgreSQL را در Volume با نام `postgres-data` نگه میدارد. هر دو روش Container، Migrationها و `BankFlowSeeder` تکرارپذیر را بهطور خودکار اجرا میکنند.
|
||||
|
||||
## توسعه محلی
|
||||
|
||||
### پیشنیازها
|
||||
|
||||
- PHP 8.4 بههمراه Extensionهای مورد نیاز Laravel و پایگاه داده انتخابشده
|
||||
- Composer 2
|
||||
- Node.js 24 و npm
|
||||
- PostgreSQL، یا SQLite برای محیط محلی سبکتر
|
||||
- Laravel Herd یا یک وبسرور محلی پیکربندیشده دیگر
|
||||
|
||||
برنامه را نصب و پیکربندی کنید:
|
||||
|
||||
```bash
|
||||
cp .env.example .env
|
||||
composer install
|
||||
php artisan key:generate
|
||||
npm install
|
||||
npm run build
|
||||
php artisan migrate --seed
|
||||
```
|
||||
|
||||
پیش از اجرای Migration، مقادیر `DB_*` در `.env` را متناسب با پایگاه داده در دسترس میزبان تغییر دهید. برای استفاده از SQLite، مقدار `DB_CONNECTION=sqlite` را تنظیم کنید، سایر مقادیر `DB_*` را حذف کنید و در صورت نبود فایل `database/database.sqlite` آن را بسازید.
|
||||
|
||||
برای توسعه فعال Frontend، فرمان `npm run dev` را اجرا کنید. در محیط استاندارد پروژه، برنامه از قبل توسط Laravel Herd سرو میشود و نیازی به اجرای PHP Development Server دیگری نیست.
|
||||
|
||||
پنل مدیریت در مسیر `/admin` قرار دارد و به کاربر احرازهویتشده با ایمیل تأییدشده نیاز دارد.
|
||||
|
||||
## نمونه API
|
||||
|
||||
یک درخواست تسهیلات ایجاد و پردازش کنید:
|
||||
|
||||
```bash
|
||||
curl -X POST http://127.0.0.1:8080/api/v1/loans \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{
|
||||
"customerId": "C-1001",
|
||||
"amount": 400000000,
|
||||
"phone": "09121234567",
|
||||
"loanType": "PERSONAL",
|
||||
"monthlyIncome": 50000000,
|
||||
"creditScore": 720,
|
||||
"hasGuarantor": false
|
||||
}'
|
||||
```
|
||||
|
||||
از `loanId` بازگرداندهشده استفاده کنید:
|
||||
|
||||
```bash
|
||||
curl -X POST http://127.0.0.1:8080/api/v1/loans/{loanId}/process
|
||||
curl http://127.0.0.1:8080/api/v1/loans/{loanId}
|
||||
curl http://127.0.0.1:8080/api/v1/loans/{loanId}/history
|
||||
```
|
||||
|
||||
## تست و قالببندی
|
||||
|
||||
محیط تست از پایگاه داده SQLite درون حافظه استفاده میکند و به PostgreSQL نیاز ندارد.
|
||||
|
||||
```bash
|
||||
php artisan test --compact
|
||||
vendor/bin/pint --format agent
|
||||
```
|
||||
|
||||
برای اجرای یک تست متمرکز از `php artisan test --compact --filter=ProcessLoanTest` استفاده کنید. راهبرد تست و پوشش فعلی در [TESTING.fa.md](TESTING.fa.md) توضیح داده شده است.
|
||||
|
||||
## ساختار پروژه
|
||||
|
||||
```text
|
||||
app/Actions/ عملیات مستقل برنامه و Transactionها
|
||||
app/Domain/Loan/ Enumها، قراردادها و Handlerهای Stage و Engine
|
||||
app/Filament/ Resourceها، Pageها و Widgetهای مدیریتی
|
||||
app/Http/ Controllerهای API، پردازش Request و Resourceها
|
||||
app/Models/ مدلهای ماندگاری Eloquent
|
||||
config/workflow-stages.php Registry امن نگاشت کد Stage به Handler
|
||||
database/ Migrationها، Factoryها و داده اولیه Workflow
|
||||
docs/ نیازمندیها، قرارداد API و Blueprint پیادهسازی
|
||||
routes/ Routeهای وب و API نسخهبندیشده
|
||||
tests/ تستهای Unit و Feature با Pest
|
||||
```
|
||||
|
||||
## مستندات بیشتر
|
||||
|
||||
- [DESIGN.fa.md](DESIGN.fa.md) — معماری اجرا، مدل Workflow، وضعیت و توسعهپذیری
|
||||
- [ENGINEERING_DECISIONS.fa.md](ENGINEERING_DECISIONS.fa.md) — گزینهها، Trade-offها، محدودیتها و کارهای آینده
|
||||
- [TESTING.fa.md](TESTING.fa.md) — دامنه تست و فرمانهای اجرا
|
||||
- [docs/bank-flow.md](docs/bank-flow.md) — نیازمندیهای اصلی چالش
|
||||
- [docs/project-blueprint.md](docs/project-blueprint.md) — Blueprint تفصیلی پیادهسازی
|
||||
@@ -1,93 +1,139 @@
|
||||
# bank-flow
|
||||
# BankFlow
|
||||
|
||||
[English](README.md) | [فارسی](README.fa.md)
|
||||
|
||||
BankFlow is a Laravel service for submitting and processing personal and business loan applications. Each loan is assigned an immutable, versioned workflow; processing executes its configured stages synchronously and records an auditable result for every stage that ran.
|
||||
|
||||
## Getting started
|
||||
The repository includes the versioned JSON API, a Filament administration panel for loans and workflow configuration, a PostgreSQL production setup, and a Pest test suite.
|
||||
|
||||
To make it easy for you to get started with GitLab, here's a list of recommended next steps.
|
||||
## Main capabilities
|
||||
|
||||
Already a pro? Just edit this README.md and make it your own. Want to make it easy? [Use the template at the bottom](#editing-this-readme)!
|
||||
- Submit and inspect loan applications through `/api/v1/loans`.
|
||||
- Process validation, fraud, guarantor, credit, and conditional manager-approval stages.
|
||||
- Stop on rejection or manual review and safely return terminal results on repeated requests.
|
||||
- Configure and publish versioned workflows per loan type through the admin panel.
|
||||
- Preserve stage results and the exact rule snapshot used for each decision.
|
||||
- Inspect service readiness through `GET /health`.
|
||||
|
||||
## Add your files
|
||||
The complete HTTP contract is in [docs/api-routes.md](docs/api-routes.md).
|
||||
|
||||
* [Create](https://docs.gitlab.com/user/project/repository/web_editor/#create-a-file) or [upload](https://docs.gitlab.com/user/project/repository/web_editor/#upload-a-file) files
|
||||
* [Add files using the command line](https://docs.gitlab.com/topics/git/add_files/#add-files-to-a-git-repository) or push an existing Git repository with the following command:
|
||||
## Technology
|
||||
|
||||
```
|
||||
cd existing_repo
|
||||
git remote add origin https://git.sharifict.com/star-bugs/bank-flow.git
|
||||
git branch -M main
|
||||
git push -uf origin main
|
||||
- PHP 8.4 and Laravel 13
|
||||
- Filament 5 and Livewire 4
|
||||
- PostgreSQL 17 in the Compose environment; SQLite is supported for tests and the standalone image
|
||||
- Eloquent ORM
|
||||
- Pest 4 and PHPUnit 12
|
||||
- Tailwind CSS 4 and Vite 8
|
||||
- Apache in the production container
|
||||
|
||||
## Run with Docker
|
||||
|
||||
The challenge-compatible standalone image uses its internal SQLite database. The entrypoint migrates and seeds the database on startup.
|
||||
|
||||
```bash
|
||||
docker build -t bankflow .
|
||||
docker run --rm -p 8080:8080 bankflow
|
||||
```
|
||||
|
||||
## Integrate with your tools
|
||||
The service is then available on port `8080`; verify it with:
|
||||
|
||||
* [Set up project integrations](https://git.sharifict.com/star-bugs/bank-flow/-/settings/integrations)
|
||||
```bash
|
||||
curl http://127.0.0.1:8080/health
|
||||
```
|
||||
|
||||
## Collaborate with your team
|
||||
For PostgreSQL-backed execution, copy the environment file, set `APP_KEY` and `DB_PASSWORD`, then use Compose:
|
||||
|
||||
* [Invite team members and collaborators](https://docs.gitlab.com/user/project/members/)
|
||||
* [Create a new merge request](https://docs.gitlab.com/user/project/merge_requests/creating_merge_requests/)
|
||||
* [Automatically close issues from merge requests](https://docs.gitlab.com/user/project/issues/managing_issues/#closing-issues-automatically)
|
||||
* [Enable merge request approvals](https://docs.gitlab.com/user/project/merge_requests/approvals/)
|
||||
* [Set auto-merge](https://docs.gitlab.com/user/project/merge_requests/auto_merge/)
|
||||
```bash
|
||||
cp .env.example .env
|
||||
docker compose up --build
|
||||
```
|
||||
|
||||
## Test and Deploy
|
||||
Compose persists PostgreSQL data in the `postgres-data` volume. Both container paths run migrations and the idempotent `BankFlowSeeder` automatically.
|
||||
|
||||
Use the built-in continuous integration in GitLab.
|
||||
## Local development
|
||||
|
||||
* [Get started with GitLab CI/CD](https://docs.gitlab.com/ci/quick_start/)
|
||||
* [Analyze your code for known vulnerabilities with Static Application Security Testing (SAST)](https://docs.gitlab.com/user/application_security/sast/)
|
||||
* [Deploy to Kubernetes, Amazon EC2, or Amazon ECS using Auto Deploy](https://docs.gitlab.com/topics/autodevops/requirements/)
|
||||
* [Use pull-based deployments for improved Kubernetes management](https://docs.gitlab.com/user/clusters/agent/)
|
||||
* [Set up protected environments](https://docs.gitlab.com/ci/environments/protected_environments/)
|
||||
### Prerequisites
|
||||
|
||||
***
|
||||
- PHP 8.4 with the extensions required by Laravel and the selected database
|
||||
- Composer 2
|
||||
- Node.js 24 and npm
|
||||
- PostgreSQL, or SQLite for a lightweight local setup
|
||||
- Laravel Herd or another locally configured web server
|
||||
|
||||
# Editing this README
|
||||
Install and configure the application:
|
||||
|
||||
When you're ready to make this README your own, just edit this file and use the handy template below (or feel free to structure it however you want - this is just a starting point!). Thanks to [makeareadme.com](https://www.makeareadme.com/) for this template.
|
||||
```bash
|
||||
cp .env.example .env
|
||||
composer install
|
||||
php artisan key:generate
|
||||
npm install
|
||||
npm run build
|
||||
php artisan migrate --seed
|
||||
```
|
||||
|
||||
## Suggestions for a good README
|
||||
Before migrating, update the `DB_*` values in `.env` for the database reachable from the host. To use SQLite, set `DB_CONNECTION=sqlite`, remove the other `DB_*` values, and create `database/database.sqlite` if it does not exist.
|
||||
|
||||
Every project is different, so consider which of these sections apply to yours. The sections used in the template are suggestions for most open source projects. Also keep in mind that while a README can be too long and detailed, too long is better than too short. If you think your README is too long, consider utilizing another form of documentation rather than cutting out information.
|
||||
For active frontend work, run `npm run dev`. The application is already served by Laravel Herd in the standard project environment; no additional PHP development server is required.
|
||||
|
||||
## Name
|
||||
Choose a self-explaining name for your project.
|
||||
The administration panel is mounted at `/admin`. It requires an authenticated user with a verified email address.
|
||||
|
||||
## Description
|
||||
Let people know what your project can do specifically. Provide context and add a link to any reference visitors might be unfamiliar with. A list of Features or a Background subsection can also be added here. If there are alternatives to your project, this is a good place to list differentiating factors.
|
||||
## API example
|
||||
|
||||
## Badges
|
||||
On some READMEs, you may see small images that convey metadata, such as whether or not all the tests are passing for the project. You can use Shields to add some to your README. Many services also have instructions for adding a badge.
|
||||
Create and process a loan:
|
||||
|
||||
## Visuals
|
||||
Depending on what you are making, it can be a good idea to include screenshots or even a video (you'll frequently see GIFs rather than actual videos). Tools like ttygif can help, but check out Asciinema for a more sophisticated method.
|
||||
```bash
|
||||
curl -X POST http://127.0.0.1:8080/api/v1/loans \
|
||||
-H 'Content-Type: application/json' \
|
||||
-d '{
|
||||
"customerId": "C-1001",
|
||||
"amount": 400000000,
|
||||
"phone": "09121234567",
|
||||
"loanType": "PERSONAL",
|
||||
"monthlyIncome": 50000000,
|
||||
"creditScore": 720,
|
||||
"hasGuarantor": false
|
||||
}'
|
||||
```
|
||||
|
||||
## Installation
|
||||
Within a particular ecosystem, there may be a common way of installing things, such as using Yarn, NuGet, or Homebrew. However, consider the possibility that whoever is reading your README is a novice and would like more guidance. Listing specific steps helps remove ambiguity and gets people to using your project as quickly as possible. If it only runs in a specific context like a particular programming language version or operating system or has dependencies that have to be installed manually, also add a Requirements subsection.
|
||||
Use the returned `loanId`:
|
||||
|
||||
## Usage
|
||||
Use examples liberally, and show the expected output if you can. It's helpful to have inline the smallest example of usage that you can demonstrate, while providing links to more sophisticated examples if they are too long to reasonably include in the README.
|
||||
```bash
|
||||
curl -X POST http://127.0.0.1:8080/api/v1/loans/{loanId}/process
|
||||
curl http://127.0.0.1:8080/api/v1/loans/{loanId}
|
||||
curl http://127.0.0.1:8080/api/v1/loans/{loanId}/history
|
||||
```
|
||||
|
||||
## Support
|
||||
Tell people where they can go to for help. It can be any combination of an issue tracker, a chat room, an email address, etc.
|
||||
## Tests and formatting
|
||||
|
||||
## Roadmap
|
||||
If you have ideas for releases in the future, it is a good idea to list them in the README.
|
||||
The test environment uses an in-memory SQLite database and does not require PostgreSQL.
|
||||
|
||||
## Contributing
|
||||
State if you are open to contributions and what your requirements are for accepting them.
|
||||
```bash
|
||||
php artisan test --compact
|
||||
vendor/bin/pint --format agent
|
||||
```
|
||||
|
||||
For people who want to make changes to your project, it's helpful to have some documentation on how to get started. Perhaps there is a script that they should run or some environment variables that they need to set. Make these steps explicit. These instructions could also be useful to your future self.
|
||||
Run a focused test with `php artisan test --compact --filter=ProcessLoanTest`. See [TESTING.md](TESTING.md) for the test strategy and current coverage.
|
||||
|
||||
You can also document commands to lint the code or run tests. These steps help to ensure high code quality and reduce the likelihood that the changes inadvertently break something. Having instructions for running tests is especially helpful if it requires external setup, such as starting a Selenium server for testing in a browser.
|
||||
## Project layout
|
||||
|
||||
## Authors and acknowledgment
|
||||
Show your appreciation to those who have contributed to the project.
|
||||
```text
|
||||
app/Actions/ Single-use application operations and transactions
|
||||
app/Domain/Loan/ Enums, stage contracts, stage handlers, and engine
|
||||
app/Filament/ Administrative resources, pages, and widgets
|
||||
app/Http/ API controllers, request parsing, and resources
|
||||
app/Models/ Eloquent persistence models
|
||||
config/workflow-stages.php Trusted stage-code-to-handler registry
|
||||
database/ Migrations, factories, and initial workflow seed data
|
||||
docs/ Requirements, API contract, and implementation blueprint
|
||||
routes/ Web and versioned API routes
|
||||
tests/ Pest feature and unit tests
|
||||
```
|
||||
|
||||
## License
|
||||
For open source projects, say how it is licensed.
|
||||
## Further documentation
|
||||
|
||||
## Project status
|
||||
If you have run out of energy or time for your project, put a note at the top of the README saying that development has slowed down or stopped completely. Someone may choose to fork your project or volunteer to step in as a maintainer or owner, allowing your project to keep going. You can also make an explicit request for maintainers.
|
||||
- [DESIGN.md](DESIGN.md) — runtime architecture, workflow model, state, and extensibility
|
||||
- [ENGINEERING_DECISIONS.md](ENGINEERING_DECISIONS.md) — alternatives, trade-offs, limitations, and future work
|
||||
- [TESTING.md](TESTING.md) — test scope and commands
|
||||
- [docs/bank-flow.md](docs/bank-flow.md) — original challenge requirements
|
||||
- [docs/project-blueprint.md](docs/project-blueprint.md) — detailed implementation blueprint
|
||||
@@ -0,0 +1,40 @@
|
||||
# تست BankFlow
|
||||
|
||||
[English](TESTING.md) | [فارسی](TESTING.fa.md)
|
||||
|
||||
BankFlow از Pest 4 استفاده میکند. Feature Testها با Application Test Case مربوط به Laravel و `LazilyRefreshDatabase` اجرا میشوند. فایل `phpunit.xml` پایگاه داده SQLite درون حافظه، Cache و Session و Mail آرایهای و Queue Driver همزمان را انتخاب میکند.
|
||||
|
||||
## اجرای مجموعه تست
|
||||
|
||||
```bash
|
||||
php artisan test --compact
|
||||
```
|
||||
|
||||
برای اجرای تست متمرکز، برای نمونه از فرمانهای زیر استفاده کنید:
|
||||
|
||||
```bash
|
||||
php artisan test --compact tests/Feature/Loan/ProcessLoanTest.php
|
||||
php artisan test --compact --filter="approves a valid personal loan"
|
||||
```
|
||||
|
||||
## پوشش Unit Test
|
||||
|
||||
Unit Testها هر Stage کسبوکار را بهطور مستقل بررسی میکنند:
|
||||
|
||||
- اعتبارسنجی موفق و دلیل اولین خطا برای هر قانون؛
|
||||
- Prefixهای تقلب و بررسی دستی؛
|
||||
- نتایج بررسی ضامن؛
|
||||
- مرزهای اعتبار مالی و قوانین Overrideشده؛
|
||||
- قابل اجرا بودن تأیید مدیر، ضریب درآمد و نتایج Pass/Fail.
|
||||
|
||||
این تستها رفتار خالص Stage را بدون هماهنگسازی HTTP یا پایگاه داده بررسی میکنند.
|
||||
|
||||
## پوشش Feature و Integration
|
||||
|
||||
Feature Testها ایجاد Loan، اعتبارسنجی معنایی تأخیری، Request ناقص، نوع تسهیلات خارج از دسترس، مسیرهای پردازش شخصی و تجاری، بررسی دستی تقلب یا اعتبار، تأیید مشروط مدیر، Idempotency وضعیت نهایی، دریافت اطلاعات، تاریخچه مرتب، خطاهای مستند Not Found و Health Check را پوشش میدهند.
|
||||
|
||||
Integration Testهای مدیریتی دسترسی احرازهویتشده به پنل، نمایش فقطخواندنی Loan، ویرایش Workflow فقط در وضعیت Draft، کپی نسخه Workflow، انتشار اعتبارسنجیشده، Archive اتمیک نسخه قبلی و تأیید محافظتشده مدیر را بررسی میکنند. این تستها مرزهای HTTP/Filament، Action، Eloquent، Migration و Resource را در بر میگیرند.
|
||||
|
||||
## موارد پوششدادهنشده
|
||||
|
||||
مجموعه فعلی، Requestهای همزمان واقعی یا رفتارهای مخصوص PostgreSQL مانند رقابت قفل ردیف و Partial Published-workflow Index را آزمایش نمیکند. همچنین Docker Smoke Test، Browser Test فرانتاند، تست Performance/Load، تست امنیت، تزریق Exception پیشبینینشده برای بررسی Rollback و Integration واقعی تقلب یا اعتبار پوشش داده نشدهاند؛ چالش برای این موارد از قوانین قطعی و Mockشده استفاده میکند.
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
# BankFlow Testing
|
||||
|
||||
[English](TESTING.md) | [فارسی](TESTING.fa.md)
|
||||
|
||||
BankFlow uses Pest 4. Feature tests run with Laravel's application test case and `LazilyRefreshDatabase`; `phpunit.xml` selects an in-memory SQLite database, array-backed cache/session/mail, and the synchronous queue driver.
|
||||
|
||||
## Run the suite
|
||||
|
||||
```bash
|
||||
php artisan test --compact
|
||||
```
|
||||
|
||||
Run a focused group with, for example:
|
||||
|
||||
```bash
|
||||
php artisan test --compact tests/Feature/Loan/ProcessLoanTest.php
|
||||
php artisan test --compact --filter="approves a valid personal loan"
|
||||
```
|
||||
|
||||
## Unit coverage
|
||||
|
||||
Unit tests exercise each business stage independently:
|
||||
|
||||
- validation success and each first-failure reason;
|
||||
- fraud and manual-review prefixes;
|
||||
- guarantor outcomes;
|
||||
- credit boundaries and overridden rules;
|
||||
- manager-approval applicability, income multiplier, and pass/fail results.
|
||||
|
||||
These tests verify pure stage behavior without HTTP or database orchestration.
|
||||
|
||||
## Feature and integration coverage
|
||||
|
||||
Feature tests cover loan creation, deferred semantic validation, malformed requests, unavailable types, personal and business processing paths, fraud/credit manual review, conditional manager approval, terminal-state idempotency, retrieval, ordered history, documented not-found errors, and health checks.
|
||||
|
||||
Administrative integration tests cover authenticated panel access, read-only loan views, draft-only workflow editing, copying workflow versions, validated publication, atomic archival of the prior version, and guarded manager approval. These tests cross the HTTP/Filament, Action, Eloquent, migration, and resource boundaries.
|
||||
|
||||
## Known gaps
|
||||
|
||||
The suite does not currently exercise real concurrent requests or PostgreSQL-specific behavior such as row-lock contention and the partial published-workflow index. It also omits Docker smoke tests, frontend browser tests, performance/load tests, security testing, unexpected-exception rollback injection, and real external fraud/credit integrations (the challenge uses deterministic mocked rules).
|
||||
@@ -0,0 +1,14 @@
|
||||
<VirtualHost *:8080>
|
||||
ServerName localhost
|
||||
ServerAdmin webmaster@localhost
|
||||
DocumentRoot /var/www/html/public
|
||||
|
||||
<Directory /var/www/html/public>
|
||||
Options -Indexes +FollowSymLinks
|
||||
AllowOverride All
|
||||
Require all granted
|
||||
</Directory>
|
||||
|
||||
ErrorLog /proc/self/fd/2
|
||||
CustomLog /proc/self/fd/1 combined
|
||||
</VirtualHost>
|
||||
@@ -16,24 +16,24 @@ use Illuminate\Http\Resources\Json\AnonymousResourceCollection;
|
||||
|
||||
class LoanController extends Controller
|
||||
{
|
||||
public function store(StoreLoanRequest $request, CreateLoanAction $createLoan): JsonResponse
|
||||
public function store(StoreLoanRequest $request, CreateLoanAction $createLoan)
|
||||
{
|
||||
$loan = $createLoan->handle($request->validated());
|
||||
|
||||
return (new LoanProcessResource($loan))->response()->setStatusCode(201);
|
||||
return LoanProcessResource::make($loan);
|
||||
}
|
||||
|
||||
public function process(string $loanId, ProcessLoanAction $processLoan): JsonResponse
|
||||
public function process(string $loanId, ProcessLoanAction $processLoan)
|
||||
{
|
||||
return (new LoanProcessResource($processLoan->handle($loanId)))->response();
|
||||
return LoanProcessResource::make($processLoan->handle($loanId));
|
||||
}
|
||||
|
||||
public function show(string $loanId, GetLoanAction $getLoan): JsonResponse
|
||||
public function show(string $loanId, GetLoanAction $getLoan)
|
||||
{
|
||||
return (new LoanResource($getLoan->handle($loanId)))->response();
|
||||
return LoanResource::make($getLoan->handle($loanId));
|
||||
}
|
||||
|
||||
public function history(string $loanId, GetLoanHistoryAction $getLoanHistory): AnonymousResourceCollection
|
||||
public function history(string $loanId, GetLoanHistoryAction $getLoanHistory)
|
||||
{
|
||||
return LoanHistoryResource::collection($getLoanHistory->handle($loanId));
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ use Illuminate\Http\JsonResponse;
|
||||
|
||||
class HealthCheckController extends Controller
|
||||
{
|
||||
public function __invoke(): JsonResponse
|
||||
public function __invoke()
|
||||
{
|
||||
return response()->json(['status' => 'UP']);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
name: bankflow
|
||||
|
||||
services:
|
||||
app:
|
||||
build:
|
||||
context: .
|
||||
dockerfile: Dockerfile
|
||||
image: bankflow:latest
|
||||
env_file:
|
||||
- .env
|
||||
environment:
|
||||
APP_URL: http://127.0.0.1:8080
|
||||
DB_CONNECTION: pgsql
|
||||
DB_HOST: postgres
|
||||
DB_PORT: 5432
|
||||
DB_DATABASE: ${DB_DATABASE:-bankflow}
|
||||
DB_USERNAME: ${DB_USERNAME:-bankflow}
|
||||
DB_PASSWORD: ${DB_PASSWORD:-bankflow}
|
||||
ports:
|
||||
- "8080:8080"
|
||||
depends_on:
|
||||
postgres:
|
||||
condition: service_healthy
|
||||
restart: unless-stopped
|
||||
|
||||
postgres:
|
||||
image: postgres:17-alpine
|
||||
environment:
|
||||
POSTGRES_DB: ${DB_DATABASE:-bankflow}
|
||||
POSTGRES_USER: ${DB_USERNAME:-bankflow}
|
||||
POSTGRES_PASSWORD: ${DB_PASSWORD:-bankflow}
|
||||
volumes:
|
||||
- postgres-data:/var/lib/postgresql/data
|
||||
healthcheck:
|
||||
test: ["CMD-SHELL", "pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}"]
|
||||
interval: 5s
|
||||
timeout: 5s
|
||||
retries: 10
|
||||
start_period: 10s
|
||||
restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
postgres-data:
|
||||
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class AdminSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$admin = User::query()->firstOrNew(['email' => 'admin@bankflow.test']);
|
||||
|
||||
$admin->name = 'BankFlow Admin';
|
||||
|
||||
if (! $admin->exists) {
|
||||
$admin->password = 'password';
|
||||
}
|
||||
|
||||
if (is_null($admin->email_verified_at)) {
|
||||
$admin->email_verified_at = now();
|
||||
}
|
||||
|
||||
$admin->save();
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,9 @@ class DatabaseSeeder extends Seeder
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
$this->call(BankFlowSeeder::class);
|
||||
$this->call([
|
||||
AdminSeeder::class,
|
||||
BankFlowSeeder::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -eu
|
||||
|
||||
gosu www-data php artisan config:clear --no-interaction
|
||||
gosu www-data php artisan config:cache --no-interaction
|
||||
gosu www-data php artisan migrate --force --no-interaction
|
||||
gosu www-data php artisan db:seed --force --no-interaction
|
||||
|
||||
exec "$@"
|
||||
@@ -7,3 +7,11 @@
|
||||
--font-sans: 'Instrument Sans', ui-sans-serif, system-ui, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji',
|
||||
'Segoe UI Symbol', 'Noto Color Emoji';
|
||||
}
|
||||
|
||||
@layer base {
|
||||
button,
|
||||
input,
|
||||
select {
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
}
|
||||
}
|
||||
+284
-1
@@ -1 +1,284 @@
|
||||
//
|
||||
const loanForm = document.querySelector('#loan-form');
|
||||
|
||||
if (loanForm) {
|
||||
const serviceStatus = document.querySelector('#service-status');
|
||||
const serviceStatusPulse = document.querySelector('#service-status-pulse');
|
||||
const serviceStatusDot = document.querySelector('#service-status-dot');
|
||||
const serviceStatusLabel = document.querySelector('#service-status-label');
|
||||
const lookupForm = document.querySelector('#lookup-form');
|
||||
const resultPanel = document.querySelector('#result-panel');
|
||||
const processButton = document.querySelector('#process-loan');
|
||||
const submitButton = document.querySelector('#submit-loan');
|
||||
const formMessage = document.querySelector('#form-message');
|
||||
const creditScore = document.querySelector('#credit-score');
|
||||
const creditScoreOutput = document.querySelector('#credit-score-output');
|
||||
const healthCheckInterval = 3_000;
|
||||
let activeLoanId = null;
|
||||
let healthCheckTimer = null;
|
||||
let isCheckingService = false;
|
||||
|
||||
const terminalStatuses = ['APPROVED', 'REJECTED', 'MANUAL_REVIEW'];
|
||||
const statusLabels = {
|
||||
SUBMITTED: 'Submitted',
|
||||
IN_PROGRESS: 'In progress',
|
||||
MANUAL_REVIEW: 'Manual review',
|
||||
APPROVED: 'Approved',
|
||||
REJECTED: 'Rejected',
|
||||
};
|
||||
const stageLabels = {
|
||||
VALIDATION: 'Validation',
|
||||
FRAUD_CHECK: 'Fraud check',
|
||||
GUARANTOR_CHECK: 'Guarantor check',
|
||||
CREDIT_CHECK: 'Credit check',
|
||||
MANAGER_APPROVAL: 'Manager approval',
|
||||
};
|
||||
|
||||
const icons = {
|
||||
success: '<svg class="size-6" viewBox="0 0 24 24" fill="none" aria-hidden="true"><path d="m5 12 4.5 4.5L19 7" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',
|
||||
pending: '<svg class="size-6" viewBox="0 0 24 24" fill="none" aria-hidden="true"><path d="M12 7v5l3 2M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',
|
||||
stopped: '<svg class="size-6" viewBox="0 0 24 24" fill="none" aria-hidden="true"><path d="M12 8v5m0 3v.01M21 12a9 9 0 1 1-18 0 9 9 0 0 1 18 0Z" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',
|
||||
};
|
||||
|
||||
const checkServiceHealth = async () => {
|
||||
try {
|
||||
const response = await fetch(serviceStatus.dataset.healthUrl, {
|
||||
headers: {Accept: 'application/json'},
|
||||
cache: 'no-store',
|
||||
signal: AbortSignal.timeout(5_000),
|
||||
});
|
||||
const payload = await response.json();
|
||||
|
||||
if (!response.ok || payload.status !== 'UP') {
|
||||
throw new Error('Service unavailable');
|
||||
}
|
||||
|
||||
serviceStatusLabel.textContent = 'Service ready';
|
||||
serviceStatusPulse.className = 'absolute inline-flex size-full animate-ping rounded-full bg-emerald-400 opacity-60';
|
||||
serviceStatusDot.className = 'relative inline-flex size-2 rounded-full bg-emerald-500';
|
||||
} catch {
|
||||
serviceStatusLabel.textContent = 'Service unavailable';
|
||||
serviceStatusPulse.className = 'hidden';
|
||||
serviceStatusDot.className = 'relative inline-flex size-2 rounded-full bg-rose-500';
|
||||
}
|
||||
};
|
||||
|
||||
const scheduleServiceHealthCheck = () => {
|
||||
window.clearTimeout(healthCheckTimer);
|
||||
|
||||
if (!document.hidden) {
|
||||
healthCheckTimer = window.setTimeout(pollServiceHealth, healthCheckInterval);
|
||||
}
|
||||
};
|
||||
|
||||
const pollServiceHealth = async () => {
|
||||
if (isCheckingService) {
|
||||
return;
|
||||
}
|
||||
|
||||
isCheckingService = true;
|
||||
await checkServiceHealth();
|
||||
isCheckingService = false;
|
||||
scheduleServiceHealthCheck();
|
||||
};
|
||||
|
||||
document.addEventListener('visibilitychange', () => {
|
||||
window.clearTimeout(healthCheckTimer);
|
||||
|
||||
if (!document.hidden) {
|
||||
pollServiceHealth();
|
||||
}
|
||||
});
|
||||
|
||||
pollServiceHealth();
|
||||
|
||||
creditScore.addEventListener('input', () => {
|
||||
creditScoreOutput.value = creditScore.value;
|
||||
creditScoreOutput.textContent = creditScore.value;
|
||||
});
|
||||
|
||||
const request = async (url, options = {}) => {
|
||||
const response = await fetch(url, {
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
...(options.body ? {'Content-Type': 'application/json'} : {}),
|
||||
},
|
||||
...options,
|
||||
});
|
||||
const payload = await response.json().catch(() => ({}));
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(payload.error || 'The request could not be completed.');
|
||||
}
|
||||
|
||||
return payload;
|
||||
};
|
||||
|
||||
const showMessage = (message, type = 'error') => {
|
||||
formMessage.textContent = message;
|
||||
formMessage.className = `mt-5 rounded-xl px-3.5 py-3 text-sm ${type === 'error' ? 'bg-rose-50 text-rose-700' : 'bg-teal-50 text-teal-800'}`;
|
||||
};
|
||||
|
||||
const clearMessage = () => {
|
||||
formMessage.className = 'mt-5 hidden rounded-xl px-3.5 py-3 text-sm';
|
||||
formMessage.textContent = '';
|
||||
};
|
||||
|
||||
const formatAmount = (value) => new Intl.NumberFormat('en-US').format(value);
|
||||
const formatTime = (value) => new Intl.DateTimeFormat('en', {
|
||||
month: 'short',
|
||||
day: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
}).format(new Date(value));
|
||||
|
||||
const createTextElement = (tag, className, text) => {
|
||||
const element = document.createElement(tag);
|
||||
element.className = className;
|
||||
element.textContent = text;
|
||||
|
||||
return element;
|
||||
};
|
||||
|
||||
const renderSummary = (loan) => {
|
||||
const summary = document.querySelector('#loan-summary');
|
||||
const entries = [
|
||||
['Customer', loan.customerId],
|
||||
['Type', statusLabels[loan.loanType] || loan.loanType],
|
||||
['Amount', loan.amount === undefined ? '—' : `${formatAmount(loan.amount)} IRR`],
|
||||
['Credit score', loan.creditScore ?? '—'],
|
||||
];
|
||||
summary.replaceChildren();
|
||||
|
||||
entries.forEach(([label, value]) => {
|
||||
const card = document.createElement('div');
|
||||
card.className = 'rounded-xl bg-white/5 p-3';
|
||||
card.append(
|
||||
createTextElement('p', 'text-[10px] font-semibold uppercase tracking-wider text-slate-500', label),
|
||||
createTextElement('p', 'mt-1 truncate text-sm font-medium text-slate-100', value ?? '—'),
|
||||
);
|
||||
summary.append(card);
|
||||
});
|
||||
};
|
||||
|
||||
const renderHistory = (history) => {
|
||||
const historyList = document.querySelector('#history-list');
|
||||
document.querySelector('#history-count').textContent = history.length ? `${history.length} stages` : 'Not processed yet';
|
||||
historyList.replaceChildren();
|
||||
|
||||
if (!history.length) {
|
||||
const empty = createTextElement('li', 'rounded-xl border border-dashed border-white/15 px-4 py-5 text-center text-sm text-slate-500', 'Run the workflow to see each decision here.');
|
||||
historyList.append(empty);
|
||||
return;
|
||||
}
|
||||
|
||||
history.forEach((entry) => {
|
||||
const item = document.createElement('li');
|
||||
item.className = 'grid grid-cols-[auto_1fr_auto] items-start gap-3 rounded-xl bg-white/5 px-3.5 py-3';
|
||||
const marker = createTextElement('span', `mt-1 size-2 rounded-full ${entry.result === 'PASS' ? 'bg-emerald-400' : entry.result === 'FAIL' ? 'bg-rose-400' : 'bg-amber-300'}`, '');
|
||||
const content = document.createElement('div');
|
||||
content.className = 'min-w-0';
|
||||
content.append(
|
||||
createTextElement('p', 'text-sm font-medium text-slate-100', stageLabels[entry.stage] || entry.stage),
|
||||
createTextElement('p', 'mt-0.5 truncate text-xs text-slate-500', entry.reason || 'Stage completed'),
|
||||
);
|
||||
item.append(marker, content, createTextElement('time', 'text-[10px] text-slate-500', formatTime(entry.timestamp)));
|
||||
historyList.append(item);
|
||||
});
|
||||
};
|
||||
|
||||
const renderResult = (loan, history = []) => {
|
||||
const isApproved = loan.status === 'APPROVED';
|
||||
const isStopped = ['REJECTED', 'MANUAL_REVIEW'].includes(loan.status);
|
||||
activeLoanId = loan.loanId;
|
||||
|
||||
document.querySelector('#result-eyebrow').textContent = terminalStatuses.includes(loan.status) ? 'Decision complete' : 'Application ready';
|
||||
document.querySelector('#result-title').textContent = statusLabels[loan.status] || loan.status;
|
||||
document.querySelector('#result-id').textContent = loan.loanId;
|
||||
document.querySelector('#result-icon').innerHTML = icons[isApproved ? 'success' : isStopped ? 'stopped' : 'pending'];
|
||||
processButton.disabled = terminalStatuses.includes(loan.status);
|
||||
processButton.textContent = terminalStatuses.includes(loan.status) ? 'Workflow complete' : 'Run decision workflow';
|
||||
renderSummary(loan);
|
||||
renderHistory(history);
|
||||
resultPanel.classList.remove('hidden');
|
||||
resultPanel.scrollIntoView({behavior: 'smooth', block: 'start'});
|
||||
};
|
||||
|
||||
const loadLoan = async (loanId) => {
|
||||
const [loan, history] = await Promise.all([
|
||||
request(`/api/v1/loans/${encodeURIComponent(loanId)}`),
|
||||
request(`/api/v1/loans/${encodeURIComponent(loanId)}/history`),
|
||||
]);
|
||||
renderResult(loan, history);
|
||||
};
|
||||
|
||||
loanForm.addEventListener('submit', async (event) => {
|
||||
event.preventDefault();
|
||||
clearMessage();
|
||||
|
||||
if (!loanForm.reportValidity()) {
|
||||
return;
|
||||
}
|
||||
|
||||
const formData = new FormData(loanForm);
|
||||
const payload = {
|
||||
customerId: formData.get('customerId'),
|
||||
amount: Number(formData.get('amount')),
|
||||
phone: formData.get('phone'),
|
||||
loanType: formData.get('loanType'),
|
||||
monthlyIncome: Number(formData.get('monthlyIncome')),
|
||||
creditScore: Number(formData.get('creditScore')),
|
||||
hasGuarantor: formData.has('hasGuarantor'),
|
||||
};
|
||||
|
||||
submitButton.disabled = true;
|
||||
submitButton.querySelector('span').textContent = 'Submitting…';
|
||||
|
||||
try {
|
||||
const createdLoan = await request('/api/v1/loans', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
document.querySelector('#lookup-loan-id').value = createdLoan.loanId;
|
||||
await loadLoan(createdLoan.loanId);
|
||||
} catch (error) {
|
||||
showMessage(error.message);
|
||||
} finally {
|
||||
submitButton.disabled = false;
|
||||
submitButton.querySelector('span').textContent = 'Submit application';
|
||||
}
|
||||
});
|
||||
|
||||
lookupForm.addEventListener('submit', async (event) => {
|
||||
event.preventDefault();
|
||||
const loanId = new FormData(lookupForm).get('loanId').trim();
|
||||
|
||||
if (!loanId) {
|
||||
document.querySelector('#lookup-loan-id').focus();
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await loadLoan(loanId);
|
||||
} catch (error) {
|
||||
showMessage(error.message);
|
||||
}
|
||||
});
|
||||
|
||||
processButton.addEventListener('click', async () => {
|
||||
if (!activeLoanId) {
|
||||
return;
|
||||
}
|
||||
|
||||
processButton.disabled = true;
|
||||
processButton.textContent = 'Processing…';
|
||||
|
||||
try {
|
||||
await request(`/api/v1/loans/${encodeURIComponent(activeLoanId)}/process`, {method: 'POST'});
|
||||
await loadLoan(activeLoanId);
|
||||
} catch (error) {
|
||||
showMessage(error.message);
|
||||
processButton.disabled = false;
|
||||
processButton.textContent = 'Run decision workflow';
|
||||
}
|
||||
});
|
||||
}
|
||||
+183
-199
@@ -3,221 +3,205 @@
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="description" content="Create and process a BankFlow loan application.">
|
||||
|
||||
<title>{{ config('app.name', 'Laravel') }}</title>
|
||||
<title>BankFlow — Loan decisions, clearly</title>
|
||||
|
||||
@fonts
|
||||
|
||||
<!-- Styles / Scripts -->
|
||||
@if (file_exists(public_path('build/manifest.json')) || file_exists(public_path('hot')))
|
||||
@vite(['resources/css/app.css', 'resources/js/app.js'])
|
||||
@else
|
||||
<style>
|
||||
/*! tailwindcss v4.0.7 | MIT License | https://tailwindcss.com */ @layer properties{@supports (((-webkit-hyphens:none)) and (not (margin-trim:inline))) or ((-moz-orient:inline) and (not (color:rgb(from red r g b)))){*,:before,:after,::backdrop{--tw-translate-x:0;--tw-translate-y:0;--tw-translate-z:0;--tw-rotate-x:initial;--tw-rotate-y:initial;--tw-rotate-z:initial;--tw-skew-x:initial;--tw-skew-y:initial;--tw-space-x-reverse:0;--tw-border-style:solid;--tw-leading:initial;--tw-font-weight:initial;--tw-tracking:initial;--tw-shadow:0 0 #0000;--tw-shadow-color:initial;--tw-shadow-alpha:100%;--tw-inset-shadow:0 0 #0000;--tw-inset-shadow-color:initial;--tw-inset-shadow-alpha:100%;--tw-ring-color:initial;--tw-ring-shadow:0 0 #0000;--tw-inset-ring-color:initial;--tw-inset-ring-shadow:0 0 #0000;--tw-ring-inset:initial;--tw-ring-offset-width:0px;--tw-ring-offset-color:#fff;--tw-ring-offset-shadow:0 0 #0000;--tw-blur:initial;--tw-brightness:initial;--tw-contrast:initial;--tw-grayscale:initial;--tw-hue-rotate:initial;--tw-invert:initial;--tw-opacity:initial;--tw-saturate:initial;--tw-sepia:initial;--tw-drop-shadow:initial;--tw-drop-shadow-color:initial;--tw-drop-shadow-alpha:100%;--tw-drop-shadow-size:initial;--tw-duration:initial;--tw-ease:initial;--tw-content:""}}}@layer theme{:root,:host{--font-sans:"Instrument Sans", ui-sans-serif, system-ui, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";--font-serif:ui-serif, Georgia, Cambria, "Times New Roman", Times, serif;--font-mono:ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;--color-red-50:oklch(97.1% .013 17.38);--color-red-100:oklch(93.6% .032 17.717);--color-red-200:oklch(88.5% .062 18.334);--color-red-300:oklch(80.8% .114 19.571);--color-red-400:oklch(70.4% .191 22.216);--color-red-500:oklch(63.7% .237 25.331);--color-red-600:oklch(57.7% .245 27.325);--color-red-700:oklch(50.5% .213 27.518);--color-red-800:oklch(44.4% .177 26.899);--color-red-900:oklch(39.6% .141 25.723);--color-red-950:oklch(25.8% .092 26.042);--color-orange-50:oklch(98% .016 73.684);--color-orange-100:oklch(95.4% .038 75.164);--color-orange-200:oklch(90.1% .076 70.697);--color-orange-300:oklch(83.7% .128 66.29);--color-orange-400:oklch(75% .183 55.934);--color-orange-500:oklch(70.5% .213 47.604);--color-orange-600:oklch(64.6% .222 41.116);--color-orange-700:oklch(55.3% .195 38.402);--color-orange-800:oklch(47% .157 37.304);--color-orange-900:oklch(40.8% .123 38.172);--color-orange-950:oklch(26.6% .079 36.259);--color-amber-50:oklch(98.7% .022 95.277);--color-amber-100:oklch(96.2% .059 95.617);--color-amber-200:oklch(92.4% .12 95.746);--color-amber-300:oklch(87.9% .169 91.605);--color-amber-400:oklch(82.8% .189 84.429);--color-amber-500:oklch(76.9% .188 70.08);--color-amber-600:oklch(66.6% .179 58.318);--color-amber-700:oklch(55.5% .163 48.998);--color-amber-800:oklch(47.3% .137 46.201);--color-amber-900:oklch(41.4% .112 45.904);--color-amber-950:oklch(27.9% .077 45.635);--color-yellow-50:oklch(98.7% .026 102.212);--color-yellow-100:oklch(97.3% .071 103.193);--color-yellow-200:oklch(94.5% .129 101.54);--color-yellow-300:oklch(90.5% .182 98.111);--color-yellow-400:oklch(85.2% .199 91.936);--color-yellow-500:oklch(79.5% .184 86.047);--color-yellow-600:oklch(68.1% .162 75.834);--color-yellow-700:oklch(55.4% .135 66.442);--color-yellow-800:oklch(47.6% .114 61.907);--color-yellow-900:oklch(42.1% .095 57.708);--color-yellow-950:oklch(28.6% .066 53.813);--color-lime-50:oklch(98.6% .031 120.757);--color-lime-100:oklch(96.7% .067 122.328);--color-lime-200:oklch(93.8% .127 124.321);--color-lime-300:oklch(89.7% .196 126.665);--color-lime-400:oklch(84.1% .238 128.85);--color-lime-500:oklch(76.8% .233 130.85);--color-lime-600:oklch(64.8% .2 131.684);--color-lime-700:oklch(53.2% .157 131.589);--color-lime-800:oklch(45.3% .124 130.933);--color-lime-900:oklch(40.5% .101 131.063);--color-lime-950:oklch(27.4% .072 132.109);--color-green-50:oklch(98.2% .018 155.826);--color-green-100:oklch(96.2% .044 156.743);--color-green-200:oklch(92.5% .084 155.995);--color-green-300:oklch(87.1% .15 154.449);--color-green-400:oklch(79.2% .209 151.711);--color-green-500:oklch(72.3% .219 149.579);--color-green-600:oklch(62.7% .194 149.214);--color-green-700:oklch(52.7% .154 150.069);--color-green-800:oklch(44.8% .119 151.328);--color-green-900:oklch(39.3% .095 152.535);--color-green-950:oklch(26.6% .065 152.934);--color-emerald-50:oklch(97.9% .021 166.113);--color-emerald-100:oklch(95% .052 163.051);--color-emerald-200:oklch(90.5% .093 164.15);--color-emerald-300:oklch(84.5% .143 164.978);--color-emerald-400:oklch(76.5% .177 163.223);--color-emerald-500:oklch(69.6% .17 162.48);--color-emerald-600:oklch(59.6% .145 163.225);--color-emerald-700:oklch(50.8% .118 165.612);--color-emerald-800:oklch(43.2% .095 166.913);--color-emerald-900:oklch(37.8% .077 168.94);--color-emerald-950:oklch(26.2% .051 172.552);--color-teal-50:oklch(98.
Line truncated
|
||||
</style>
|
||||
@endif
|
||||
</head>
|
||||
<body class="bg-[#FDFDFC] dark:bg-[#0a0a0a] text-[#1b1b18] flex p-6 lg:p-8 items-center lg:justify-center min-h-screen flex-col">
|
||||
<header class="w-full lg:max-w-4xl max-w-[335px] text-sm mb-6 not-has-[nav]:hidden">
|
||||
@if (Route::has('login'))
|
||||
<nav class="flex items-center justify-end gap-4">
|
||||
@auth
|
||||
<a
|
||||
href="{{ url('/dashboard') }}"
|
||||
class="inline-block px-5 py-1.5 dark:text-[#EDEDEC] border-[#19140035] hover:border-[#1915014a] border text-[#1b1b18] dark:border-[#3E3E3A] dark:hover:border-[#62605b] rounded-sm text-sm leading-normal"
|
||||
>
|
||||
Dashboard
|
||||
</a>
|
||||
@else
|
||||
<a
|
||||
href="{{ route('login') }}"
|
||||
class="inline-block px-5 py-1.5 dark:text-[#EDEDEC] text-[#1b1b18] border border-transparent hover:border-[#19140035] dark:hover:border-[#3E3E3A] rounded-sm text-sm leading-normal"
|
||||
>
|
||||
Log in
|
||||
<body class="min-h-screen bg-[#f4f3ee] font-sans text-slate-950 antialiased selection:bg-teal-200 selection:text-teal-950">
|
||||
<div class="pointer-events-none fixed inset-0 overflow-hidden" aria-hidden="true">
|
||||
<div class="absolute -top-32 right-[8%] size-96 rounded-full bg-[#cdeee7]/70 blur-3xl"></div>
|
||||
<div class="absolute -bottom-48 -left-20 size-[32rem] rounded-full bg-[#f5d9a8]/45 blur-3xl"></div>
|
||||
</div>
|
||||
|
||||
<div class="relative mx-auto flex min-h-screen w-full max-w-[1440px] flex-col px-5 py-6 sm:px-8 lg:px-12 lg:py-8">
|
||||
<header class="flex items-center justify-between gap-4">
|
||||
<a href="{{ url('/') }}" class="group inline-flex items-center gap-3" aria-label="BankFlow home">
|
||||
<span class="grid size-10 place-items-center rounded-2xl bg-slate-950 text-white shadow-lg shadow-slate-950/15 transition-transform group-hover:-rotate-3">
|
||||
<svg class="size-5" viewBox="0 0 24 24" fill="none" aria-hidden="true">
|
||||
<path d="M4 17.5 8.2 13l3.1 2.8L20 6.5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
<path d="M15 6.5h5v5" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
|
||||
</svg>
|
||||
</span>
|
||||
<span>
|
||||
<span class="block text-[15px] font-semibold tracking-tight">BankFlow</span>
|
||||
<span class="block text-[10px] font-medium uppercase tracking-[0.22em] text-slate-500">Decision engine</span>
|
||||
</span>
|
||||
</a>
|
||||
|
||||
@if (Route::has('register'))
|
||||
<a
|
||||
href="{{ route('register') }}"
|
||||
class="inline-block px-5 py-1.5 dark:text-[#EDEDEC] border-[#19140035] hover:border-[#1915014a] border text-[#1b1b18] dark:border-[#3E3E3A] dark:hover:border-[#62605b] rounded-sm text-sm leading-normal">
|
||||
Register
|
||||
</a>
|
||||
@endif
|
||||
@endauth
|
||||
</nav>
|
||||
@endif
|
||||
<div id="service-status" data-health-url="{{ route('health') }}" class="flex items-center gap-2 rounded-full border border-white/80 bg-white/65 px-3 py-2 text-xs font-medium text-slate-600 shadow-sm backdrop-blur-xl" aria-live="polite">
|
||||
<span class="relative flex size-2">
|
||||
<span id="service-status-pulse" class="absolute inline-flex size-full animate-ping rounded-full bg-slate-400 opacity-60"></span>
|
||||
<span id="service-status-dot" class="relative inline-flex size-2 rounded-full bg-slate-400"></span>
|
||||
</span>
|
||||
<span id="service-status-label">Checking service</span>
|
||||
</div>
|
||||
</header>
|
||||
<div class="flex items-center justify-center w-full transition-opacity opacity-100 duration-750 lg:grow starting:opacity-0">
|
||||
<main class="flex max-w-[335px] w-full flex-col-reverse lg:max-w-4xl lg:flex-row">
|
||||
<div class="text-[13px] leading-[20px] flex-1 p-6 pb-6 lg:p-20 lg:pb-10 bg-white dark:bg-[#161615] dark:text-[#EDEDEC] shadow-[inset_0px_0px_0px_1px_rgba(26,26,0,0.16)] dark:shadow-[inset_0px_0px_0px_1px_#fffaed2d] rounded-bl-lg rounded-br-lg lg:rounded-tl-lg lg:rounded-br-none">
|
||||
<h1 class="mb-1 font-medium">Let's get started</h1>
|
||||
<p class="mb-2 text-[#706f6c] dark:text-[#A1A09A]">With so many options available to you,<br /> we suggest you start with the following:</p>
|
||||
<ul class="flex flex-col mb-4 lg:mb-6">
|
||||
<li class="flex items-center gap-4 py-2 relative before:border-l before:border-[#e3e3e0] dark:before:border-[#3E3E3A] before:top-1/2 before:bottom-0 before:left-[0.4rem] before:absolute">
|
||||
<span class="relative py-1 bg-white dark:bg-[#161615]">
|
||||
<span class="flex items-center justify-center rounded-full bg-[#FDFDFC] dark:bg-[#161615] shadow-[0px_0px_1px_0px_rgba(0,0,0,0.03),0px_1px_2px_0px_rgba(0,0,0,0.06)] w-3.5 h-3.5 border dark:border-[#3E3E3A] border-[#e3e3e0]">
|
||||
<span class="rounded-full bg-[#dbdbd7] dark:bg-[#3E3E3A] w-1.5 h-1.5"></span>
|
||||
</span>
|
||||
</span>
|
||||
<span>
|
||||
Read the
|
||||
<a href="https://laravel.com/docs" target="_blank" class="inline-flex items-center space-x-1 font-medium underline underline-offset-4 text-[#f53003] dark:text-[#FF4433] ml-1">
|
||||
<span>Documentation</span>
|
||||
<svg
|
||||
width="10"
|
||||
height="11"
|
||||
viewBox="0 0 10 11"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="w-2.5 h-2.5"
|
||||
>
|
||||
<path
|
||||
d="M7.70833 6.95834V2.79167H3.54167M2.5 8L7.5 3.00001"
|
||||
stroke="currentColor"
|
||||
stroke-linecap="square"
|
||||
/>
|
||||
</svg>
|
||||
</a>
|
||||
</span>
|
||||
</li>
|
||||
<li class="flex items-center gap-4 py-2 relative before:border-l before:border-[#e3e3e0] dark:before:border-[#3E3E3A] before:bottom-1/2 before:top-0 before:left-[0.4rem] before:absolute">
|
||||
<span class="relative py-1 bg-white dark:bg-[#161615]">
|
||||
<span class="flex items-center justify-center rounded-full bg-[#FDFDFC] dark:bg-[#161615] shadow-[0px_0px_1px_0px_rgba(0,0,0,0.03),0px_1px_2px_0px_rgba(0,0,0,0.06)] w-3.5 h-3.5 border dark:border-[#3E3E3A] border-[#e3e3e0]">
|
||||
<span class="rounded-full bg-[#dbdbd7] dark:bg-[#3E3E3A] w-1.5 h-1.5"></span>
|
||||
</span>
|
||||
</span>
|
||||
<span>
|
||||
Watch video tutorials at
|
||||
<a href="https://laracasts.com" target="_blank" class="inline-flex items-center space-x-1 font-medium underline underline-offset-4 text-[#f53003] dark:text-[#FF4433] ml-1">
|
||||
<span>Laracasts</span>
|
||||
<svg
|
||||
width="10"
|
||||
height="11"
|
||||
viewBox="0 0 10 11"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="w-2.5 h-2.5"
|
||||
>
|
||||
<path
|
||||
d="M7.70833 6.95834V2.79167H3.54167M2.5 8L7.5 3.00001"
|
||||
stroke="currentColor"
|
||||
stroke-linecap="square"
|
||||
/>
|
||||
</svg>
|
||||
</a>
|
||||
</span>
|
||||
</li>
|
||||
</ul>
|
||||
<ul class="flex gap-3 text-sm leading-normal">
|
||||
<li>
|
||||
<a href="https://cloud.laravel.com" target="_blank" class="inline-block dark:bg-[#eeeeec] dark:border-[#eeeeec] dark:text-[#1C1C1A] dark:hover:bg-white dark:hover:border-white hover:bg-black hover:border-black px-5 py-1.5 bg-[#1b1b18] rounded-sm border border-black text-white text-sm leading-normal">
|
||||
Deploy now
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<p class="mt-6 lg:mt-10 text-[#706f6c] dark:text-[#A1A09A]">
|
||||
v{{ app()->version() }}
|
||||
<a href="https://github.com/laravel/framework/blob/13.x/CHANGELOG.md" target="_blank" class="inline-flex items-center space-x-1 font-medium underline underline-offset-4 text-[#f53003] dark:text-[#FF4433] ml-1">
|
||||
<span>View changelog</span>
|
||||
<svg
|
||||
width="10"
|
||||
height="11"
|
||||
viewBox="0 0 10 11"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
class="w-2.5 h-2.5"
|
||||
>
|
||||
<path
|
||||
d="M7.70833 6.95834V2.79167H3.54167M2.5 8L7.5 3.00001"
|
||||
stroke="currentColor"
|
||||
stroke-linecap="square"
|
||||
/>
|
||||
</svg>
|
||||
</a>
|
||||
<main class="grid flex-1 items-center gap-10 py-12 lg:grid-cols-[0.8fr_1.2fr] lg:gap-16 lg:py-10">
|
||||
<section class="max-w-xl">
|
||||
<div class="mb-6 inline-flex items-center gap-2 rounded-full border border-slate-900/10 bg-white/55 px-3 py-1.5 text-xs font-semibold uppercase tracking-[0.16em] text-teal-800 backdrop-blur">
|
||||
<span>Simple in</span>
|
||||
<span class="text-slate-300">/</span>
|
||||
<span>Clear out</span>
|
||||
</div>
|
||||
|
||||
<h1 class="max-w-lg text-5xl font-semibold leading-[0.95] tracking-[-0.055em] text-slate-950 sm:text-6xl lg:text-7xl">
|
||||
A loan journey you can see.
|
||||
</h1>
|
||||
<p class="mt-6 max-w-md text-base leading-7 text-slate-600 sm:text-lg">
|
||||
Submit an application, run the decision workflow, and follow every stage from validation to outcome.
|
||||
</p>
|
||||
|
||||
<div class="mt-9 flex items-center gap-3 text-xs font-medium text-slate-500">
|
||||
<span class="grid size-7 place-items-center rounded-full border border-slate-300 bg-white/60 text-slate-800">1</span>
|
||||
<span>Submit</span>
|
||||
<span class="h-px w-7 bg-slate-300"></span>
|
||||
<span class="grid size-7 place-items-center rounded-full border border-slate-300 bg-white/60 text-slate-800">2</span>
|
||||
<span>Process</span>
|
||||
<span class="h-px w-7 bg-slate-300"></span>
|
||||
<span class="grid size-7 place-items-center rounded-full border border-slate-300 bg-white/60 text-slate-800">3</span>
|
||||
<span>Review</span>
|
||||
</div>
|
||||
<div class="bg-[#fff2f2] dark:bg-[#1D0002] relative lg:-ml-px -mb-px lg:mb-0 rounded-t-lg lg:rounded-t-none lg:rounded-r-lg aspect-[335/364] lg:aspect-auto w-full lg:w-[438px] shrink-0 overflow-hidden">
|
||||
{{-- Laravel Logo --}}
|
||||
<svg class="w-full text-[#F53003] dark:text-[#F61500] transition-all translate-y-0 opacity-100 max-w-none duration-750 starting:opacity-0 motion-safe:starting:translate-y-6" viewBox="0 0 438 104" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M17.2036 -3H0V102.197H49.5189V86.7187H17.2036V-3Z" fill="currentColor" />
|
||||
<path d="M110.256 41.6337C108.061 38.1275 104.945 35.3731 100.905 33.3681C96.8667 31.3647 92.8016 30.3618 88.7131 30.3618C83.4247 30.3618 78.5885 31.3389 74.201 33.2923C69.8111 35.2456 66.0474 37.928 62.9059 41.3333C59.7643 44.7401 57.3198 48.6726 55.5754 53.1293C53.8287 57.589 52.9572 62.274 52.9572 67.1813C52.9572 72.1925 53.8287 76.8995 55.5754 81.3069C57.3191 85.7173 59.7636 89.6241 62.9059 93.0293C66.0474 96.4361 69.8119 99.1155 74.201 101.069C78.5885 103.022 83.4247 103.999 88.7131 103.999C92.8016 103.999 96.8667 102.997 100.905 100.994C104.945 98.9911 108.061 96.2359 110.256 92.7282V102.195H126.563V32.1642H110.256V41.6337ZM108.76 75.7472C107.762 78.4531 106.366 80.8078 104.572 82.8112C102.776 84.8161 100.606 86.4183 98.0637 87.6206C95.5202 88.823 92.7004 89.4238 89.6103 89.4238C86.5178 89.4238 83.7252 88.823 81.2324 87.6206C78.7388 86.4183 76.5949 84.8161 74.7998 82.8112C73.004 80.8078 71.6319 78.4531 70.6856 75.7472C69.7356 73.0421 69.2644 70.1868 69.2644 67.1821C69.2644 64.1758 69.7356 61.3205 70.6856 58.6154C71.6319 55.9102 73.004 53.5571 74.7998 51.5522C76.5949 49.5495 78.738 47.9451 81.2324 46.7427C83.7252 45.5404 86.5178 44.9396 89.6103 44.9396C92.7012 44.9396 95.5202 45.5404 98.0637 46.7427C100.606 47.9451 102.776 49.5487 104.572 51.5522C106.367 53.5571 107.762 55.9102 108.76 58.6154C109.756 61.3205 110.256 64.1758 110.256 67.1821C110.256 70.1868 109.756 73.0421 108.76 75.7472Z" fill="currentColor" />
|
||||
<path d="M242.805 41.6337C240.611 38.1275 237.494 35.3731 233.455 33.3681C229.416 31.3647 225.351 30.3618 221.262 30.3618C215.974 30.3618 211.138 31.3389 206.75 33.2923C202.36 35.2456 198.597 37.928 195.455 41.3333C192.314 44.7401 189.869 48.6726 188.125 53.1293C186.378 57.589 185.507 62.274 185.507 67.1813C185.507 72.1925 186.378 76.8995 188.125 81.3069C189.868 85.7173 192.313 89.6241 195.455 93.0293C198.597 96.4361 202.361 99.1155 206.75 101.069C211.138 103.022 215.974 103.999 221.262 103.999C225.351 103.999 229.416 102.997 233.455 100.994C237.494 98.9911 240.611 96.2359 242.805 92.7282V102.195H259.112V32.1642H242.805V41.6337ZM241.31 75.7472C240.312 78.4531 238.916 80.8078 237.122 82.8112C235.326 84.8161 233.156 86.4183 230.614 87.6206C228.07 88.823 225.251 89.4238 222.16 89.4238C219.068 89.4238 216.275 88.823 213.782 87.6206C211.289 86.4183 209.145 84.8161 207.35 82.8112C205.554 80.8078 204.182 78.4531 203.236 75.7472C202.286 73.0421 201.814 70.1868 201.814 67.1821C201.814 64.1758 202.286 61.3205 203.236 58.6154C204.182 55.9102 205.554 53.5571 207.35 51.5522C209.145 49.5495 211.288 47.9451 213.782 46.7427C216.275 45.5404 219.068 44.9396 222.16 44.9396C225.251 44.9396 228.07 45.5404 230.614 46.7427C233.156 47.9451 235.326 49.5487 237.122 51.5522C238.917 53.5571 240.312 55.9102 241.31 58.6154C242.306 61.3205 242.806 64.1758 242.806 67.1821C242.805 70.1868 242.305 73.0421 241.31 75.7472Z" fill="currentColor" />
|
||||
<path d="M438 -3H421.694V102.197H438V-3Z" fill="currentColor" />
|
||||
<path d="M139.43 102.197H155.735V48.2834H183.712V32.1665H139.43V102.197Z" fill="currentColor" />
|
||||
<path d="M324.49 32.1665L303.995 85.794L283.498 32.1665H266.983L293.748 102.197H314.242L341.006 32.1665H324.49Z" fill="currentColor" />
|
||||
<path d="M376.571 30.3656C356.603 30.3656 340.797 46.8497 340.797 67.1828C340.797 89.6597 356.094 104 378.661 104C391.29 104 399.354 99.1488 409.206 88.5848L398.189 80.0226C398.183 80.031 389.874 90.9895 377.468 90.9895C363.048 90.9895 356.977 79.3111 356.977 73.269H411.075C413.917 50.1328 398.775 30.3656 376.571 30.3656ZM357.02 61.0967C357.145 59.7487 359.023 43.3761 376.442 43.3761C393.861 43.3761 395.978 59.7464 396.099 61.0967H357.02Z" fill="currentColor" />
|
||||
</svg>
|
||||
|
||||
{{-- 13 --}}
|
||||
<svg class="w-[438px] max-w-none relative -mt-[6.6rem] -ml-8 lg:ml-0 [--stroke-color:#1B1B18] dark:[--stroke-color:#FF750F]" viewBox="0 0 440 392" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g class="mix-blend-darken dark:mix-blend-normal transition-all delay-300 opacity-100 duration-750 starting:opacity-0 text-[#1B1B18] dark:text-black">
|
||||
<mask id="path-1-mask" maskUnits="userSpaceOnUse" x="-0.328613" y="103" width="338" height="299" fill="black">
|
||||
<rect fill="white" x="-0.328613" y="103" width="338" height="299"/>
|
||||
<path d="M234.936 400.8C204.136 400.8 178.936 392.4 159.336 375.6C140.136 358.8 130.536 337 130.536 310.2H200.736C200.736 318.2 203.736 324.8 209.736 330C215.736 335.2 223.736 337.8 233.736 337.8C243.336 337.8 251.136 335 257.136 329.4C263.536 323.8 266.736 316.6 266.736 307.8C266.736 299.8 263.936 293.2 258.336 288C252.736 282.8 245.536 280.2 236.736 280.2H199.536V218.4H236.736C243.536 218.4 249.336 216 254.136 211.2C258.936 206.4 261.336 200.4 261.336 193.2C261.336 184.8 258.736 178.2 253.536 173.4C248.336 168.6 241.736 166.2 233.736 166.2C226.536 166.2 220.336 168.4 215.136 172.8C210.336 177.2 207.936 182.8 207.936 189.6H141.336C141.336 164.8 150.136 144.6 167.736 129C185.336 113 207.936 105 235.536 105C263.136 105 285.536 112.2 302.736 126.6C320.336 141 329.136 160 329.136 183.6C329.136 200.8 324.536 214.8 315.336 225.6C306.136 236 294.336 243.2 279.936 247.2C297.136 252 310.736 260.2 320.736 271.8C331.136 283.4 336.336 298 336.336 315.6C336.336 340.4 326.936 360.8 308.136 376.8C289.336 392.8 264.936 400.8 234.936 400.8Z"/>
|
||||
<path d="M26.8714 167.6H1.67139V105.2H94.6714V400.2H26.8714V167.6Z"/>
|
||||
</mask>
|
||||
<path d="M234.936 400.8C204.136 400.8 178.936 392.4 159.336 375.6C140.136 358.8 130.536 337 130.536 310.2H200.736C200.736 318.2 203.736 324.8 209.736 330C215.736 335.2 223.736 337.8 233.736 337.8C243.336 337.8 251.136 335 257.136 329.4C263.536 323.8 266.736 316.6 266.736 307.8C266.736 299.8 263.936 293.2 258.336 288C252.736 282.8 245.536 280.2 236.736 280.2H199.536V218.4H236.736C243.536 218.4 249.336 216 254.136 211.2C258.936 206.4 261.336 200.4 261.336 193.2C261.336 184.8 258.736 178.2 253.536 173.4C248.336 168.6 241.736 166.2 233.736 166.2C226.536 166.2 220.336 168.4 215.136 172.8C210.336 177.2 207.936 182.8 207.936 189.6H141.336C141.336 164.8 150.136 144.6 167.736 129C185.336 113 207.936 105 235.536 105C263.136 105 285.536 112.2 302.736 126.6C320.336 141 329.136 160 329.136 183.6C329.136 200.8 324.536 214.8 315.336 225.6C306.136 236 294.336 243.2 279.936 247.2C297.136 252 310.736 260.2 320.736 271.8C331.136 283.4 336.336 298 336.336 315.6C336.336 340.4 326.936 360.8 308.136 376.8C289.336 392.8 264.936 400.8 234.936 400.8Z" fill="currentColor"/>
|
||||
<path d="M26.8714 167.6H1.67139V105.2H94.6714V400.2H26.8714V167.6Z" fill="currentColor"/>
|
||||
<path d="M234.936 400.8C204.136 400.8 178.936 392.4 159.336 375.6C140.136 358.8 130.536 337 130.536 310.2H200.736C200.736 318.2 203.736 324.8 209.736 330C215.736 335.2 223.736 337.8 233.736 337.8C243.336 337.8 251.136 335 257.136 329.4C263.536 323.8 266.736 316.6 266.736 307.8C266.736 299.8 263.936 293.2 258.336 288C252.736 282.8 245.536 280.2 236.736 280.2H199.536V218.4H236.736C243.536 218.4 249.336 216 254.136 211.2C258.936 206.4 261.336 200.4 261.336 193.2C261.336 184.8 258.736 178.2 253.536 173.4C248.336 168.6 241.736 166.2 233.736 166.2C226.536 166.2 220.336 168.4 215.136 172.8C210.336 177.2 207.936 182.8 207.936 189.6H141.336C141.336 164.8 150.136 144.6 167.736 129C185.336 113 207.936 105 235.536 105C263.136 105 285.536 112.2 302.736 126.6C320.336 141 329.136 160 329.136 183.6C329.136 200.8 324.536 214.8 315.336 225.6C306.136 236 294.336 243.2 279.936 247.2C297.136 252 310.736 260.2 320.736 271.8C331.136 283.4 336.336 298 336.336 315.6C336.336 340.4 326.936 360.8 308.136 376.8C289.336 392.8 264.936 400.8 234.936 400.8Z" stroke="var(--stroke-color)" stroke-width="2.4" mask="url(#path-1-mask)"/>
|
||||
<path d="M26.8714 167.6H1.67139V105.2H94.6714V400.2H26.8714V167.6Z" stroke="var(--stroke-color)" stroke-width="2.4" mask="url(#path-1-mask)"/>
|
||||
</g>
|
||||
<form id="lookup-form" class="mt-10 flex max-w-md gap-2" novalidate>
|
||||
<label for="lookup-loan-id" class="sr-only">Existing loan ID</label>
|
||||
<input id="lookup-loan-id" name="loanId" type="text" autocomplete="off" placeholder="Already applied? Enter loan ID" class="min-w-0 flex-1 rounded-2xl border border-slate-900/10 bg-white/65 px-4 py-3 text-sm shadow-sm outline-none backdrop-blur placeholder:text-slate-400 focus:border-teal-600 focus:ring-4 focus:ring-teal-600/10">
|
||||
<button type="submit" class="rounded-2xl bg-slate-950 px-5 py-3 text-sm font-semibold text-white shadow-lg shadow-slate-950/10 transition hover:-translate-y-0.5 hover:bg-teal-800 focus:outline-none focus:ring-4 focus:ring-teal-600/20">
|
||||
Find
|
||||
</button>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<g class="transition-all delay-400 opacity-100 duration-750 starting:opacity-0 motion-safe:starting:-translate-x-[26px] text-[#F3BEC7] dark:text-[#4B0600]">
|
||||
<mask id="path-2-mask" maskUnits="userSpaceOnUse" x="25.3357" y="103" width="338" height="299" fill="black">
|
||||
<rect fill="white" x="25.3357" y="103" width="338" height="299"/>
|
||||
<path d="M260.6 400.8C229.8 400.8 204.6 392.4 185 375.6C165.8 358.8 156.2 337 156.2 310.2H226.4C226.4 318.2 229.4 324.8 235.4 330C241.4 335.2 249.4 337.8 259.4 337.8C269 337.8 276.8 335 282.8 329.4C289.2 323.8 292.4 316.6 292.4 307.8C292.4 299.8 289.6 293.2 284 288C278.4 282.8 271.2 280.2 262.4 280.2H225.2V218.4H262.4C269.2 218.4 275 216 279.8 211.2C284.6 206.4 287 200.4 287 193.2C287 184.8 284.4 178.2 279.2 173.4C274 168.6 267.4 166.2 259.4 166.2C252.2 166.2 246 168.4 240.8 172.8C236 177.2 233.6 182.8 233.6 189.6H167C167 164.8 175.8 144.6 193.4 129C211 113 233.6 105 261.2 105C288.8 105 311.2 112.2 328.4 126.6C346 141 354.8 160 354.8 183.6C354.8 200.8 350.2 214.8 341 225.6C331.8 236 320 243.2 305.6 247.2C322.8 252 336.4 260.2 346.4 271.8C356.8 283.4 362 298 362 315.6C362 340.4 352.6 360.8 333.8 376.8C315 392.8 290.6 400.8 260.6 400.8Z"/>
|
||||
<path d="M52.5357 167.6H27.3357V105.2H120.336V400.2H52.5357V167.6Z"/>
|
||||
</mask>
|
||||
<path d="M260.6 400.8C229.8 400.8 204.6 392.4 185 375.6C165.8 358.8 156.2 337 156.2 310.2H226.4C226.4 318.2 229.4 324.8 235.4 330C241.4 335.2 249.4 337.8 259.4 337.8C269 337.8 276.8 335 282.8 329.4C289.2 323.8 292.4 316.6 292.4 307.8C292.4 299.8 289.6 293.2 284 288C278.4 282.8 271.2 280.2 262.4 280.2H225.2V218.4H262.4C269.2 218.4 275 216 279.8 211.2C284.6 206.4 287 200.4 287 193.2C287 184.8 284.4 178.2 279.2 173.4C274 168.6 267.4 166.2 259.4 166.2C252.2 166.2 246 168.4 240.8 172.8C236 177.2 233.6 182.8 233.6 189.6H167C167 164.8 175.8 144.6 193.4 129C211 113 233.6 105 261.2 105C288.8 105 311.2 112.2 328.4 126.6C346 141 354.8 160 354.8 183.6C354.8 200.8 350.2 214.8 341 225.6C331.8 236 320 243.2 305.6 247.2C322.8 252 336.4 260.2 346.4 271.8C356.8 283.4 362 298 362 315.6C362 340.4 352.6 360.8 333.8 376.8C315 392.8 290.6 400.8 260.6 400.8Z" fill="currentColor"/>
|
||||
<path d="M52.5357 167.6H27.3357V105.2H120.336V400.2H52.5357V167.6Z" fill="currentColor"/>
|
||||
<path d="M260.6 400.8C229.8 400.8 204.6 392.4 185 375.6C165.8 358.8 156.2 337 156.2 310.2H226.4C226.4 318.2 229.4 324.8 235.4 330C241.4 335.2 249.4 337.8 259.4 337.8C269 337.8 276.8 335 282.8 329.4C289.2 323.8 292.4 316.6 292.4 307.8C292.4 299.8 289.6 293.2 284 288C278.4 282.8 271.2 280.2 262.4 280.2H225.2V218.4H262.4C269.2 218.4 275 216 279.8 211.2C284.6 206.4 287 200.4 287 193.2C287 184.8 284.4 178.2 279.2 173.4C274 168.6 267.4 166.2 259.4 166.2C252.2 166.2 246 168.4 240.8 172.8C236 177.2 233.6 182.8 233.6 189.6H167C167 164.8 175.8 144.6 193.4 129C211 113 233.6 105 261.2 105C288.8 105 311.2 112.2 328.4 126.6C346 141 354.8 160 354.8 183.6C354.8 200.8 350.2 214.8 341 225.6C331.8 236 320 243.2 305.6 247.2C322.8 252 336.4 260.2 346.4 271.8C356.8 283.4 362 298 362 315.6C362 340.4 352.6 360.8 333.8 376.8C315 392.8 290.6 400.8 260.6 400.8Z" stroke="var(--stroke-color)" stroke-width="2.4" mask="url(#path-2-mask)"/>
|
||||
<path d="M52.5357 167.6H27.3357V105.2H120.336V400.2H52.5357V167.6Z" stroke="var(--stroke-color)" stroke-width="2.4" mask="url(#path-2-mask)"/>
|
||||
</g>
|
||||
|
||||
<g class="mix-blend-color dark:mix-blend-hard-light transition-all delay-400 opacity-100 duration-750 starting:opacity-0 motion-safe:starting:-translate-x-[51px] text-[#F8B803] dark:text-[#391800]">
|
||||
<mask id="path-3-mask" maskUnits="userSpaceOnUse" x="51" y="103" width="338" height="299" fill="black">
|
||||
<rect fill="white" x="51" y="103" width="338" height="299"/>
|
||||
<path d="M286.264 400.8C255.464 400.8 230.264 392.4 210.664 375.6C191.464 358.8 181.864 337 181.864 310.2H252.064C252.064 318.2 255.064 324.8 261.064 330C267.064 335.2 275.064 337.8 285.064 337.8C294.664 337.8 302.464 335 308.464 329.4C314.864 323.8 318.064 316.6 318.064 307.8C318.064 299.8 315.264 293.2 309.664 288C304.064 282.8 296.864 280.2 288.064 280.2H250.864V218.4H288.064C294.864 218.4 300.664 216 305.464 211.2C310.264 206.4 312.664 200.4 312.664 193.2C312.664 184.8 310.064 178.2 304.864 173.4C299.664 168.6 293.064 166.2 285.064 166.2C277.864 166.2 271.664 168.4 266.464 172.8C261.664 177.2 259.264 182.8 259.264 189.6H192.664C192.664 164.8 201.464 144.6 219.064 129C236.664 113 259.264 105 286.864 105C314.464 105 336.864 112.2 354.064 126.6C371.664 141 380.464 160 380.464 183.6C380.464 200.8 375.864 214.8 366.664 225.6C357.464 236 345.664 243.2 331.264 247.2C348.464 252 362.064 260.2 372.064 271.8C382.464 283.4 387.664 298 387.664 315.6C387.664 340.4 378.264 360.8 359.464 376.8C340.664 392.8 316.264 400.8 286.264 400.8Z"/>
|
||||
<path d="M78.2 167.6H53V105.2H146V400.2H78.2V167.6Z"/>
|
||||
</mask>
|
||||
<path d="M286.264 400.8C255.464 400.8 230.264 392.4 210.664 375.6C191.464 358.8 181.864 337 181.864 310.2H252.064C252.064 318.2 255.064 324.8 261.064 330C267.064 335.2 275.064 337.8 285.064 337.8C294.664 337.8 302.464 335 308.464 329.4C314.864 323.8 318.064 316.6 318.064 307.8C318.064 299.8 315.264 293.2 309.664 288C304.064 282.8 296.864 280.2 288.064 280.2H250.864V218.4H288.064C294.864 218.4 300.664 216 305.464 211.2C310.264 206.4 312.664 200.4 312.664 193.2C312.664 184.8 310.064 178.2 304.864 173.4C299.664 168.6 293.064 166.2 285.064 166.2C277.864 166.2 271.664 168.4 266.464 172.8C261.664 177.2 259.264 182.8 259.264 189.6H192.664C192.664 164.8 201.464 144.6 219.064 129C236.664 113 259.264 105 286.864 105C314.464 105 336.864 112.2 354.064 126.6C371.664 141 380.464 160 380.464 183.6C380.464 200.8 375.864 214.8 366.664 225.6C357.464 236 345.664 243.2 331.264 247.2C348.464 252 362.064 260.2 372.064 271.8C382.464 283.4 387.664 298 387.664 315.6C387.664 340.4 378.264 360.8 359.464 376.8C340.664 392.8 316.264 400.8 286.264 400.8Z" fill="currentColor"/>
|
||||
<path d="M78.2 167.6H53V105.2H146V400.2H78.2V167.6Z" fill="currentColor"/>
|
||||
<path d="M286.264 400.8C255.464 400.8 230.264 392.4 210.664 375.6C191.464 358.8 181.864 337 181.864 310.2H252.064C252.064 318.2 255.064 324.8 261.064 330C267.064 335.2 275.064 337.8 285.064 337.8C294.664 337.8 302.464 335 308.464 329.4C314.864 323.8 318.064 316.6 318.064 307.8C318.064 299.8 315.264 293.2 309.664 288C304.064 282.8 296.864 280.2 288.064 280.2H250.864V218.4H288.064C294.864 218.4 300.664 216 305.464 211.2C310.264 206.4 312.664 200.4 312.664 193.2C312.664 184.8 310.064 178.2 304.864 173.4C299.664 168.6 293.064 166.2 285.064 166.2C277.864 166.2 271.664 168.4 266.464 172.8C261.664 177.2 259.264 182.8 259.264 189.6H192.664C192.664 164.8 201.464 144.6 219.064 129C236.664 113 259.264 105 286.864 105C314.464 105 336.864 112.2 354.064 126.6C371.664 141 380.464 160 380.464 183.6C380.464 200.8 375.864 214.8 366.664 225.6C357.464 236 345.664 243.2 331.264 247.2C348.464 252 362.064 260.2 372.064 271.8C382.464 283.4 387.664 298 387.664 315.6C387.664 340.4 378.264 360.8 359.464 376.8C340.664 392.8 316.264 400.8 286.264 400.8Z" stroke="var(--stroke-color)" stroke-width="2.4" mask="url(#path-3-mask)"/>
|
||||
<path d="M78.2 167.6H53V105.2H146V400.2H78.2V167.6Z" stroke="var(--stroke-color)" stroke-width="2.4" mask="url(#path-3-mask)"/>
|
||||
</g>
|
||||
|
||||
<g class="mix-blend-multiply dark:mix-blend-normal transition-all delay-400 opacity-100 duration-750 starting:opacity-0 motion-safe:starting:-translate-x-[78px] text-[#F3BEC7] dark:text-[#733000]">
|
||||
<mask id="path-4-mask" maskUnits="userSpaceOnUse" x="76.6643" y="103" width="338" height="299" fill="black">
|
||||
<rect fill="white" x="76.6643" y="103" width="338" height="299"/>
|
||||
<path d="M311.929 400.8C281.129 400.8 255.929 392.4 236.329 375.6C217.129 358.8 207.529 337 207.529 310.2H277.729C277.729 318.2 280.729 324.8 286.729 330C292.729 335.2 300.729 337.8 310.729 337.8C320.329 337.8 328.129 335 334.129 329.4C340.529 323.8 343.729 316.6 343.729 307.8C343.729 299.8 340.929 293.2 335.329 288C329.729 282.8 322.529 280.2 313.729 280.2H276.529V218.4H313.729C320.529 218.4 326.329 216 331.129 211.2C335.929 206.4 338.329 200.4 338.329 193.2C338.329 184.8 335.729 178.2 330.529 173.4C325.329 168.6 318.729 166.2 310.729 166.2C303.529 166.2 297.329 168.4 292.129 172.8C287.329 177.2 284.929 182.8 284.929 189.6H218.329C218.329 164.8 227.129 144.6 244.729 129C262.329 113 284.929 105 312.529 105C340.129 105 362.529 112.2 379.729 126.6C397.329 141 406.129 160 406.129 183.6C406.129 200.8 401.529 214.8 392.329 225.6C383.129 236 371.329 243.2 356.929 247.2C374.129 252 387.729 260.2 397.729 271.8C408.129 283.4 413.329 298 413.329 315.6C413.329 340.4 403.929 360.8 385.129 376.8C366.329 392.8 341.929 400.8 311.929 400.8Z"/>
|
||||
<path d="M103.864 167.6H78.6643V105.2H171.664V400.2H103.864V167.6Z"/>
|
||||
</mask>
|
||||
<path d="M311.929 400.8C281.129 400.8 255.929 392.4 236.329 375.6C217.129 358.8 207.529 337 207.529 310.2H277.729C277.729 318.2 280.729 324.8 286.729 330C292.729 335.2 300.729 337.8 310.729 337.8C320.329 337.8 328.129 335 334.129 329.4C340.529 323.8 343.729 316.6 343.729 307.8C343.729 299.8 340.929 293.2 335.329 288C329.729 282.8 322.529 280.2 313.729 280.2H276.529V218.4H313.729C320.529 218.4 326.329 216 331.129 211.2C335.929 206.4 338.329 200.4 338.329 193.2C338.329 184.8 335.729 178.2 330.529 173.4C325.329 168.6 318.729 166.2 310.729 166.2C303.529 166.2 297.329 168.4 292.129 172.8C287.329 177.2 284.929 182.8 284.929 189.6H218.329C218.329 164.8 227.129 144.6 244.729 129C262.329 113 284.929 105 312.529 105C340.129 105 362.529 112.2 379.729 126.6C397.329 141 406.129 160 406.129 183.6C406.129 200.8 401.529 214.8 392.329 225.6C383.129 236 371.329 243.2 356.929 247.2C374.129 252 387.729 260.2 397.729 271.8C408.129 283.4 413.329 298 413.329 315.6C413.329 340.4 403.929 360.8 385.129 376.8C366.329 392.8 341.929 400.8 311.929 400.8Z" fill="currentColor"/>
|
||||
<path d="M103.864 167.6H78.6643V105.2H171.664V400.2H103.864V167.6Z" fill="currentColor"/>
|
||||
<path d="M311.929 400.8C281.129 400.8 255.929 392.4 236.329 375.6C217.129 358.8 207.529 337 207.529 310.2H277.729C277.729 318.2 280.729 324.8 286.729 330C292.729 335.2 300.729 337.8 310.729 337.8C320.329 337.8 328.129 335 334.129 329.4C340.529 323.8 343.729 316.6 343.729 307.8C343.729 299.8 340.929 293.2 335.329 288C329.729 282.8 322.529 280.2 313.729 280.2H276.529V218.4H313.729C320.529 218.4 326.329 216 331.129 211.2C335.929 206.4 338.329 200.4 338.329 193.2C338.329 184.8 335.729 178.2 330.529 173.4C325.329 168.6 318.729 166.2 310.729 166.2C303.529 166.2 297.329 168.4 292.129 172.8C287.329 177.2 284.929 182.8 284.929 189.6H218.329C218.329 164.8 227.129 144.6 244.729 129C262.329 113 284.929 105 312.529 105C340.129 105 362.529 112.2 379.729 126.6C397.329 141 406.129 160 406.129 183.6C406.129 200.8 401.529 214.8 392.329 225.6C383.129 236 371.329 243.2 356.929 247.2C374.129 252 387.729 260.2 397.729 271.8C408.129 283.4 413.329 298 413.329 315.6C413.329 340.4 403.929 360.8 385.129 376.8C366.329 392.8 341.929 400.8 311.929 400.8Z" stroke="var(--stroke-color)" stroke-width="2.4" mask="url(#path-4-mask)"/>
|
||||
<path d="M103.864 167.6H78.6643V105.2H171.664V400.2H103.864V167.6Z" stroke="var(--stroke-color)" stroke-width="2.4" mask="url(#path-4-mask)"/>
|
||||
</g>
|
||||
|
||||
<g class="mix-blend-hard-light transition-all delay-400 opacity-100 duration-750 starting:opacity-0 motion-safe:starting:-translate-x-[102px] text-[#F3BEC7] dark:text-[#4B0600]">
|
||||
<mask id="path-5-mask" maskUnits="userSpaceOnUse" x="102.329" y="103" width="338" height="299" fill="black">
|
||||
<rect fill="white" x="102.329" y="103" width="338" height="299"/>
|
||||
<path d="M337.593 400.8C306.793 400.8 281.593 392.4 261.993 375.6C242.793 358.8 233.193 337 233.193 310.2H303.393C303.393 318.2 306.393 324.8 312.393 330C318.393 335.2 326.393 337.8 336.393 337.8C345.993 337.8 353.793 335 359.793 329.4C366.193 323.8 369.393 316.6 369.393 307.8C369.393 299.8 366.593 293.2 360.993 288C355.393 282.8 348.193 280.2 339.393 280.2H302.193V218.4H339.393C346.193 218.4 351.993 216 356.793 211.2C361.593 206.4 363.993 200.4 363.993 193.2C363.993 184.8 361.393 178.2 356.193 173.4C350.993 168.6 344.393 166.2 336.393 166.2C329.193 166.2 322.993 168.4 317.793 172.8C312.993 177.2 310.593 182.8 310.593 189.6H243.993C243.993 164.8 252.793 144.6 270.393 129C287.993 113 310.593 105 338.193 105C365.793 105 388.193 112.2 405.393 126.6C422.993 141 431.793 160 431.793 183.6C431.793 200.8 427.193 214.8 417.993 225.6C408.793 236 396.993 243.2 382.593 247.2C399.793 252 413.393 260.2 423.393 271.8C433.793 283.4 438.993 298 438.993 315.6C438.993 340.4 429.593 360.8 410.793 376.8C391.993 392.8 367.593 400.8 337.593 400.8Z"/>
|
||||
<path d="M129.529 167.6H104.329V105.2H197.329V400.2H129.529V167.6Z"/>
|
||||
</mask>
|
||||
<path d="M337.593 400.8C306.793 400.8 281.593 392.4 261.993 375.6C242.793 358.8 233.193 337 233.193 310.2H303.393C303.393 318.2 306.393 324.8 312.393 330C318.393 335.2 326.393 337.8 336.393 337.8C345.993 337.8 353.793 335 359.793 329.4C366.193 323.8 369.393 316.6 369.393 307.8C369.393 299.8 366.593 293.2 360.993 288C355.393 282.8 348.193 280.2 339.393 280.2H302.193V218.4H339.393C346.193 218.4 351.993 216 356.793 211.2C361.593 206.4 363.993 200.4 363.993 193.2C363.993 184.8 361.393 178.2 356.193 173.4C350.993 168.6 344.393 166.2 336.393 166.2C329.193 166.2 322.993 168.4 317.793 172.8C312.993 177.2 310.593 182.8 310.593 189.6H243.993C243.993 164.8 252.793 144.6 270.393 129C287.993 113 310.593 105 338.193 105C365.793 105 388.193 112.2 405.393 126.6C422.993 141 431.793 160 431.793 183.6C431.793 200.8 427.193 214.8 417.993 225.6C408.793 236 396.993 243.2 382.593 247.2C399.793 252 413.393 260.2 423.393 271.8C433.793 283.4 438.993 298 438.993 315.6C438.993 340.4 429.593 360.8 410.793 376.8C391.993 392.8 367.593 400.8 337.593 400.8Z" fill="currentColor"/>
|
||||
<path d="M129.529 167.6H104.329V105.2H197.329V400.2H129.529V167.6Z" fill="currentColor"/>
|
||||
<path d="M337.593 400.8C306.793 400.8 281.593 392.4 261.993 375.6C242.793 358.8 233.193 337 233.193 310.2H303.393C303.393 318.2 306.393 324.8 312.393 330C318.393 335.2 326.393 337.8 336.393 337.8C345.993 337.8 353.793 335 359.793 329.4C366.193 323.8 369.393 316.6 369.393 307.8C369.393 299.8 366.593 293.2 360.993 288C355.393 282.8 348.193 280.2 339.393 280.2H302.193V218.4H339.393C346.193 218.4 351.993 216 356.793 211.2C361.593 206.4 363.993 200.4 363.993 193.2C363.993 184.8 361.393 178.2 356.193 173.4C350.993 168.6 344.393 166.2 336.393 166.2C329.193 166.2 322.993 168.4 317.793 172.8C312.993 177.2 310.593 182.8 310.593 189.6H243.993C243.993 164.8 252.793 144.6 270.393 129C287.993 113 310.593 105 338.193 105C365.793 105 388.193 112.2 405.393 126.6C422.993 141 431.793 160 431.793 183.6C431.793 200.8 427.193 214.8 417.993 225.6C408.793 236 396.993 243.2 382.593 247.2C399.793 252 413.393 260.2 423.393 271.8C433.793 283.4 438.993 298 438.993 315.6C438.993 340.4 429.593 360.8 410.793 376.8C391.993 392.8 367.593 400.8 337.593 400.8Z" stroke="var(--stroke-color)" stroke-width="2.4" mask="url(#path-5-mask)"/>
|
||||
<path d="M129.529 167.6H104.329V105.2H197.329V400.2H129.529V167.6Z" stroke="var(--stroke-color)" stroke-width="2.4" mask="url(#path-5-mask)"/>
|
||||
</g>
|
||||
</svg>
|
||||
<div class="absolute inset-0 rounded-t-lg lg:rounded-t-none lg:rounded-r-lg shadow-[inset_0px_0px_0px_1px_rgba(26,26,0,0.16)] dark:shadow-[inset_0px_0px_0px_1px_#fffaed2d]"></div>
|
||||
<section class="relative">
|
||||
<div class="absolute -inset-3 -z-10 rotate-1 rounded-[2rem] bg-teal-900/8"></div>
|
||||
<div class="overflow-hidden rounded-[1.75rem] border border-white/90 bg-white/80 shadow-[0_24px_80px_-30px_rgba(15,23,42,0.35)] backdrop-blur-xl">
|
||||
<div class="flex items-center justify-between border-b border-slate-200/80 px-5 py-4 sm:px-7">
|
||||
<div>
|
||||
<p class="text-xs font-semibold uppercase tracking-[0.16em] text-teal-700">New application</p>
|
||||
<h2 class="mt-1 text-lg font-semibold tracking-tight">Tell us the essentials</h2>
|
||||
</div>
|
||||
<span class="rounded-full bg-slate-100 px-3 py-1 text-[11px] font-medium text-slate-500">~ 1 minute</span>
|
||||
</div>
|
||||
|
||||
<form id="loan-form" class="p-5 sm:p-7" novalidate>
|
||||
<div class="grid gap-4 sm:grid-cols-2">
|
||||
<label class="grid gap-1.5 text-sm font-medium text-slate-700">
|
||||
Customer ID
|
||||
<input name="customerId" type="text" value="C-1001" required class="rounded-xl border border-slate-200 bg-white px-3.5 py-2.5 text-sm outline-none transition focus:border-teal-600 focus:ring-4 focus:ring-teal-600/10">
|
||||
</label>
|
||||
|
||||
<label class="grid gap-1.5 text-sm font-medium text-slate-700">
|
||||
Mobile number
|
||||
<input name="phone" type="tel" inputmode="numeric" value="09121234567" pattern="09[0-9]{9}" required class="rounded-xl border border-slate-200 bg-white px-3.5 py-2.5 text-sm outline-none transition focus:border-teal-600 focus:ring-4 focus:ring-teal-600/10">
|
||||
</label>
|
||||
|
||||
<label class="grid gap-1.5 text-sm font-medium text-slate-700">
|
||||
Requested amount
|
||||
<span class="relative">
|
||||
<input name="amount" type="number" inputmode="numeric" min="1" step="1" value="400000000" required class="w-full rounded-xl border border-slate-200 bg-white px-3.5 py-2.5 pr-14 text-sm outline-none transition focus:border-teal-600 focus:ring-4 focus:ring-teal-600/10">
|
||||
<span class="pointer-events-none absolute inset-y-0 right-3 flex items-center text-xs text-slate-400">IRR</span>
|
||||
</span>
|
||||
</label>
|
||||
|
||||
<label class="grid gap-1.5 text-sm font-medium text-slate-700">
|
||||
Monthly income
|
||||
<span class="relative">
|
||||
<input name="monthlyIncome" type="number" inputmode="numeric" min="0" step="1" value="50000000" required class="w-full rounded-xl border border-slate-200 bg-white px-3.5 py-2.5 pr-14 text-sm outline-none transition focus:border-teal-600 focus:ring-4 focus:ring-teal-600/10">
|
||||
<span class="pointer-events-none absolute inset-y-0 right-3 flex items-center text-xs text-slate-400">IRR</span>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<fieldset class="mt-5">
|
||||
<legend class="text-sm font-medium text-slate-700">Loan type</legend>
|
||||
<div class="mt-2 grid grid-cols-2 gap-2">
|
||||
<label class="relative cursor-pointer">
|
||||
<input class="peer sr-only" type="radio" name="loanType" value="PERSONAL" checked>
|
||||
<span class="flex items-center gap-3 rounded-xl border border-slate-200 bg-white px-3.5 py-3 text-sm transition peer-checked:border-teal-700 peer-checked:bg-teal-50 peer-checked:text-teal-900 peer-focus-visible:ring-4 peer-focus-visible:ring-teal-600/10">
|
||||
<span class="grid size-8 place-items-center rounded-lg bg-slate-100 text-slate-600 peer-checked:bg-white">
|
||||
<svg class="size-4" viewBox="0 0 24 24" fill="none" aria-hidden="true"><path d="M12 12a4 4 0 1 0 0-8 4 4 0 0 0 0 8ZM4.5 20c.8-3.4 3.3-5.5 7.5-5.5s6.7 2.1 7.5 5.5" stroke="currentColor" stroke-width="1.8" stroke-linecap="round"/></svg>
|
||||
</span>
|
||||
Personal
|
||||
</span>
|
||||
</label>
|
||||
<label class="relative cursor-pointer">
|
||||
<input class="peer sr-only" type="radio" name="loanType" value="BUSINESS">
|
||||
<span class="flex items-center gap-3 rounded-xl border border-slate-200 bg-white px-3.5 py-3 text-sm transition peer-checked:border-teal-700 peer-checked:bg-teal-50 peer-checked:text-teal-900 peer-focus-visible:ring-4 peer-focus-visible:ring-teal-600/10">
|
||||
<span class="grid size-8 place-items-center rounded-lg bg-slate-100 text-slate-600">
|
||||
<svg class="size-4" viewBox="0 0 24 24" fill="none" aria-hidden="true"><path d="M4 20V8h16v12M8 8V4h8v4M2 20h20M8 12h2m4 0h2m-8 4h2m4 0h2" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
||||
</span>
|
||||
Business
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</fieldset>
|
||||
|
||||
<div class="mt-5 grid gap-5 sm:grid-cols-[1fr_auto] sm:items-end">
|
||||
<label class="grid gap-2 text-sm font-medium text-slate-700">
|
||||
<span class="flex items-center justify-between gap-3">
|
||||
Credit score
|
||||
<output id="credit-score-output" for="credit-score" class="rounded-md bg-slate-950 px-2 py-0.5 font-mono text-xs text-white">720</output>
|
||||
</span>
|
||||
<input id="credit-score" name="creditScore" type="range" min="0" max="1000" value="720" class="h-2 w-full cursor-pointer appearance-none rounded-full bg-slate-200 accent-teal-700">
|
||||
</label>
|
||||
|
||||
<label class="flex cursor-pointer items-center justify-between gap-4 rounded-xl border border-slate-200 bg-white px-3.5 py-3 text-sm font-medium text-slate-700 sm:min-w-44">
|
||||
Has guarantor
|
||||
<span class="relative inline-flex">
|
||||
<input name="hasGuarantor" type="checkbox" class="peer sr-only">
|
||||
<span class="h-6 w-11 rounded-full bg-slate-200 transition peer-checked:bg-teal-700 peer-focus-visible:ring-4 peer-focus-visible:ring-teal-600/10"></span>
|
||||
<span class="absolute left-1 top-1 size-4 rounded-full bg-white shadow transition peer-checked:translate-x-5"></span>
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div id="form-message" class="mt-5 hidden rounded-xl px-3.5 py-3 text-sm" role="alert"></div>
|
||||
|
||||
<button id="submit-loan" type="submit" class="mt-5 flex w-full items-center justify-center gap-2 rounded-xl bg-teal-800 px-4 py-3.5 text-sm font-semibold text-white shadow-lg shadow-teal-900/15 transition hover:-translate-y-0.5 hover:bg-teal-900 focus:outline-none focus:ring-4 focus:ring-teal-700/20 disabled:cursor-wait disabled:opacity-60">
|
||||
<span>Submit application</span>
|
||||
<svg class="size-4" viewBox="0 0 24 24" fill="none" aria-hidden="true"><path d="m9 18 6-6-6-6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<section id="result-panel" class="hidden pb-10" aria-live="polite">
|
||||
<div class="rounded-[1.75rem] bg-slate-950 p-5 text-white shadow-2xl shadow-slate-950/20 sm:p-7">
|
||||
<div class="flex flex-col gap-5 sm:flex-row sm:items-center sm:justify-between">
|
||||
<div class="flex items-center gap-4">
|
||||
<span id="result-icon" class="grid size-12 place-items-center rounded-2xl bg-white/10 text-teal-300"></span>
|
||||
<div>
|
||||
<p id="result-eyebrow" class="text-xs font-semibold uppercase tracking-[0.16em] text-teal-300">Application ready</p>
|
||||
<h2 id="result-title" class="mt-1 text-2xl font-semibold tracking-tight">Submitted</h2>
|
||||
<p id="result-id" class="mt-1 font-mono text-xs text-slate-400"></p>
|
||||
</div>
|
||||
</div>
|
||||
<button id="process-loan" type="button" class="rounded-xl bg-[#d9f99d] px-5 py-3 text-sm font-semibold text-slate-950 transition hover:-translate-y-0.5 hover:bg-lime-200 focus:outline-none focus:ring-4 focus:ring-lime-200/20 disabled:cursor-not-allowed disabled:opacity-50">
|
||||
Run decision workflow
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@if (Route::has('login'))
|
||||
<div class="h-14.5 hidden lg:block"></div>
|
||||
@endif
|
||||
<div class="mt-7 grid gap-6 border-t border-white/10 pt-6 lg:grid-cols-[0.7fr_1.3fr]">
|
||||
<div id="loan-summary" class="grid grid-cols-2 gap-3"></div>
|
||||
<div>
|
||||
<div class="flex items-center justify-between gap-3">
|
||||
<h3 class="text-sm font-semibold">Decision trail</h3>
|
||||
<span id="history-count" class="text-xs text-slate-500"></span>
|
||||
</div>
|
||||
<ol id="history-list" class="mt-4 grid gap-2"></ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<footer class="flex items-center justify-between gap-4 border-t border-slate-900/10 py-5 text-xs text-slate-500">
|
||||
<p>BankFlow <span class="text-slate-300">/</span> Transparent loan processing</p>
|
||||
<a href="{{ route('health') }}" class="transition hover:text-teal-800">Service health</a>
|
||||
</footer>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,5 +1,6 @@
|
||||
<?php
|
||||
|
||||
use App\Domain\Loan\Enums\LoanStage;
|
||||
use App\Models\Loan;
|
||||
use Database\Seeders\BankFlowSeeder;
|
||||
|
||||
@@ -21,9 +22,9 @@ it('approves a valid personal loan and records applicable stages', function () {
|
||||
$loan = Loan::query()->where('public_id', $loanId)->firstOrFail();
|
||||
|
||||
expect($loan->histories()->orderBy('id')->pluck('stage_code')->all())->toBe([
|
||||
'VALIDATION',
|
||||
'FRAUD_CHECK',
|
||||
'CREDIT_CHECK',
|
||||
LoanStage::Validation,
|
||||
LoanStage::FraudCheck,
|
||||
LoanStage::CreditCheck,
|
||||
]);
|
||||
});
|
||||
|
||||
@@ -55,14 +56,14 @@ it('approves a valid business loan with a guarantor', function () {
|
||||
$loan = Loan::query()->where('public_id', $loanId)->firstOrFail();
|
||||
|
||||
expect($loan->histories()->orderBy('id')->pluck('stage_code')->all())->toBe([
|
||||
'VALIDATION',
|
||||
'FRAUD_CHECK',
|
||||
'GUARANTOR_CHECK',
|
||||
'CREDIT_CHECK',
|
||||
LoanStage::Validation,
|
||||
LoanStage::FraudCheck,
|
||||
LoanStage::GuarantorCheck,
|
||||
LoanStage::CreditCheck,
|
||||
]);
|
||||
});
|
||||
|
||||
it('stops for fraud and credit manual review decisions', function (array $overrides, string $stage) {
|
||||
it('stops for fraud and credit manual review decisions', function (array $overrides, LoanStage $stage) {
|
||||
$loanId = $this->postJson('/api/v1/loans', validLoanPayload($overrides))->json('loanId');
|
||||
|
||||
$this->postJson("/api/v1/loans/{$loanId}/process")
|
||||
@@ -74,8 +75,8 @@ it('stops for fraud and credit manual review decisions', function (array $overri
|
||||
|
||||
expect($loan->histories()->latest('id')->value('stage_code'))->toBe($stage);
|
||||
})->with([
|
||||
'fraud review' => [['customerId' => 'REVIEW-1001'], 'FRAUD_CHECK'],
|
||||
'credit review' => [['creditScore' => 600], 'CREDIT_CHECK'],
|
||||
'fraud review' => [['customerId' => 'REVIEW-1001'], LoanStage::FraudCheck],
|
||||
'credit review' => [['creditScore' => 600], LoanStage::CreditCheck],
|
||||
]);
|
||||
|
||||
it('executes manager approval only above its threshold', function (
|
||||
|
||||
Reference in new issue
Block a user