feat: monorepo with NestJS API, admin panel and DB-driven website

Restructure the repo into a pnpm + Turborepo monorepo:

- apps/web: Nuxt 4 site, now server-rendered and reading all content
  from the API; pages cached with SWR and purged on content changes
- apps/api: NestJS 12 + Prisma 7 + PostgreSQL. Auth with short-lived
  access tokens and rotating httpOnly refresh cookies, roles (ADMIN,
  EDITOR), catalog, editable site sections, media upload to S3-compatible
  storage (converted to WebP), contact messages, audit log
- apps/admin: Vue 3 admin panel (Ant Design Vue, Pinia, Tailwind) for
  products, categories, site sections, messages, media and users
- packages/shared: Zod schemas and types shared by API and admin

Also:
- seed script that loads the original 8 categories / 89 products and
  section content
- Docker images for api (with a one-off migrate service), web, admin,
  and an nginx gateway for both domains
- dev and production compose files, daily database backup service
- API e2e tests

Removes the committed static out/ build and the old root Dockerfile.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
S. Esmaeili
2026-10-21 20:31:05 +03:30
co-authored by Claude Opus 5.5
parent 31076174e2
commit 789d224ea0
395 changed files with 19070 additions and 11592 deletions
+132
View File
@@ -0,0 +1,132 @@
<script setup lang="ts">
import {
AppstoreOutlined,
DashboardOutlined,
ExportOutlined,
FileImageOutlined,
LayoutOutlined,
LogoutOutlined,
MailOutlined,
MenuOutlined,
ShoppingOutlined,
TeamOutlined,
UserOutlined,
} from "@ant-design/icons-vue";
import { ROLE_LABELS } from "@imen/shared";
import { computed, h, ref, watch } from "vue";
import { useRoute, useRouter } from "vue-router";
import { useAuthStore } from "@/stores/auth";
import { SITE_URL } from "@/utils/format";
const auth = useAuthStore();
const route = useRoute();
const router = useRouter();
const drawer = ref(false);
const items = computed(() => [
{ key: "dashboard", icon: () => h(DashboardOutlined), label: "داشبورد" },
{ key: "products", icon: () => h(ShoppingOutlined), label: "محصولات" },
{ key: "categories", icon: () => h(AppstoreOutlined), label: "دسته‌بندی‌ها" },
{ key: "sections", icon: () => h(LayoutOutlined), label: "بخش‌های سایت" },
{ key: "messages", icon: () => h(MailOutlined), label: "پیام‌های تماس" },
{ key: "media", icon: () => h(FileImageOutlined), label: "کتابخانه رسانه" },
...(auth.isAdmin ? [{ key: "users", icon: () => h(TeamOutlined), label: "کاربران" }] : []),
]);
/** menu entry to highlight for nested pages (products/12 → products) */
const MENU_OF: Record<string, string> = {
"product-new": "products",
"product-edit": "products",
"category-new": "categories",
"category-edit": "categories",
"section-edit": "sections",
};
const selected = computed(() => {
const name = String(route.name ?? "");
return [MENU_OF[name] ?? name];
});
const go = ({ key }: { key: string | number }) => {
drawer.value = false;
void router.push({ name: String(key) });
};
watch(() => route.fullPath, () => (drawer.value = false));
</script>
<template>
<a-layout class="min-h-screen">
<a-layout-sider
:width="232"
breakpoint="lg"
collapsed-width="0"
:trigger="null"
class="!hidden lg:!block"
style="background: #0b1224"
>
<div class="flex items-center gap-3 px-5 py-5">
<img src="/favicon.svg" alt="" class="size-8" />
<div class="leading-tight text-white">
<div class="font-bold">ایمن پیشگامان</div>
<div class="text-[11px] text-white/50">پنل مدیریت</div>
</div>
</div>
<a-menu
theme="dark"
mode="inline"
:selected-keys="selected"
:items="items"
style="background: transparent; border: 0"
@click="go"
/>
</a-layout-sider>
<a-drawer v-model:open="drawer" placement="right" :width="260" :body-style="{ padding: 0, background: '#0b1224' }" :closable="false">
<a-menu theme="dark" mode="inline" :selected-keys="selected" :items="items" style="background: transparent; border: 0" @click="go" />
</a-drawer>
<a-layout>
<a-layout-header
class="flex items-center justify-between gap-4 border-b border-gray-200 !bg-white !px-4 md:!px-6"
style="height: 60px; line-height: 60px"
>
<div class="flex items-center gap-3">
<a-button class="lg:!hidden" @click="drawer = true">
<template #icon><MenuOutlined /></template>
</a-button>
<a :href="SITE_URL" target="_blank" rel="noopener" class="flex items-center gap-1.5 text-sm text-gray-500 hover:text-[#ff5a00]">
<ExportOutlined />
مشاهده سایت
</a>
</div>
<a-dropdown placement="bottomLeft">
<a-button type="text" class="flex items-center gap-2">
<UserOutlined />
<span>{{ auth.user?.name }}</span>
<a-tag v-if="auth.user" class="!m-0" :color="auth.isAdmin ? 'orange' : 'blue'">
{{ ROLE_LABELS[auth.user.role] }}
</a-tag>
</a-button>
<template #overlay>
<a-menu>
<a-menu-item key="profile" @click="router.push({ name: 'profile' })">
<UserOutlined /> حساب کاربری
</a-menu-item>
<a-menu-item key="logout" danger @click="auth.logout()">
<LogoutOutlined /> خروج
</a-menu-item>
</a-menu>
</template>
</a-dropdown>
</a-layout-header>
<a-layout-content class="p-4 md:p-6">
<!-- keyed by path (not query) so /sections/hero → /sections/about gets a fresh page -->
<RouterView v-slot="{ Component, route: r }">
<component :is="Component" :key="r.path" />
</RouterView>
</a-layout-content>
</a-layout>
</a-layout>
</template>