feat: complete fullstack investment manager challenge - #5
Open
vinicastrolima wants to merge 36 commits into
Open
feat: complete fullstack investment manager challenge#5vinicastrolima wants to merge 36 commits into
vinicastrolima wants to merge 36 commits into
Conversation
…v config - Multi-stage PHP 8.4 image (pdo_pgsql, bcmath, intl, zip, opcache, pcntl) - php-fpm + nginx, Postgres 17, Mailpit, queue worker and Vite dev server - Makefile 'up' brings the whole stack up, migrates and seeds in one command - Configure Laravel env for Postgres, Mailpit and CORS (FRONTEND_URL)
Production: laravel/sanctum (Bearer token auth), brick/money (exact money), spatie/laravel-data (typed DTOs). Dev: pestphp/pest, dedoc/scramble (OpenAPI), larastan (static analysis). Publishes API routes and personal_access_tokens.
- config/cors.php: allow only the SPA origin (FRONTEND_URL), token mode - config/investments.php: monthly gain rate + tax brackets as exact strings - pint.json (strict_types baseline applied repo-wide) and phpstan.neon (Larastan lvl 6) - Dockerfile: add pdo_sqlite for the in-memory test suite - gitignore local planning notes
Pure, framework-free domain: GainRate/TaxBracket/InvestmentStatus, ElapsedMonths (complete-month counting with last-day rule), GainCalculator (month-by-month compounding, HALF_UP each step) and TaxCalculator (tax on gains by age bracket), all backed by brick/money for exact cents. 37 unit tests cover the challenge vectors (1000@6mo -> 1031.61/31.61; gains 200 -> tax 45.00) and edge cases.
FormRequests + API Resources cover validation/serialization idiomatically, so laravel-data was redundant. laravel/pao corrupts stdout via its stream filter here, so tests run on Pest's standard reporter.
Migration + Investment model (money stored as integer cents via a MoneyCast adapter, status enum, withdrawal snapshot columns), owner relationship + Sanctum HasApiTokens on User, an InvestmentRepository contract with an Eloquent implementation, and a factory with active/withdrawn states.
Actions (Create/Withdraw/List) behind thin controllers; InvestmentCalculator facade over the domain; FormRequests enforce the date/amount rules; API Resource computes expected balance/gains (or the frozen withdrawal); Sanctum token auth; owner-only Policy; domain exceptions mapped to 409/422. Withdrawal-preview keeps tax math server-side. 21 feature tests cover create/view/withdraw/list/pagination.
Markdown Blade templates for investment created/withdrawn, sent to the owner via queued Mailables and dispatched from domain events. The withdrawal e-mail renders the full taxed breakdown. Blade is used here for templating without coupling the UI; Mailpit catches everything in dev. Tests assert queueing and rendering.
DatabaseSeeder creates a demo user (demo@coderockr.test) with active investments in each tax bracket, one already-withdrawn investment, and a second owner to make per-owner scoping visible. Covered by a feature test.
Scramble serves interactive docs at /docs/api and the raw spec at /docs/api.json; configured title/version/description and Bearer-auth documentation. The generated OpenAPI 3.1 spec is committed to api/docs/openapi.json (regenerate with 'make docs').
Tailwind v4 (Vite plugin) with light/dark tokens, '@' path alias, ESLint (vue-ts) + Prettier, Vitest, and the supporting npm scripts. Removes the Vite starter cruft.
Fetch-based API client with Bearer injection and 401 handling, Pinia auth/ui stores (token persisted, class-based dark mode), Vue Router with auth guards, the app shell/header, currency & date composables, and login/register pages.
TanStack Query hooks (paginated list with keepPreviousData, detail, debounced withdrawal preview, create/withdraw mutations); investment cards, status badges, paginator and a withdraw dialog with a live taxed-net preview; list/detail/create pages with loading, empty and error states.
The worker can start before migrations create the jobs table; a restart policy lets it recover and drain queued notification e-mails to Mailpit.
Dashboard (light + dark), investment detail, the live taxed withdrawal preview, the Scramble API docs and a caught notification e-mail in Mailpit.
Setup/run instructions, architecture, business rules, third-party library rationale, API docs links, tests/quality, screenshots and design notes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
This pull request delivers the fullstack Investment Manager challenge, including a documented JSON API and a responsive SPA based on the supplied Figma reference.
Highlights
Technical decisions
Quality assurance
The Playwright scenarios cover:
Running the project