# AI Resource Pro - airesourcepro.com This is the repository for the AI Resource Pro website ([airesourcepro.com](https://airesourcepro.com)), a platform dedicated to providing resources related to Artificial Intelligence. ## Project Overview AI Resource Pro is built using a modern web stack focused on performance, developer experience, and scalability. It utilizes Supabase for backend services like authentication and database management, and is deployed on Plesk. ## Tech Stack * **Framework:** [Next.js](https://nextjs.org/) (with React) * **Language:** [TypeScript](https://www.typescriptlang.org/) * **Styling:** [Tailwind CSS](https://tailwindcss.com/) * **UI Components:** [shadcn/ui](https://ui.shadcn.com/) * **Database ORM:** [Prisma](https://www.prisma.io/) * **Backend & Auth:** [Supabase](https://supabase.com/) * **Containerization:** [Docker](https://www.docker.com/) (for development/deployment consistency) ## Key Features * **AI Tool Directory:** Curated list of AI tools, filterable by category. * **Learning Resources:** Educational content related to AI. * **News Feed:** Latest news in the AI space. * **AI Coach:** Personalized AI learning recommendations. * **Admin Dashboard:** Interface for managing content (Tools, Learning, News, Categories, Users). * **API:** Provides data access for various parts of the application. ## Getting Started 1. **Clone the repository:** ```bash git clone cd airesource-pro-site ``` 2. **Install dependencies:** ```bash npm install ``` 3. **Set up environment variables:** * Copy the example environment file: `cp .env.example .env.local` * Fill in the required values in `.env.local`, especially Supabase credentials (`NEXT_PUBLIC_SUPABASE_URL`, `NEXT_PUBLIC_SUPABASE_ANON_KEY`, `SUPABASE_SERVICE_ROLE_KEY`) and the API key (`AI_RESOURCE_PRO_API_KEY`). * **Important Security Note:** Ensure `BYPASS_AUTH_IN_DEV` is **never** set to `true` unless specifically for isolated local testing, and **never** commit it as `true`. 4. **Set up Supabase:** * Ensure your local Supabase instance (if using Docker) or your remote Supabase project is running and configured according to the project's schema (potentially using Prisma migrations). Refer to `supabase/` directory and Prisma schema if needed. 5. **Run Prisma migrations (if necessary):** ```bash npx prisma migrate dev # or apply deployments if targeting a specific environment npx prisma migrate deploy ``` 6. **Run the development server:** ```bash npm run dev ``` 7. Open [http://localhost:3001](http://localhost:3001) in your browser. ## Authentication * **Primary Method:** Supabase Authentication (JWT-based, handled via Supabase client libraries). Admin access relies on Supabase user roles. * **Secondary Method (API):** API Key (`AI_RESOURCE_PRO_API_KEY` set in `.env.local`). Required for certain backend API routes when not authenticated via Supabase. Include the header `x-api-key: YOUR_API_KEY`. ## API Endpoints The application exposes various API endpoints under `/api/`. Key areas include: * `/api/admin/...`: Endpoints for the admin dashboard (require Supabase admin authentication). * `/api/auth/...`: Authentication-related endpoints (login, logout, status checks). * `/api/tools`: CRUD operations for AI tools. * `/api/learning`: CRUD operations for learning resources. * `/api/news`: CRUD operations for news articles. * `/api/categories`: CRUD operations for categories. * `/api/featured-tools`, `/api/featured-learning`: Endpoints for featured content. * `/api/faqs`: Endpoint for FAQs. * `/api/ai-coach/...`: Endpoints for the AI Coach feature. * `/api/webhooks/midjourney`: Webhook for Midjourney image generation updates. * `/api/revalidate`: On-demand cache revalidation for content updates. * `/api/health-check`: Basic health check endpoint. *(For detailed request/response formats and parameters, please refer to the respective route handler files within `src/app/api/`)* ## Caching and Revalidation Blog posts, news, and potentially other content types utilize Next.js caching. * Dynamic pages often use `export const dynamic = 'force-dynamic'` or similar strategies for fresh data. * The `/api/revalidate` endpoint allows invalidating specific paths (e.g., `/api/revalidate?path=/news/[slug]`) when content is updated via the admin panel, ensuring users see the latest information. ## Testing * **Unit/Integration Tests:** Located in `src/__tests__/`. Run using: ```bash npm test # or yarn test, pnpm test ``` * **E2E Tests (Selenium):** Refer to the "Selenium Testing" section in the previous README version or relevant test files if applicable. Ensure WebDriver and browser drivers are installed. ## Deployment * The application is deployed on a Plesk server. * Configuration for PM2 (process manager) might be present in `ecosystem.config.js`. * Ensure environment variables are correctly set on the production server. ## Color Palette ### Light Theme * **Primary:** `#1a1a1a` * **Secondary Accent:** `#46AAE9` * **Text:** `#000000` * **Background:** `#ffffff` ### Dark Theme * **Primary:** `#ffffff` * **Secondary Accent:** `#46AAE9` * **Text:** `#ffffff` * **Background:** `#1a1a1a` ## Contribution Guidelines * Follow the coding patterns and separation rules outlined in `.roo/rules/rules.md`. * Write clean, simple, and maintainable code. * Avoid code duplication (DRY principle). * Ensure changes are well-tested. * Keep files focused (Single Responsibility Principle). Aim for < 300 lines per file. * Update this README if significant changes are made to the stack, architecture, or setup process.