Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
* text=auto eol=lf
*.js text eol=lf
*.jsx text eol=lf
*.ts text eol=lf
*.tsx text eol=lf
*.json text eol=lf
*.css text eol=lf
*.html text eol=lf
*.md text eol=lf
*.yml text eol=lf
*.yaml text eol=lf
*.sh text eol=lf
*.bat text eol=crlf
*.cmd text eol=crlf
*.ps1 text eol=crlf
*.png binary
*.jpg binary
*.jpeg binary
*.gif binary
68 changes: 68 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: CI

on:
pull_request:
branches: [dev, main]
push:
branches: [dev]
workflow_dispatch:

jobs:
build:
name: Build and Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

# Backend: install deps only (no build script)
- name: Backend install
working-directory: backend
run: |
npm ci || npm install

# Frontend web: install + build
- name: Frontend install
working-directory: frontend
run: |
npm ci || npm install
- name: Frontend build
working-directory: frontend
run: |
npm run build

# Admin web: install + build
- name: Admin install
working-directory: admin
run: |
npm ci || npm install
- name: Admin build
working-directory: admin
run: |
npm run build

# Users Admin web: install + build
- name: Users Admin install
working-directory: users-admin
run: |
npm ci || npm install
- name: Users Admin build
working-directory: users-admin
run: |
npm run build

# Mobile (Expo): install + lint only (skip heavy builds)
- name: Mobile install
working-directory: mobile
run: |
npm ci || npm install
- name: Mobile lint (if configured)
working-directory: mobile
run: |
npm run lint --if-present
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,4 @@ dist
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
.continue/
186 changes: 61 additions & 125 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,136 +1,72 @@
# Hangry

Hangry is a full-stack web application built using the MERN (MongoDB, Express.js, React, Node.js) stack. It aims to provide users with a smooth and interactive experience to explore and order food when they're feeling "hangry" (hungry + angry).
Hangry là hệ sinh thái đặt đồ ăn đa kênh xây trên MERN + Expo. Người dùng có thể duyệt menu, thêm giỏ, thanh toán (Stripe/COD) và theo dõi đơn; đội vận hành có portal để quản lý món, đơn và người dùng.

## Tech Stack
MongoDB · Express.js · React (Vite) · Node.js · React Native (Expo) · Stripe · Cloudinary/Uploads · JWT

<p align="center">
<img src="https://img.shields.io/badge/MongoDB-4ea94b?style=for-the-badge&logo=mongodb&logoColor=white" alt="MongoDB" />
<img src="https://img.shields.io/badge/Express.js-404D59?style=for-the-badge" alt="Express.js" />
<img src="https://img.shields.io/badge/React-20232A?style=for-the-badge&logo=react&logoColor=61DAFB" alt="React" />
<img src="https://img.shields.io/badge/Node.js-43853D?style=for-the-badge&logo=node.js&logoColor=white" alt="Node.js" />
<img src="https://img.shields.io/badge/JavaScript-323330?style=for-the-badge&logo=javascript&logoColor=F7DF1E" alt="JavaScript" />
<img src="https://img.shields.io/badge/HTML5-E34F26?style=for-the-badge&logo=html5&logoColor=white" alt="HTML5" />
<img src="https://img.shields.io/badge/CSS3-1572B6?style=for-the-badge&logo=css3&logoColor=white" alt="CSS3" />
<img src="https://img.shields.io/badge/Stripe-626CD9?style=for-the-badge&logo=Stripe&logoColor=white" alt="Stripe"/>
<img src="https://img.shields.io/badge/Render-%46E3B7.svg?style=for-the-badge&logo=render&logoColor=white" alt="Render">
</p>

## Table of Contents

## Mục Lục
- [Live Link](#live-link)
- [Features](#features)
- [Tính Năng](#tính-năng)
- [Tech Stack](#tech-stack)
- [Installation](#installation)
- [Usage](#usage)
- [API Endpoints](#api-endpoints)
- [Contributing](#contributing)
- [Cài Đặt](#cài-đặt)
- [Sử Dụng](#sử-dụng)
- [API Chính](#api-chính)
- [Đóng Góp](#đóng-góp)
- [License](#license)

## Live-Link

- You can view the live link [here.](https://hangry-frontend.onrender.com/)

## Features

- User authentication and authorization (JWT-based).
- Explore a variety of food items from different categories.
- Add items to cart and manage orders.
- Interactive UI with real-time updates.
- Fully responsive design.
- Backend RESTful API for handling data.

## Tech Stack

- **Frontend**: React.js
- **Backend**: Node.js, Express.js
- **Database**: MongoDB
- **Authentication**: JWT (JSON Web Tokens)
- **UI Library**: Material-UI / Bootstrap (mention if any)

## Installation

1. Clone the repository:

```bash
git clone https://github.com/aayushai/Hangry.git
```

2. Navigate to the project directory:

```bash
cd Hangry
```

3. Install dependencies for both frontend and backend:

```bash
# Install backend dependencies
cd backend
npm install

# Install frontend dependencies
cd ../frontend
npm install
```

4. Set up environment variables:

- Create a `.env` file in the `backend` folder and configure the following variables:
```bash
MONGO_URI=<your-mongo-db-uri>
JWT_SECRET=<your-jwt-secret>
```

5. Run the application:

- Start the backend:
```bash
cd backend
npm run dev
```

- Start the frontend:
```bash
cd ../frontend
npm start
```

The app should now be running on `http://localhost:3000`.

## Usage

- Register or login to your account.
- Browse food categories and add items to your cart.
- Review and place orders.
- View and manage your profile and order history.

## API Endpoints

Here are some key API endpoints for the backend (located in the `backend/routes` folder):

- **User Routes**:
- `POST /api/users/login`: User login.
- `POST /api/users/register`: User registration.

- **Food Routes**:
- `GET /api/food`: Get all food items.
- `POST /api/food`: Add a new food item (Admin only).

- **Order Routes**:
- `POST /api/orders`: Create a new order.
- `GET /api/orders/:id`: Get order by ID.

## Contributing

If you'd like to contribute to this project, please follow these steps:

1. Fork the repository.
2. Create your feature branch (`git checkout -b feature/AmazingFeature`).
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`).
4. Push to the branch (`git push origin feature/AmazingFeature`).
5. Open a pull request.
## Live Link
- Web khách hàng: https://hangry-frontend.onrender.com
- Backend mẫu: https://hangry-backend.onrender.com

## Tính Năng
- Đăng ký/đăng nhập JWT, phân quyền user/admin.
- Duyệt danh mục, thêm/giảm giỏ, thanh toán Stripe hoặc COD.
- Portal admin thêm món (upload ảnh), duyệt menu, cập nhật trạng thái đơn.
- Console quản lý người dùng (lọc, khóa/mở, đổi role, xóa).
- Ứng dụng di động Expo tabs: Home, Cart, Orders, Profile.

## Cài Đặt
```bash
git clone https://github.com/TNTDanh/Software_Hangry.git
cd Software_Hangry

cd backend && npm install
cd ../frontend && npm install
cd ../admin && npm install
cd ../users-admin && npm install
cd ../mobile && npm install
```

### Biến môi trường
- `backend/.env`: `PORT`, `MONGO_URI`, `JWT_SECRET`, `CLIENT_URL`, `FRONTEND_URL`, `STRIPE_SECRET_KEY`, các khóa Cloudinary (nếu dùng).
- `frontend/.env`, `admin/.env`, `users-admin/.env`: `VITE_API_URL=http://localhost:4000`.
- `mobile/src/api/client.ts` & `mobile/src/until/image.ts`: cập nhật `API_URL` phù hợp (VD: `http://10.0.2.2:4000` trên Android emulator).

### Chạy dự án
| Module | Lệnh |
| ------------- | --------------------------- |
| Backend | `cd backend && npm run server` |
| Web khách | `cd frontend && npm run dev` |
| Admin portal | `cd admin && npm run dev` |
| User console | `cd users-admin && npm run dev`|
| Mobile (Expo) | `cd mobile && npx expo start` |

## Sử Dụng
1. Mở web/app → đăng ký/đăng nhập.
2. Duyệt menu, lọc danh mục, thêm món vào giỏ.
3. Đặt đơn (Stripe redirect hoặc COD) và theo dõi trạng thái.
4. Admin dùng portal để thêm món, chỉnh đơn; console để quản lý người dùng.

## API Chính
- **User:** `POST /api/user/register`, `POST /api/user/login`, `GET /api/user/list`, `POST /api/user/update`, `POST /api/user/remove`.
- **Food:** `POST /api/food/add`, `GET /api/food/list`, `POST /api/food/remove`.
- **Cart:** `POST /api/cart/add`, `/remove`, `/get`.
- **Order:** `POST /api/order/place`, `/place-cod`, `/verify`, `/userorders`, `GET /api/order/list`, `POST /api/order/status`.

## Đóng Góp
1. Fork repo & tạo nhánh `feat/<ten>`.
2. Commit, push, mở Pull Request về nhánh `dev`.

## License

This project is licensed under the MIT License.
Dự án phát hành theo [MIT](LICENSE).
2 changes: 1 addition & 1 deletion admin/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>D&P's Admin</title>
<title>D&P RESTAURANT</title>
</head>
<body>
<div id="root"></div>
Expand Down
Binary file added admin/public/header_img.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
78 changes: 54 additions & 24 deletions admin/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,63 @@
import React from 'react'
import Navbar from './components/Navbar/Navbar'
import Sidebar from './components/Sidebar/Sidebar'
import { Routes,Route } from 'react-router-dom'
import Add from './pages/Add/Add'
import List from './pages/List/List'
import Orders from './pages/Orders/Orders'
import { ToastContainer } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';
import React from "react";
import { Routes, Route, Navigate } from "react-router-dom";
import Navbar from "./components/Navbar/Navbar";
import Sidebar from "./components/Sidebar/Sidebar";
import Add from "./pages/Add/Add";
import List from "./pages/List/List";
import Orders from "./pages/Orders/Orders";
import Login from "./pages/Login/Login";
import { ToastContainer } from "react-toastify";
import "react-toastify/dist/ReactToastify.css";
import useAuth from "./auth/useAuth.jsx";
import useUI from "./ui/useUI.jsx";

const App = () => {
const url = import.meta.env.VITE_API_URL || "http://localhost:5000";
const { token, role, logout } = useAuth();
const { t } = useUI();

// const url = "http://localhost:4000"
const url = "https://hangry-backend.onrender.com"
if (!token) {
return (
<>
<ToastContainer />
<Login url={url} />
</>
);
}

const allowedRoles = ["admin", "restaurantOwner"];
if (!allowedRoles.includes(role)) {
return (
<>
<ToastContainer />
<div className="unauthorized">
<div className="unauth-card">
<p className="unauth-title">{t("noPermission")}</p>
<p className="unauth-sub">Vui lòng đăng nhập bằng tài khoản admin hoặc chủ nhà hàng.</p>
<button onClick={logout}>{t("loginAgain")}</button>
</div>
</div>
</>
);
}

return (
<div>
<ToastContainer/>
<Navbar/>
<hr/>
<div className="admin-app">
<ToastContainer />
<Navbar />
<div className="app-content">
<Sidebar/>
<Routes>
<Route path="/add" element={<Add url={url}/>}/>
<Route path="/list" element={<List url={url}/>}/>
<Route path="/orders" element={<Orders url={url}/>}/>
</Routes>
<Sidebar role={role} />
<div className="app-main">
<Routes>
<Route path="/add" element={<Add url={url} />} />
<Route path="/list" element={<List url={url} />} />
<Route path="/orders" element={<Orders url={url} />} />
<Route path="*" element={<Navigate to="/list" replace />} />
</Routes>
</div>
</div>
</div>
)
}
);
};

export default App
export default App;
2 changes: 1 addition & 1 deletion admin/src/assets/assets.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ export const assets ={
parcel_icon
}

export const url = 'https://hangry-backend.onrender.com'
export const url = import.meta.env.VITE_API_URL || "http://localhost:5000";
Binary file added admin/src/assets/bag_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading