How tarrekosama/pc-builder-serverside works
Project type and purpose
• This is a full-stack e-commerce web application (“PC Builder”) with:
– An Angular SPA frontend serving the UI and invoking RESTful endpoints
– A Laravel backend exposing an API, handling business logic, data access, authentication, and admin operations
– A MySQL database for persistent storage
– Integration with external payment providers (Stripe, PayPal)
File structure
• Top-level folders:
– app/Http/Controllers/API: REST controllers (MotherboardController, PsuController, etc.)
– app/Models: Eloquent models representing Users, Orders, Components, Builds, Reviews, Notifications, etc.
– routes/api.php & routes/web.php: define API endpoints vs. any server-side rendered pages
– resources/js & resources/css: assets for the frontend (if Angular code sits here or in a separate frontend/ folder)
– database/migrations & seeders: DB schema definitions and sample data loaders
– config/ & bootstrap/: framework configuration and bootstrapping
– public/index.php: entry point for HTTP requests
– vendor/ & composer.json: PHP dependencies
– package.json, vite.config.js, tailwind.config.js: Node build and asset tooling
README for additional insights
• Frontend: Angular (likely in a separate frontend/ folder or integrated via resources/)
• Backend: Laravel 9+, Sanctum for API auth, uses Stripe/PayPal SDKs
• Features: real-time compatibility checks, shopping cart, guest checkout, order tracking, admin dashboards
a. Main components
– Browser (Angular SPA)
– Web server (Nginx/Apache)
– API layer (Laravel controllers + request validation)
– Business logic layer (Services, FormRequests, Resource transformers)
– Data access layer (Eloquent models, Repositories)
– Relational database (MySQL)
– External payment gateways (Stripe, PayPal)
– Optional: Queue worker for sending notifications, processing long-running tasks
– Admin console (part of Angular or Laravel Blade)
– File storage (local or S3 for uploads)
b. Relationships and interactions
– Users → Angular UI → HTTP(S) → Web server → Laravel’s public/index.php → Router → Controller → Service → Model → MySQL
– Checkout flow: Controller invokes payment SDK → Webhook listeners → Update Order status → Notification job queued
– Admin → Authenticated API calls → Inventory/Order management endpoints
– Real-time compatibility: Angular polls or WebSocket (if implemented) to API → Controller runs compatibility logic → returns suggestions
c. Architectural patterns & design principles
– RESTful API separation between UI and backend
– MVC pattern within Laravel (Controllers, Models, Views/Resources)
– Form request validation (app/Http/Requests) for strong typing
– Database migrations and seeders for reproducible schema
– Queues (config/queue.php) for async tasks
– Use of environment config (.env) for secrets
d. Key technologies
– Laravel, PHP 8+, Composer
– Angular, TypeScript, Node/NPM
– MySQL, Eloquent ORM
– Stripe & PayPal SDKs
– Tailwind CSS / PostCSS / Vite for asset bundling
– Laravel Sanctum for API authentication
Diagramming conventions
• Components:
• Data flow:
– UI vs. API vs. Data vs. External
• Labels:
– Name each component clearly (e.g., “Angular SPA,” “API: MotherboardController,” “MySQL: builds table”)
– Annotate key interactions (e.g., “Validate compatibility,” “Charge via Stripe,” “Seed initial data”)