# Ник-Маш Трейд ЕООД — Industrial Equipment Website

## Project Overview
A full-stack bilingual (Bulgarian default, English `/en/` prefix) industrial equipment website and admin CMS for Ник-Маш Трейд ЕООД — a Bulgarian importer/trader of electric motors, gearboxes, pumps, and fans (25+ years).

## Architecture
- **Monorepo**: pnpm workspace with artifacts + shared libs
- **Frontend** (`artifacts/nickmash`): React + Vite + Tailwind v4 + wouter routing
- **Backend** (`artifacts/api-server`): Express.js + Drizzle ORM + PostgreSQL
- **Shared libs**: `@workspace/api-spec` (OpenAPI), `@workspace/api-client-react` (React Query hooks), `@workspace/api-zod` (Zod schemas), `@workspace/db` (Drizzle schema + client), `@workspace/object-storage-web`

## Public Site Pages
- `/` — Home: hero, category grid, about, partner slider
- `/products` — Product catalog with search + sidebar filters
- `/products/:id` — Product detail with image gallery + contact panel
- `/blog` — Blog post list
- `/blog/:slug` — Blog post detail with SEO meta
- `/contacts` — Contact form (mailto) + Google Map

All pages available in English at `/en/` prefix.

## Admin CMS (`/admin`)
- Session-based auth (NO Clerk). Credentials: `admin` / `admin123`
- `/admin/dashboard` — Stats overview
- `/admin/products` — Product CRUD
- `/admin/products/:id/edit` — Product edit form
- `/admin/blog` — Blog CRUD
- `/admin/blog/:slug/edit` — Blog edit form
- `/admin/categories` — Category management
- `/admin/filters` — Filter management per category
- `/admin/partners` — Partner logo management

## Database Tables (PostgreSQL via Drizzle ORM)
- `admins` — Admin users (bcryptjs password hashing)
- `categories` — Equipment categories with BG/EN names + icon
- `filters` — Per-category filters (range/select/multiselect/boolean)
- `products` — Products with BG/EN bilingual content, condition, price, images (JSON), attributes (JSON)
- `blog_posts` — Blog with BG/EN content, SEO meta fields
- `partners` — Partner logos with sort order

## API Endpoints (`/api`)
- `POST /api/auth/login` — Session login
- `POST /api/auth/logout` — Session logout
- `GET /api/auth/me` — Current user (401 if not authenticated)
- `GET/POST /api/categories` — List/Create
- `PATCH/DELETE /api/categories/:id` — Update/Delete
- `GET/POST /api/filters?categoryId=` — List/Create
- `PATCH/DELETE /api/filters/:id` — Update/Delete
- `GET /api/products/stats` — Product statistics
- `GET/POST /api/products` — List/Create (supports: search, categoryId, condition, minPrice, maxPrice, page, limit)
- `GET/PATCH/DELETE /api/products/:id` — CRUD
- `GET/POST /api/blog` — List/Create (supports: published, page, limit)
- `GET/PATCH/DELETE /api/blog/:slug` — CRUD
- `GET/POST /api/partners` — List/Create
- `DELETE /api/partners/:id` — Delete
- `POST /api/storage/uploads/request-url` — Presigned upload URL
- `GET /api/storage/objects/*` — Serve private objects
- `GET /api/storage/public-objects/*` — Serve public objects

## Design System
- Dark industrial theme (charcoal #1a1a1a / #111 backgrounds)
- Gold/orange accent (#d97706 / amber-600)
- Inter font (Google Fonts)
- Custom Tailwind v4 CSS variables defined in `index.css`

## i18n
- `src/i18n/bg.json` — Bulgarian translations (default)
- `src/i18n/en.json` — English translations
- `src/i18n/useTranslation.tsx` — LocaleContext + useTranslation hook
- Locale detected from URL: starts with `/en` = English, else Bulgarian

## Auth
- Session-based using express-session + SESSION_SECRET env var
- `src/hooks/use-auth.tsx` — AuthContext + useAuth hook
- `src/components/admin-guard.tsx` — AdminGuard component

## Seeds
Run: `pnpm --filter @workspace/scripts run seed`
Creates: admin user, 4 categories, 5 sample products, 2 blog posts, 5 partner entries

## Environment Variables
- `DATABASE_URL` — PostgreSQL connection string
- `SESSION_SECRET` — Express session secret
- `DEFAULT_OBJECT_STORAGE_BUCKET_ID` — GCS bucket for object storage
- `PRIVATE_OBJECT_DIR` — Private objects directory prefix
- `PUBLIC_OBJECT_SEARCH_PATHS` — Public object search paths
- `SITE_URL` — Canonical production domain (e.g. `https://nickmasch.bg`). Must be set in both dev and production deployment secrets. Used by `prerender.mjs` for canonical/hreflang injection and by the dynamic `/sitemap.xml` endpoint. Defaults to `https://nickmasch.bg` if unset.

## Key Commands
```bash
pnpm --filter @workspace/db run push        # Push DB schema
pnpm --filter @workspace/api-spec run codegen  # Regenerate API hooks
pnpm --filter @workspace/scripts run seed   # Seed database
pnpm run typecheck                          # Full typecheck
```
