How 23klhuynh/vietnamese_restaurant works
Project type and purpose
• This is a full-stack web application (“Pho Viet”), consisting of:
• A React/TypeScript single-page application (client/)
• A Flask REST API server with JWT-based authentication (server/)
• A PostgreSQL database for persisting menu items and users
• Purpose: allow users to register, log in, browse a restaurant menu, add items to a cart, and place orders.
File structure
• Top-level:
• client/ – front-end code powered by Vite, React, TailwindCSS
• server/ – back-end Python Flask application
• client/:
• src/pages – Route-based views (Home, Login, Register, Menu, NotFound)
• src/components – Reusable UI fragments, navigation bar, menu items, cart
• src/auth/UserContext.tsx – React Context holds JWT and user info
• Hooks for scroll, UI behavior
• Configuration: vite.config.js, tailwind.config.js, tsconfig.json
• server/:
• app.py – Flask app instantiation and routing
• config.py – environment and database URI
• extensions.py – DB, JWT setup
• jwt_handlers.py – issue/verify tokens
• routes/ – auth.py (register, login, refresh, logout), menu.py (CRUD menu items)
• requirements.txt – Python dependencies
Key insights from README
• Uses JWT for authentication
• PostgreSQL as persistent store
• Deployed on Vercel (front end) and Render (back end)
• Start commands: npm run dev / flask app.py
Main components
a. Front-end Layer (client)
– Browser
– Hosted on Vercel
– React SPA
b. API Layer (server)
– Flask REST API
– Hosted on Render
– Modules: Auth service, Menu service
c. Data Layer
– PostgreSQL database
d. External Services
– Vercel CDN
– Render compute
– (Optional) Third-party analytics or payment if any
Relationships and interactions
• User (Browser) → HTTP(S) GET/POST → React SPA assets (Vercel CDN)
• React SPA → HTTP(S) API calls → Flask endpoints (Auth & Menu)
• Flask → SQL queries → PostgreSQL
• JWT issuance: Auth service → signs token → returned to client → stored in UserContext localStorage or HTTP-only cookie
• Protected API calls include JWT in Authorization header → validated by jwt_handlers
Architectural patterns and design principles
• Client-Server separation (SPA vs. REST API)
• Stateless authentication via JWT
• Modular back-end with Blueprints (routes/auth.py, routes/menu.py)
• React Context for global state (auth)
• Component-based UI (atoms, molecules, pages)
• Tailwind utility-first CSS integration
Technologies & frameworks
• Front-end: React, Vite, TypeScript, TailwindCSS
• Back-end: Flask, Flask-JWT-Extended, psycopg2 (or SQLAlchemy), Python 3.x
• Database: PostgreSQL
• Hosting: Vercel (front), Render (back)
Final checklist
• [ ] All components labeled (Browser, React SPA, Auth Service, Menu Service, DB)
• [ ] Clear boundary of hosting environments
• [ ] Notes on major frameworks/technologies in each component