Skip to content
Open
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
13 changes: 8 additions & 5 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: Build and Push Images

on:
# push:
# # branches:
# # - main
# tags:
# - 'v*.*.*'
push:
branches:
- main
tags:
- 'v*.*.*'
workflow_dispatch:

jobs:
Expand Down Expand Up @@ -38,3 +38,6 @@ jobs:
*.labels.org.opencontainers.image.revision=${{ github.sha }}
*.cache-from=type=gha
*.cache-to=type=gha,mode=max
env:
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }}
VITE_MAPBOX_API_KEY: ${{ secrets.VITE_MAPBOX_API_KEY }}
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,7 @@ kustomize-view:
kubectl kustomize k8s/kustomization/base

kustomize-apply:
kubectl apply -k k8s/kustomization/base
kubectl apply -k k8s/kustomization/base

kustomize-delete:
kubectl delete -k k8s/kustomization/base
34 changes: 34 additions & 0 deletions api-gateway/nginx.conf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ http {
server notification-service:3000;
}

upstream order_service {
server order-service:5000;
}

upstream payment_service {
server payment-service:5000;
}

server {
listen 5000;
server_name localhost;
Expand Down Expand Up @@ -42,6 +50,32 @@ http {
add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" always;
}

# Order Service
location /api/orders/ {
rewrite ^/api/orders/(.*)$ /orders/$1 break;
proxy_pass http://order_service/;
limit_req zone=api burst=10;

# CORS headers
add_header Access-Control-Allow-Origin "*" always;
add_header Access-Control-Allow-Credentials "true" always;
add_header Access-Control-Allow-Headers "Authorization, Content-Type" always;
add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" always;
}

# Payment Service
location /api/payments/ {
rewrite ^/api/payments/(.*)$ /orders/$1 break;
proxy_pass http://payment__service/;
limit_req zone=api burst=10;

# CORS headers
add_header Access-Control-Allow-Origin "*" always;
add_header Access-Control-Allow-Credentials "true" always;
add_header Access-Control-Allow-Headers "Authorization, Content-Type" always;
add_header Access-Control-Allow-Methods "GET, POST, PUT, DELETE, OPTIONS" always;
}

location = /unauthorized {
return 401;
}
Expand Down
25 changes: 24 additions & 1 deletion docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ variable "TAG" {
default = "latest"
}

variable "STRIPE_SECRET_KEY" {}
variable "VITE_MAPBOX_API_KEY" {}

# Define common build configuration
target "common" {
args = {
Expand All @@ -28,14 +31,18 @@ target "common" {

# Default group builds all services with their specified targets from docker-compose
group "default" {
targets = ["frontend", "user-service", "notification-service", "email-service", "sms-service"]
targets = ["frontend", "user-service", "notification-service", "email-service", "sms-service", "order-service", "payment-service"]
}

# Frontend service
target "frontend" {
inherits = ["common"]
context = "./frontend"
tags = ["${REGISTRY}/frontend:${TAG}"]
args = {
STRIPE_SECRET_KEY = "${STRIPE_SECRET_KEY}"
VITE_MAPBOX_API_KEY = "${VITE_MAPBOX_API_KEY}"
}
}

# User Service (default to development as in docker-compose)
Expand Down Expand Up @@ -69,3 +76,19 @@ target "sms-service" {
target = "production"
tags = ["${REGISTRY}/sms-service:${TAG}"]
}

# Order Service
target "order-service" {
inherits = ["common"]
context = "./order-service"
target = "production"
tags = ["${REGISTRY}/order-service:${TAG}"]
}

# Payment Service
target "payment-service" {
inherits = ["common"]
context = "./payment-service"
target = "production"
tags = ["${REGISTRY}/payment-service:${TAG}"]
}
24 changes: 24 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,30 @@ services:
networks:
- cravedrop-network

order-service:
image: nmdra/order-service
build:
context: ./order-service
target: production
container_name: order-service
hostname: order-service
ports:
- "3007:5000"
env_file:
- ./order-service/.env

payment-service:
image: nmdra/payment-service
build:
context: ./payment-service
target: production
container_name: payment-service
hostname: payment-service
ports:
- "3008:5000"
env_file:
- ./payment-service/.env

volumes:
pg_data:

Expand Down
6 changes: 6 additions & 0 deletions frontend/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
FROM node:22-alpine AS builder

ARG STRIPE_SECRET_KEY
ARG VITE_MAPBOX_API_KEY

ENV STRIPE_SECRET_KEY=${STRIPE_SECRET_KEY}
ENV VITE_MAPBOX_API_KEY=${VITE_MAPBOX_API_KEY}}

WORKDIR /app

COPY package.json yarn.lock ./
Expand Down
5 changes: 4 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
"preview": "vite preview"
},
"dependencies": {
"@stripe/react-stripe-js": "^3.6.0",
"@stripe/stripe-js": "^7.2.0",
"@tailwindcss/vite": "^4.1.4",
"axios": "^1.8.4",
"axios": "^1.9.0",
"axios-mock-adapter": "^2.1.0",
"cors": "^2.8.5",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"react-hot-toast": "^2.5.2",
Expand Down
40 changes: 38 additions & 2 deletions frontend/src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,25 @@ import Notifications from './Pages/Customer/Notifications'
import SidebarLayout from './Layouts/SidebarLayout'
import OrderSummary from './Pages/Customer/OrderSummary'

//order part
import { CartProvider } from './Context/CartContext'
import Home from './Pages/order/HomePage'
import ProductDetails from './Pages/order/ProductDetails'
import Cart from './Pages/order/CartPage'
import Checkout from './Pages/order/Checkoutpage'
import Payment from './Pages/order/PaymentPage'
import SuccessPage from './Pages/order/SuccessPage'

//Restuarant part
import RestuarantRegister from "./pages/Register.jsx";
import RestuarantLogin from "./pages/Login.jsx";
import RestuarantDashboard from "./pages/Dashboard.jsx";
import RestuarantMenuManagement from './pages/MenuManagement.jsx';
import RestuarantProfileSettings from "./pages/ProfileSettings.jsx";
import RestuarantAdminDashboard from "./pages/AdminDashboard.jsx";
import "./restaurnat.css";
import Restuarantstyles from "./App.module.css";

const router = createBrowserRouter(
createRoutesFromElements(
<>
Expand All @@ -37,6 +56,23 @@ const router = createBrowserRouter(
<Route path="/orders/:orderId" element={<OrderSummary />} />
</Route>

{/* order part */}
<Route path="/home" element={<Home />} />
<Route path="/products/:id" element={<ProductDetails />} />
<Route path="/cart" element={<Cart />} />
<Route path="/checkout" element={<Checkout />} />
<Route path="/payment" element={<Payment />} />
<Route path="/success" element={<SuccessPage />} />

<Route path="/restaurant" element={<SidebarLayout />}>
<Route path="/register" element={<RestuarantRegister />} />
<Route path="/login" element={<RestuarantLogin />} />
<Route path="/dashboard" element={<RestuarantDashboard/>} />
<Route path="/menu-management" element={<RestuarantMenuManagement />} />
<Route path="/profile" element={<RestuarantProfileSettings />} />
<Route path="/admin/dashboard" element={<RestuarantAdminDashboard />} />
</Route>

{/* Catch-all for 404 */}
<Route path="*" element={<NotFound />} />
</Route>
Expand All @@ -46,10 +82,10 @@ const router = createBrowserRouter(

const App = () => {
return (
<>
<CartProvider>
<RouterProvider router={router} />
<Toaster position="top-center" reverseOrder={false} />
</>
</CartProvider>
)
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/Components/Home/ShopList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const FoodList = () => {
<div className="flex items-center justify-center pt-10 pb-[6rem]">
<button
className="rounded-lg bg-[#b8f724] px-10 py-4 hover:bg-[#f3ffc6]"
onClick={() => navigate('/foods')}
onClick={() => navigate('/home')}
>
View More
</button>
Expand Down
30 changes: 30 additions & 0 deletions frontend/src/Components/order/ProductCard.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from 'react';

const ProductCard = ({ product }) => {
return (
<div className="bg-white rounded-lg shadow-lg overflow-hidden transform transition duration-300 hover:scale-105 hover:shadow-xl">
<div className="relative">
<img
src={product.image || 'https://via.placeholder.com/300'}
alt={product.name}
className="w-full h-48 object-cover"
/>
<div className="absolute top-2 right-2 bg-blue-500 text-white text-xs font-bold px-2 py-1 rounded">
New
</div>
</div>
<div className="p-4">
<h2 className="text-lg font-semibold text-gray-800 truncate">{product.name}</h2>
<p className="text-sm text-gray-600 mt-2 truncate">{product.description}</p>
<div className="flex items-center justify-between mt-4">
<span className="text-xl font-bold text-green-600">${product.price.toFixed(2)}</span>
<button className="bg-blue-500 text-white px-4 py-2 rounded-lg hover:bg-blue-600 transition">
Add t Cart
</button>
</div>
</div>
</div>
);
};

export default ProductCard;
20 changes: 20 additions & 0 deletions frontend/src/Context/CartContext.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { createContext, useState, useEffect } from 'react';

export const CartContext = createContext();

export const CartProvider = ({ children }) => {
const [cartItems, setCartItems] = useState(() => {
const storedCart = localStorage.getItem('cartItems');
return storedCart ? JSON.parse(storedCart) : [];
});

useEffect(() => {
localStorage.setItem('cartItems', JSON.stringify(cartItems));
}, [cartItems]);

return (
<CartContext.Provider value={{ cartItems, setCartItems }}>
{children}
</CartContext.Provider>
);
};
Loading