# maiquochuy/restaurant_review_mobile_app architecture

> Architecture diagram of the GitHub repository maiquochuy/restaurant_review_mobile_app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-31). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/maiquochuy/restaurant_review_mobile_app
- Repository: https://github.com/maiquochuy/restaurant_review_mobile_app

## Overview

##### Project type and purpose
- This is a full-stack mobile application:
- Frontend: React Native mobile app for iOS and Android
- Backend: Node.js/Express REST API
- Purpose: Allow end users to discover restaurants, write/read reviews, redeem vouchers; enable restaurant owners to manage menus/vouchers; provide an admin dashboard.

##### File structure
- Top-level directories:
- Restaurant_Review_App → all mobile code & config
- Restaurant_Review_App_BE → backend API code & config
- Frontend structure highlights:
- src/screens, src/components, src/navigators → UI and navigation
- src/contexts → global state via React Context API
- android/ & ios/ → native project files, Gradle, Xcode configs
- Backend structure highlights:
- routes/ → HTTP endpoints
- controllers/ → business logic
- models/ → Mongoose data schemas
- middleware/ → auth, error handling, file upload
- utils/, helpers/, config/ → external integrations & environment

##### README for additional insights
- Technology stack: React Native, React Navigation, TailwindCSS, Axios, Node.js/Express, MongoDB/Mongoose, JWT, Multer + Cloudinary, Nodemailer, Helmet, CORS.
- Key features and flows: authentication, restaurant discovery, reviews, notifications, maps, voucher system, admin functions.

##### Main components & interactions
a. Components
- Mobile App (React Native)
– UI layer: Screens & reusable Components
– Navigation layer: Stack, Tab, Drawer
– State Management: Context Providers
– HTTP Client: Axios
- API Server (Node.js / Express)
– Route Handlers → Controllers → Models
– Middleware for Auth (JWT), Errors, File Upload
- Database
– MongoDB (hosted locally or Atlas)
- External Services
– Cloudinary for image storage
– Email SMTP (Nodemailer)
– Map Services: Mapbox / Google Places
– Push Notifications / Real-time (if any)
b. Relationships & Data Flows
1. User interacts with Mobile UI → triggers Axios HTTP request
2. Requests go through Express routes → auth middleware → controllers
3. Controllers read/write data via Mongoose models to MongoDB
4. For uploads: Multer streams to Cloudinary → stored URLs back in DB
5. For emails: Nodemailer connects to SMTP
6. /Places API calls from mobile or backend to external map services
c. Architectural patterns / principles
- MVC-style on backend (Routes → Controllers → Models)
- Component-based & Context-driven on frontend
- Separation of concerns: UI vs. navigation vs. data fetching vs. state
- Secure layers: JWT auth, password hashing, CORS, Helmet
d. Key technologies to annotate
- React Navigation (Stack/Tab/Drawer)
- Native modules (Android / iOS directories)
- TailwindCSS via NativeWind
- Express.js, Mongoose
- Multer + Cloudinary
- JWT / bcrypt
- Nodemailer (SMTP)
- Mapbox / Google Places API

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Mobile Frontend Layer
    subgraph "Mobile App (React Native)" 
        direction TB
        MA_UI_Screens["UI Layer – Screens"]:::frontend
        MA_Components["UI Layer – Reusable Components"]:::frontend
        MA_Navigators["Navigation Layer"]:::frontend
        MA_Contexts["State Management (React Context)"]:::frontend
        MA_Axios["HTTP Client (Axios Config)"]:::frontend
        MA_Android["Native Android Files"]:::frontend
        MA_iOS["Native iOS Files"]:::frontend
    end

    %% Backend Layer
    subgraph "API Server (Node.js / Express)" 
        direction TB
        BE_Entry["server.js"]:::backend
        BE_Routes["API Routes"]:::backend
        BE_AdminRoutes["Admin Routes"]:::backend
        BE_Middleware["Middleware (Auth, Error, File Upload)"]:::backend
        BE_Controllers["Controllers (Business Logic)"]:::backend
        BE_Models["Mongoose Models"]:::backend
        BE_DBConfig["DB Config (MongoDB)"]:::backend
        BE_AuthHelpers["Auth Helpers (JWT, bcrypt)"]:::backend
        BE_CloudinaryUtil["Cloudinary Util"]:::backend
        BE_EmailUtil["Email Util (Nodemailer)"]:::backend
        BE_ErrorUtil["Error Utility"]:::backend
    end

    %% Database
    MongoDB["MongoDB Database"]:::db

    %% External Services
    subgraph "External Services"
        direction TB
        Cloudinary["Cloudinary"]:::external
        SMTP["Email SMTP (Nodemailer)"]:::external
        MapServices["Mapbox / Google Places"]:::external
        PushNotif["Push Notifications"]:::external
    end

    %% Connections
    MA_Axios -->|"HTTP/JSON"| BE_Entry
    BE_Entry --> BE_Routes
    BE_Entry --> BE_AdminRoutes
    BE_Routes --> BE_Middleware
    BE_AdminRoutes --> BE_Middleware
    BE_Middleware --> BE_Controllers
    BE_Controllers --> BE_Models
    BE_Models -->|"DB Operations"| MongoDB
    BE_DBConfig --> MongoDB
    BE_Controllers -->|"Upload Image"| BE_CloudinaryUtil
    BE_CloudinaryUtil --> Cloudinary
    BE_Controllers -->|"Send Email"| BE_EmailUtil
    BE_EmailUtil --> SMTP
    MA_Axios -->|"Map API Calls"| MapServices
    MA_Axios -->|"Push Notification"| PushNotif

    %% Click Events
    click MA_UI_Screens "https://github.com/maiquochuy/restaurant_review_mobile_app/tree/main/Restaurant_Review_App/src/screens/"
    click MA_Components "https://github.com/maiquochuy/restaurant_review_mobile_app/tree/main/Restaurant_Review_App/src/components/"
    click MA_Navigators "https://github.com/maiquochuy/restaurant_review_mobile_app/tree/main/Restaurant_Review_App/src/navigators/"
    click MA_Contexts "https://github.com/maiquochuy/restaurant_review_mobile_app/tree/main/Restaurant_Review_App/src/contexts/"
    click MA_Axios "https://github.com/maiquochuy/restaurant_review_mobile_app/blob/main/Restaurant_Review_App/src/constants/ApiContants.js"
    click MA_Android "https://github.com/maiquochuy/restaurant_review_mobile_app/tree/main/Restaurant_Review_App/android/"
    click MA_iOS "https://github.com/maiquochuy/restaurant_review_mobile_app/tree/main/Restaurant_Review_App/ios/"
    click BE_Entry "https://github.com/maiquochuy/restaurant_review_mobile_app/blob/main/Restaurant_Review_App_BE/server.js"
    click BE_Routes "https://github.com/maiquochuy/restaurant_review_mobile_app/tree/main/Restaurant_Review_App_BE/routes/"
    click BE_AdminRoutes "https://github.com/maiquochuy/restaurant_review_mobile_app/blob/main/Restaurant_Review_App_BE/routes/adminRoute.js"
    click BE_Controllers "https://github.com/maiquochuy/restaurant_review_mobile_app/tree/main/Restaurant_Review_App_BE/controllers/"
    click BE_Models "https://github.com/maiquochuy/restaurant_review_mobile_app/tree/main/Restaurant_Review_App_BE/models/"
    click BE_Middleware "https://github.com/maiquochuy/restaurant_review_mobile_app/tree/main/Restaurant_Review_App_BE/middleware/"
    click BE_DBConfig "https://github.com/maiquochuy/restaurant_review_mobile_app/blob/main/Restaurant_Review_App_BE/config/db.js"
    click BE_CloudinaryUtil "https://github.com/maiquochuy/restaurant_review_mobile_app/blob/main/Restaurant_Review_App_BE/utils/cloudinary.js"
    click BE_EmailUtil "https://github.com/maiquochuy/restaurant_review_mobile_app/blob/main/Restaurant_Review_App_BE/utils/sendEmail.js"
    click BE_ErrorUtil "https://github.com/maiquochuy/restaurant_review_mobile_app/blob/main/Restaurant_Review_App_BE/utils/errorResponse.js"
    click BE_AuthHelpers "https://github.com/maiquochuy/restaurant_review_mobile_app/blob/main/Restaurant_Review_App_BE/helpers/authHelper.js"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#333,stroke-width:1px
    classDef db fill:#FFA500,stroke:#333,stroke-width:1px
    classDef external fill:#D8BFD8,stroke:#333,stroke-width:1px
```
