|
| 1 | +--- |
| 2 | +name: gamers-fe-guide |
| 3 | +description: Comprehensive guide to the GAMERS-FE project structure, tech stack, and development patterns. |
| 4 | +--- |
| 5 | + |
| 6 | +# GAMERS-FE Project Skill |
| 7 | + |
| 8 | +## Project Overview |
| 9 | +GAMERS-FE is a Next.js 16 application built with TypeScript and Tailwind CSS v4. It serves as the frontend for a gaming platform/community service, featuring contest management, user profiles, and game integrations (Valorant, LoL). |
| 10 | + |
| 11 | +## Tech Stack |
| 12 | +- **Framework**: Next.js 16.1.1 (App Router) |
| 13 | +- **Language**: TypeScript 5.x |
| 14 | +- **Styling**: |
| 15 | + - Tailwind CSS v4 |
| 16 | + - `clsx` & `tailwind-merge` for class management |
| 17 | + - Framer Motion & GSAP for animations |
| 18 | +- **State Management**: |
| 19 | + - React Query (`@tanstack/react-query`) for server state |
| 20 | + - React Context for global UI state |
| 21 | +- **Form Handling**: React Hook Form (`react-hook-form`) + Zod validation |
| 22 | +- **API Client**: Custom Axios wrapper (`@/lib/api-client`) |
| 23 | +- **I18n**: `i18next` & `react-i18next` |
| 24 | +- **Package Manager**: npm |
| 25 | + |
| 26 | +## Directory Structure |
| 27 | +- `src/app`: Next.js App Router pages and layouts. |
| 28 | +- `src/components`: |
| 29 | + - `ui`: Reusable UI components (Buttons, Inputs, Modals). |
| 30 | + - `contest`: Contest-related components. |
| 31 | + - `admin`: Admin dashboard components. |
| 32 | + - `layout`: Layout components (Header, Footer). |
| 33 | +- `src/services`: API service modules. |
| 34 | +- `src/types`: TypeScript definitions, especially API responses (`api.ts`). |
| 35 | +- `src/lib`: Utility libraries and configurations (e.g., `api-client`). |
| 36 | +- `src/hooks`: Custom React hooks. |
| 37 | +- `src/utils`: Helper functions. |
| 38 | +- `src/locales`: i18n translation files. |
| 39 | + |
| 40 | +## Key Development Patterns |
| 41 | + |
| 42 | +### 1. API Integration |
| 43 | +- **Do not** make direct `fetch` or `axios` calls in components. |
| 44 | +- **Always** create a service function in `src/services/` using the `api` client. |
| 45 | +- Define request/response types in `src/types/api.ts`. |
| 46 | +- Use the `api` client from `@/lib/api-client`. |
| 47 | + |
| 48 | +**Example:** |
| 49 | +`src/services/user-service.ts` |
| 50 | +```typescript |
| 51 | +import { api } from '@/lib/api-client'; |
| 52 | +import { UserResponse, ApiResponse } from '@/types/api'; |
| 53 | + |
| 54 | +export const getUser = async (id: number) => { |
| 55 | + return api.get<ApiResponse<UserResponse>>(`/users/${id}`); |
| 56 | +}; |
| 57 | +``` |
| 58 | + |
| 59 | +### 2. Styling Rules |
| 60 | +- Use Tailwind CSS utility classes found in `src/app/globals.css` (or implicitly via Tailwind v4). |
| 61 | +- Use the configured custom colors: `deep-black`, `neon-cyan`, `neon-purple`. |
| 62 | +- For conditional classes, use `cn()` (or `clsx` + `tailwind-merge`). |
| 63 | + |
| 64 | +**Example:** |
| 65 | +```tsx |
| 66 | +import { cn } from "@/lib/utils"; // or explicit imports |
| 67 | + |
| 68 | +<div className={cn("p-4 rounded-lg", isActive ? "bg-neon-cyan" : "bg-gray-800")}> |
| 69 | + Content |
| 70 | +</div> |
| 71 | +``` |
| 72 | + |
| 73 | +### 3. Component Structure |
| 74 | +- Use functional components with TypeScript interfaces for props. |
| 75 | +- Place reusable generic components in `src/components/ui`. |
| 76 | +- Place feature-specific components in `src/components/[feature]`. |
| 77 | +- Use `export default` or named exports consistently (check existing files). |
| 78 | + |
| 79 | +### 4. Form Handling |
| 80 | +- Use `useForm` from `react-hook-form`. |
| 81 | +- Define validation schemas with `zod`. |
| 82 | +- Use `zodResolver` to integrate them. |
| 83 | + |
| 84 | +### 5. Config Files |
| 85 | +- `next.config.ts`: Image domains (`images.unsplash.com`, `discord`, etc.) and redirects. |
| 86 | +- `tailwind.config.ts`: Custom theme extensions. |
| 87 | + |
| 88 | +## Development Workflow |
| 89 | +- **Start Dev Server**: `npm run dev` |
| 90 | +- **Build for Production**: `npm run build` |
| 91 | +- **Lint Code**: `npm run lint` |
| 92 | + |
| 93 | +## Critical Rules |
| 94 | +1. **Never** use `any` type implicitly or explicitly if possible. |
| 95 | +2. **Always** check `swagger.yaml` or backend docs before creating new API types. |
| 96 | +3. **Follow** the existing folder structure when adding new files. |
0 commit comments