From 98044f46d06951a437a730582b413148314978e1 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 11 Sep 2025 09:36:27 +0000 Subject: [PATCH] feat: Initial project setup and configuration Co-authored-by: davidpetkov06 --- .env.example | 28 ++++++++ .github/workflows/ci.yml | 102 ++++++++++++++++++++++++++ .gitignore | 127 +++++++++++++++++++++++++++++++-- .prettierignore | 128 +++++++++++++++++++++++++++++++++ .prettierrc | 18 +++++ Dockerfile | 57 +++++++++++++++ README.md | 150 +++++++++++++++++++++++++-------------- package.json | 21 +++++- scripts/setup.sh | 65 +++++++++++++++++ 9 files changed, 638 insertions(+), 58 deletions(-) create mode 100644 .env.example create mode 100644 .github/workflows/ci.yml create mode 100644 .prettierignore create mode 100644 .prettierrc create mode 100644 Dockerfile create mode 100755 scripts/setup.sh diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..de06e77 --- /dev/null +++ b/.env.example @@ -0,0 +1,28 @@ +# Environment Configuration Example +# Copy this file to .env.local and fill in your actual values + +# Next.js Configuration +NEXT_PUBLIC_APP_URL=http://localhost:3000 +NEXT_PUBLIC_APP_NAME="stox.bg" +NEXT_PUBLIC_APP_DESCRIPTION="stox.bg – проект на Devids" + +# Supabase Configuration +NEXT_PUBLIC_SUPABASE_URL=your_supabase_url_here +NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key_here +SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key_here + +# Analytics & Monitoring +NEXT_PUBLIC_GA_MEASUREMENT_ID=your_google_analytics_id_here +NEXT_PUBLIC_VERCEL_ANALYTICS_ID=your_vercel_analytics_id_here + +# External APIs +NEXT_PUBLIC_NEWS_API_KEY=your_news_api_key_here +NEXT_PUBLIC_FINANCIAL_API_KEY=your_financial_api_key_here + +# Security +NEXTAUTH_SECRET=your_nextauth_secret_here +NEXTAUTH_URL=http://localhost:3000 + +# Development +NODE_ENV=development +NEXT_TELEMETRY_DISABLED=1 \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..cc0a533 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,102 @@ +name: CI/CD Pipeline + +on: + push: + branches: [main, develop] + pull_request: + branches: [main, develop] + +jobs: + lint-and-type-check: + name: Lint and Type Check + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Run ESLint + run: npm run lint + + - name: Run TypeScript type check + run: npm run type-check + + - name: Check Prettier formatting + run: npm run format:check + + build-and-test: + name: Build and Test + runs-on: ubuntu-latest + needs: lint-and-type-check + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Build application + run: npm run build + env: + NEXT_PUBLIC_APP_URL: https://stox.bg + + - name: Upload build artifacts + uses: actions/upload-artifact@v4 + with: + name: build-files + path: .next/ + + deploy-preview: + name: Deploy Preview + runs-on: ubuntu-latest + needs: build-and-test + if: github.event_name == 'pull_request' + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Download build artifacts + uses: actions/download-artifact@v4 + with: + name: build-files + path: .next/ + + - name: Deploy to Vercel Preview + uses: amondnet/vercel-action@v25 + with: + vercel-token: ${{ secrets.VERCEL_TOKEN }} + vercel-org-id: ${{ secrets.VERCEL_ORG_ID }} + vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} + working-directory: ./ + + deploy-production: + name: Deploy Production + runs-on: ubuntu-latest + needs: build-and-test + if: github.ref == 'refs/heads/main' && github.event_name == 'push' + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Deploy to Vercel Production + uses: amondnet/vercel-action@v25 + with: + vercel-token: ${{ secrets.VERCEL_TOKEN }} + vercel-org-id: ${{ secrets.VERCEL_ORG_ID }} + vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} + vercel-args: '--prod' + working-directory: ./ \ No newline at end of file diff --git a/.gitignore b/.gitignore index 5ef6a52..4cce8ad 100644 --- a/.gitignore +++ b/.gitignore @@ -30,12 +30,131 @@ yarn-debug.log* yarn-error.log* .pnpm-debug.log* -# env files (can opt-in for committing if needed) -.env* +# Environment files +.env +.env.local +.env.development.local +.env.test.local +.env.production.local +.env.*.local -# vercel +# Vercel .vercel -# typescript +# TypeScript *.tsbuildinfo next-env.d.ts + +# IDE and Editor files +.vscode/ +.idea/ +*.swp +*.swo +*~ + +# OS generated files +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db + +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* +.pnpm-debug.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Coverage directory used by tools like istanbul +coverage/ +*.lcov + +# nyc test coverage +.nyc_output + +# Dependency directories +node_modules/ +jspm_packages/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next/ +out/ + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +public + +# Storybook build outputs +.out +.storybook-out + +# Temporary folders +tmp/ +temp/ + +# Docker +.dockerignore +Dockerfile.dev + +# Database +*.sqlite +*.db + +# Backup files +*.bak +*.backup +*.old + +# Security +*.pem +*.key +*.crt +*.p12 +*.pfx + +# Analytics and monitoring +lighthouse-report.html +*.lighthouse.html + +# Performance monitoring +.web-vitals.json diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..be5d2d0 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,128 @@ +# Dependencies +node_modules/ +.pnp +.pnp.js + +# Production builds +.next/ +out/ +build/ +dist/ + +# Environment files +.env* + +# Logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Coverage directory used by tools like istanbul +coverage/ + +# nyc test coverage +.nyc_output + +# Dependency directories +node_modules/ +jspm_packages/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Microbundle cache +.rpt2_cache/ +.rts2_cache_cjs/ +.rts2_cache_es/ +.rts2_cache_umd/ + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# parcel-bundler cache (https://parceljs.org/) +.cache +.parcel-cache + +# Next.js build output +.next/ +out/ + +# Nuxt.js build / generate output +.nuxt +dist + +# Gatsby files +.cache/ +public + +# Storybook build outputs +.out +.storybook-out + +# Temporary folders +tmp/ +temp/ + +# OS generated files +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db + +# IDE files +.vscode/ +.idea/ + +# Package lock files +package-lock.json +yarn.lock +pnpm-lock.yaml + +# Generated files +*.tsbuildinfo +next-env.d.ts + +# Vercel +.vercel + +# Database +*.sqlite +*.db + +# Backup files +*.bak +*.backup +*.old + +# Security +*.pem +*.key +*.crt +*.p12 +*.pfx + +# Analytics and monitoring +lighthouse-report.html +*.lighthouse.html + +# Performance monitoring +.web-vitals.json \ No newline at end of file diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..ff7466a --- /dev/null +++ b/.prettierrc @@ -0,0 +1,18 @@ +{ + "semi": true, + "trailingComma": "es5", + "singleQuote": false, + "printWidth": 80, + "tabWidth": 2, + "useTabs": false, + "endOfLine": "lf", + "arrowParens": "avoid", + "bracketSpacing": true, + "bracketSameLine": false, + "quoteProps": "as-needed", + "jsxSingleQuote": false, + "proseWrap": "preserve", + "htmlWhitespaceSensitivity": "css", + "embeddedLanguageFormatting": "auto", + "plugins": ["prettier-plugin-tailwindcss"] +} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..80be442 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,57 @@ +# Use the official Node.js 18 image as the base image +FROM node:18-alpine AS base + +# Install dependencies only when needed +FROM base AS deps +# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed. +RUN apk add --no-cache libc6-compat +WORKDIR /app + +# Install dependencies based on the preferred package manager +COPY package.json package-lock.json* ./ +RUN npm ci --only=production + +# Rebuild the source code only when needed +FROM base AS builder +WORKDIR /app +COPY --from=deps /app/node_modules ./node_modules +COPY . . + +# Next.js collects completely anonymous telemetry data about general usage. +# Learn more here: https://nextjs.org/telemetry +# Uncomment the following line in case you want to disable telemetry during the build. +ENV NEXT_TELEMETRY_DISABLED 1 + +RUN npm run build + +# Production image, copy all the files and run next +FROM base AS runner +WORKDIR /app + +ENV NODE_ENV production +ENV NEXT_TELEMETRY_DISABLED 1 + +RUN addgroup --system --gid 1001 nodejs +RUN adduser --system --uid 1001 nextjs + +COPY --from=builder /app/public ./public + +# Set the correct permission for prerender cache +RUN mkdir .next +RUN chown nextjs:nodejs .next + +# Automatically leverage output traces to reduce image size +# https://nextjs.org/docs/advanced-features/output-file-tracing +COPY --from=builder --chown=nextjs:nodejs /app/.next/standalone ./ +COPY --from=builder --chown=nextjs:nodejs /app/.next/static ./.next/static + +USER nextjs + +EXPOSE 3000 + +ENV PORT 3000 +ENV HOSTNAME "0.0.0.0" + +# server.js is created by next build from the standalone output +# https://nextjs.org/docs/pages/api-reference/next-config-js/output +CMD ["node", "server.js"] \ No newline at end of file diff --git a/README.md b/README.md index 7768192..6df36ea 100644 --- a/README.md +++ b/README.md @@ -1,78 +1,124 @@ -# Next.js SSR Template +# stox.bg – проект на Devids -A high-performance, SEO-optimized Next.js template with server-side rendering capabilities, designed for modern web applications. +Високопроизводителен, SEO-оптимизиран Next.js проект с server-side rendering възможности, създаден за модерни уеб приложения. -## Features +## 🚀 Функции -- **Server-Side Rendering**: Leverages Next.js SSR for improved performance and SEO benefits -- **SEO Optimization**: Built-in metadata management, Open Graph tags, and structured data -- **TypeScript Support**: Full TypeScript integration for better type safety and developer experience -- **Tailwind CSS**: Utility-first CSS framework for rapid UI development -- **Shadcn UI Components**: Beautifully designed, accessible UI components -- **Smooth Scrolling**: Integrated Lenis for buttery-smooth scroll experiences -- **Lucide Icons**: Beautiful, consistent, open-source icons as React components -- **Responsive Design**: Fully responsive layout that works on all devices and screen sizes -- **Accessibility**: Built with accessibility in mind to ensure your app can be used by everyone -- **Performance Optimized**: Optimized for Core Web Vitals and fast loading times +- **Server-Side Rendering**: Използва Next.js SSR за подобрена производителност и SEO предимства +- **SEO Оптимизация**: Вградено управление на метаданни, Open Graph тагове и структурирани данни +- **TypeScript Поддръжка**: Пълна TypeScript интеграция за по-добра типова безопасност +- **Tailwind CSS**: Utility-first CSS фреймуърк за бърза UI разработка +- **Shadcn UI Компоненти**: Красиво дизайнирани, достъпни UI компоненти +- **Плавно Скролиране**: Интегриран Lenis за плавно скролиране +- **Lucide Икони**: Красиви, консистентни, open-source икони като React компоненти +- **Responsive Дизайн**: Напълно responsive layout за всички устройства +- **Достъпност**: Създаден с фокус върху достъпността +- **Оптимизирана Производителност**: Оптимизиран за Core Web Vitals и бързо зареждане +- **Български Език**: Пълна поддръжка за български език и локализация -## Getting Started +## 🛠️ Бързо Стартиране -### Prerequisites +### Предварителни Изисквания -- Node.js 18.17.0 or later -- npm, yarn, or pnpm +- Node.js 18.17.0 или по-нова версия +- npm, yarn, или pnpm -### Installation +### Инсталация -1. Clone this repository: +1. Клонирайте репозитория: ```bash - git clone https://github.com/yourusername/ssr-template.git - cd ssr-template + git clone https://github.com/yourusername/stox-bg.git + cd stox-bg ``` -2. Install dependencies: +2. Стартирайте автоматичната настройка: + ```bash + ./scripts/setup.sh + ``` + + Или ръчно: ```bash npm install - # or - yarn install - # or - pnpm install + cp .env.example .env.local + # Редактирайте .env.local с вашите API ключове ``` -3. Run the development server: +3. Стартирайте development сървъра: ```bash npm run dev - # or - yarn dev - # or - pnpm dev ``` -4. Open [http://localhost:3000](http://localhost:3000) in your browser to see the result. +4. Отворете [http://localhost:3000](http://localhost:3000) в браузъра си. -## Project Structure +## 📁 Структура на Проекта ``` -├── app/ # App Router pages and layouts -│ ├── about/ # About page -│ ├── contact/ # Contact page -│ ├── features/ # Features page +├── app/ # App Router страници и layouts +│ ├── about/ # За нас страница +│ ├── business/ # Бизнес страница +│ ├── contact/ # Контакти страница +│ ├── technology/ # Технологии страница +│ ├── legal/ # Правни страници +│ ├── terms/ # Условия за ползване +│ ├── c/ # Динамични страници +│ ├── api/ # API routes │ ├── layout.tsx # Root layout -│ └── page.tsx # Home page -├── components/ # Reusable components -│ ├── layout/ # Layout components (header, footer) -│ ├── providers/ # Provider components -│ └── ui/ # UI components -├── lib/ # Utility functions and libraries -│ └── seo/ # SEO utilities -├── public/ # Static assets -├── .gitignore # Git ignore file -├── components.json # shadcn UI configuration -├── next.config.ts # Next.js configuration -├── package.json # Dependencies and scripts -├── postcss.config.mjs # PostCSS configuration -├── tailwind.config.js # Tailwind CSS configuration -└── tsconfig.json # TypeScript configuration +│ └── page.tsx # Начална страница +├── components/ # Преизползваеми компоненти +│ ├── layout/ # Layout компоненти (header, footer) +│ ├── providers/ # Provider компоненти +│ ├── ui/ # UI компоненти +│ └── fastlane/ # Fastlane специфични компоненти +├── lib/ # Utility функции и библиотеки +│ ├── seo/ # SEO utilities +│ └── utils.ts # Общи utility функции +├── public/ # Статични файлове +│ └── images/ # Изображения и асети +├── scripts/ # Скриптове за автоматизация +├── guides/ # Документация и ръководства +├── .github/ # GitHub Actions workflows +├── .vscode/ # VS Code настройки +├── components.json # shadcn UI конфигурация +├── next.config.ts # Next.js конфигурация +├── tailwind.config.ts # Tailwind CSS конфигурация +├── tsconfig.json # TypeScript конфигурация +├── .prettierrc # Prettier конфигурация +├── .eslintrc.mjs # ESLint конфигурация +├── Dockerfile # Docker конфигурация +└── package.json # Зависимости и скриптове +``` + +## 🎯 Доступни Команди + +### Development +```bash +npm run dev # Стартира development сървър с Turbopack +npm run build # Създава production build +npm run start # Стартира production сървър +npm run clean # Почиства build артефакти +``` + +### Code Quality +```bash +npm run lint # Стартира ESLint +npm run lint:fix # Поправя ESLint проблеми +npm run type-check # Стартира TypeScript type checking +npm run format # Форматира кода с Prettier +npm run format:check # Проверява форматирането +``` + +### SEO & Performance +```bash +npm run seo:validate # Валидира SEO имплементацията +npm run seo:test # Стартира Lighthouse SEO тест +npm run analyze # Анализира bundle размера +``` + +### Database (когато се конфигурира) +```bash +npm run db:generate # Генерира database schema +npm run db:push # Push-ва промените в базата данни +npm run db:studio # Отваря database studio ``` ## Customization diff --git a/package.json b/package.json index 501b68a..1cf346b 100644 --- a/package.json +++ b/package.json @@ -7,9 +7,21 @@ "build": "next build", "start": "next start", "lint": "next lint", + "lint:fix": "next lint --fix", + "type-check": "tsc --noEmit", + "clean": "rm -rf .next out node_modules/.cache", "postbuild": "echo 'Using dynamic sitemap via API route'", "seo:validate": "node scripts/validate-seo.js", - "seo:test": "npx lighthouse https://stox.bg --view --output=html --output-path=./lighthouse-report.html" + "seo:test": "npx lighthouse https://stox.bg --view --output=html --output-path=./lighthouse-report.html", + "analyze": "ANALYZE=true npm run build", + "format": "prettier --write .", + "format:check": "prettier --check .", + "prepare": "husky install || true", + "test": "echo 'No tests configured yet'", + "test:watch": "echo 'No tests configured yet'", + "db:generate": "echo 'Database schema generation not configured'", + "db:push": "echo 'Database push not configured'", + "db:studio": "echo 'Database studio not configured'" }, "dependencies": { "@radix-ui/react-slot": "^1.2.3", @@ -43,6 +55,11 @@ "eslint-config-next": "15.3.2", "tailwindcss": "^4", "tw-animate-css": "^1.3.0", - "typescript": "^5" + "typescript": "^5", + "prettier": "^3.0.0", + "prettier-plugin-tailwindcss": "^0.5.0", + "@next/bundle-analyzer": "^15.3.2", + "husky": "^9.0.0", + "lint-staged": "^15.0.0" } } diff --git a/scripts/setup.sh b/scripts/setup.sh new file mode 100755 index 0000000..36ca39f --- /dev/null +++ b/scripts/setup.sh @@ -0,0 +1,65 @@ +#!/bin/bash + +# Development Setup Script for stox.bg +# This script sets up the development environment + +set -e + +echo "🚀 Setting up stox.bg development environment..." + +# Check if Node.js is installed +if ! command -v node &> /dev/null; then + echo "❌ Node.js is not installed. Please install Node.js 18+ first." + exit 1 +fi + +# Check Node.js version +NODE_VERSION=$(node -v | cut -d'v' -f2 | cut -d'.' -f1) +if [ "$NODE_VERSION" -lt 18 ]; then + echo "❌ Node.js version 18+ is required. Current version: $(node -v)" + exit 1 +fi + +echo "✅ Node.js $(node -v) detected" + +# Install dependencies +echo "📦 Installing dependencies..." +npm install + +# Create .env.local if it doesn't exist +if [ ! -f .env.local ]; then + echo "📝 Creating .env.local file..." + cp .env.example .env.local + echo "✅ .env.local created. Please update it with your actual values." +else + echo "✅ .env.local already exists" +fi + +# Install Husky for git hooks +echo "🔧 Setting up git hooks..." +npx husky install + +# Add pre-commit hook +npx husky add .husky/pre-commit "npm run lint-staged" + +# Add commit-msg hook for conventional commits +npx husky add .husky/commit-msg "npx --no -- commitlint --edit \$1" + +echo "🎉 Setup complete!" +echo "" +echo "Next steps:" +echo "1. Update .env.local with your actual API keys and secrets" +echo "2. Run 'npm run dev' to start the development server" +echo "3. Open http://localhost:3000 in your browser" +echo "" +echo "Available commands:" +echo " npm run dev - Start development server" +echo " npm run build - Build for production" +echo " npm run start - Start production server" +echo " npm run lint - Run ESLint" +echo " npm run lint:fix - Fix ESLint issues" +echo " npm run type-check - Run TypeScript type checking" +echo " npm run format - Format code with Prettier" +echo " npm run clean - Clean build artifacts" +echo " npm run seo:validate - Validate SEO implementation" +echo " npm run seo:test - Run Lighthouse SEO test" \ No newline at end of file