How shakirchaya0/fullstack-app works
Project Type and Purpose
• This is a full-stack restaurant management system with two distinct codebases:
• Frontend: React + TypeScript (Vite)
• Backend: Node.js + TypeScript, layered/DDD architecture
• Purpose: Allow customers to scan QR codes to browse menus, order, pay (via Mercado Pago), reserve tables; staff manage orders, menus, reservations, payments, and customer relations.
File Structure
• Top-level: frontend/, backend/
• Frontend/src:
• features/ – feature modules (News, Products, Login, Reservation, Payment, Profile…)
• routes/ – React Router routes
• shared/ – reusable hooks, components, contexts
• store/ – Redux slices
• Backend/src:
• presentation/ – controllers, routes, middleware (Express/Koa)
• application/ – services/use-cases
• domain/ – entities, repositories interfaces
• infrastructure/ – config, database adapter, external services (MercadoPago client, SMTP client, WebSocket server)
• scripts/ – bootstrapping
• Configuration: .env, PostgreSQL, Mercado Pago sandbox, SMTP settings, WebSocket URL.
Main Components
a. Client Mobile Device (Browser/SPA)
• React application served by Vite on port 5173
• Communicates over HTTP/HTTPS and WebSocket
b. API Gateway / Backend Service
• Node.js TypeScript service
• Layers: Presentation, Application, Domain, Infrastructure
• Exposes REST endpoints (orders, menus, reservations, payments, auth)
• WebSocket endpoint for real-time updates (e.g., order status)
c. Database
• PostgreSQL
• Tables: Users, Roles, Products, Orders, Reservations, Payments, News, etc.
d. External Services
• Mercado Pago (Sandbox) for payment processing
• SMTP (e.g., Gmail or Mailtrap) for email confirmations/reset links
• (Optional) Public tunnel (ngrok) for Webhook testing
e. Administrative UI (Desktop/Web)
• Same React SPA or a separate route accessible by staff/admin roles for order management, menu updates, table availability.
Relationships & Data Flow
• Client ↔ Backend (REST API):
• Login/Signup, fetch menu, create order/reservation, user profile
• Client ↔ Backend (WebSocket):
• Real-time order status, table readiness, push notifications
• Backend ↔ Database:
• CRUD operations on domain entities via repository layer
• Backend ↔ Mercado Pago:
• Initiate payment, receive payment confirmation (synchronous)
• Webhook callback (asynchronous) → Backend updates order status
• Backend ↔ SMTP Service:
• Send order receipt, reservation confirmation, password reset emails
Architectural Patterns & Design Principles
• Layered (Onion) Architecture / DDD
• Presentation → Application (use cases) → Domain (business rules) → Infrastructure
• Feature-based modularization on the frontend
• CQRS/Separation of Concerns: controllers orchestrate use cases, repositories handle persistence
• Env-driven configuration for endpoints & secrets
• External integration adapters for payments and mail
• Versioned services or ports annotated