Full stack application · Laravel and Vue
Travel Reimbursement
Calculates the monthly reimbursement for work trips from a calendar, with the AI’s math checked by the backend.
- Laravel 12 as a serverless function on Vercel
- PostgreSQL (Neon) in production, SQLite locally
- Stateless authentication with an encrypted token
- Type
- In production
- Period
- Oct 2026
- Stack
- Laravel, PHP 8.4, Vue 2.7, PostgreSQL

Architecture overview
01Interface
Vue 2.7 + BootstrapVue — Input
monthly calendar; day off or holiday in one click
02API
Laravel 12 serverless — Deterministic code
Form Requests, thin controllers, rate limiting
TokenService — Deterministic code
{id, expira} token encrypted with AES-256
03Rule
DiasUteisService — Deterministic code
workdays in the month minus the excluded dates
PostgreSQL — Data
Neon in production, SQLite locally
04AI
OpenRouter — Language model
total and explanation as JSON; backup models
05Check
ReembolsoService — Deterministic code
redoes the sum; checks that the difference is < R$0.01
mismatch → shows the correct value and warns
06Output
Result — Output
total, per-day breakdown and explanation
- Input and output
- Deterministic code
- Language model
- Data
01Context and problem
People who travel for work in their own car have to count, every month, how many Mondays, Tuesdays and Wednesdays fell on the calendar, subtract holidays and days off and multiply each day by a different rate before sending it to HR. It’s simple, repetitive math that is easy to get wrong.
02Goal
Reduce closing the month to three actions — set the rates once, mark the days off and generate — with a reliable, explained result.
Keep the system in production at zero infrastructure and AI cost, without giving up authentication or verification of the result.
03How it works
- 1.
Setup
The user creates an account and sets the amount paid for each weekday, Monday through Friday.
- 2.
Calendar
The month shows the rate for each workday. One click marks the day as a day off or holiday and removes it from the total.
- 3.
Calculation
The backend computes the workdays, builds the prompt with the dates and rates and asks the model for strict JSON with the total and the explanation.
- 4.
Verification
ReembolsoServiceextracts the JSON even when the model wraps it in markdown, redoes the sum and setsconfere: falseif the total doesn’t match. The frontend only displays: the server decides the final number.
System screens

04Technical architecture
Two Vercel projects pointing at the same repository: the static Vue frontend and the Laravel API running as a serverless function with the vercel-php runtime.
Laravel 12 API
Three thin controllers that receive requests already validated by Form Requests. Business rules live in seven single-responsibility services, such as
DiasUteisService,OpenRouterServiceandReembolsoService.Authentication
With no session between serverless invocations,
TokenServiceissues a{id, expira}token encrypted with AES-256 using theAPP_KEY— no token table and no Redis. Tokens last 7 days, passwords use bcrypt, and login, sign-up and generation are rate limited.Database
PostgreSQL on Neon through the Vercel integration (
DATABASE_URL) and SQLite locally.BancoDadosServicecreates the tables in a fresh environment.Vue frontend
Vue 2.7, BootstrapVue, Vite and axios. The calendar stays compact and the layout reflows on phone screens.
05Technologies
- Backend
- Laravel 12 · PHP 8.4 · Eloquent · Form Requests
- Frontend
- Vue 2.7 · BootstrapVue · Vite · axios
- Data
- PostgreSQL (Neon) · SQLite
- AI and infra
- OpenRouter (free models) · Vercel (vercel-php)
06Engineering decisions
The AI explains; the system guarantees
The model’s response is treated as untrusted input: extracted, compared with the local calculation and flagged when it diverges. In the tests documented in the repository, a small model answered R$405 where the correct value was R$395, and the check caught the error.
Stateless authentication for serverless
The encrypted token removes the need for session storage. Login runs the hash check even when the email doesn’t exist, so response time doesn’t reveal which accounts are registered.
Same code for SQLite and Postgres
Switching databases is just an environment variable. Local development stays simple, and production runs on managed Postgres.
Thin controllers, rules in services
Controllers only deal with HTTP and return JSON. Workday calculation, the model integration and the verification are isolated in services, which makes each rule easy to find and to test.
07Technical challenges
404 routes in production
With the function entry point at
api/index.php, Laravel treated/apias its base folder and every route returned 404 on Vercel. The fix adjustsSCRIPT_NAMEbefore booting the framework.Read-only file system
In the serverless function, the only writable directory is
/tmp. Caches and compiled views were redirected there.Availability with free models
Free models often run out of quota. A list of backup models lets the next one answer when one fails.
08What was implemented
- Sign-up and login with bcrypt, a 7-day token and rate limiting
- Per-user rates for each weekday
- Monthly calendar with days off and holidays
- Reimbursement generated with AI and checked by the backend
- Breakdown by weekday
- Responsive layout for phones
- Site and API deployed on Vercel, with Postgres on Neon
09Possible next steps
Future improvements — not implemented yet
- Automated tests for the calculation services — the repository has no tests yet beyond Laravel’s default scaffolding.
- Migrate the frontend to Vue 3, since Vue 2 has reached end of life.
- Export the result as a PDF to send to HR.
