|
| 1 | +# WARP.md |
| 2 | + |
| 3 | +This file provides guidance to WARP (warp.dev) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +**Star Sailors** is a Next.js 14 application for space exploration, citizen science, and data classification. It features a complex user-centric architecture with components organized around user mechanics (classification, deployment, discovery, research, social, profile) rather than technical implementation. |
| 8 | + |
| 9 | +## Common Development Commands |
| 10 | + |
| 11 | +### Local Development |
| 12 | +```bash |
| 13 | +# Start development server (recommended) |
| 14 | +yarn dev |
| 15 | +# or using Makefile |
| 16 | +make dev |
| 17 | + |
| 18 | +# Install dependencies |
| 19 | +yarn install |
| 20 | +# or |
| 21 | +make install |
| 22 | + |
| 23 | +# Build application |
| 24 | +yarn build |
| 25 | +# or |
| 26 | +make build-app |
| 27 | +``` |
| 28 | + |
| 29 | +### Database Operations (Drizzle ORM + Supabase) |
| 30 | +```bash |
| 31 | +# Generate database schema |
| 32 | +yarn db:generate |
| 33 | + |
| 34 | +# Push schema changes to database |
| 35 | +yarn db:push |
| 36 | + |
| 37 | +# Open Drizzle Studio (database UI) |
| 38 | +yarn db:studio |
| 39 | +# or via Docker |
| 40 | +make db-studio |
| 41 | + |
| 42 | +# Database migrations |
| 43 | +yarn db:migrate |
| 44 | +``` |
| 45 | + |
| 46 | +### Testing |
| 47 | + |
| 48 | +#### Unit Testing (Vitest) |
| 49 | +```bash |
| 50 | +# Run unit tests |
| 51 | +yarn test:unit |
| 52 | + |
| 53 | +# Run unit tests in watch mode |
| 54 | +yarn test:unit:watch |
| 55 | + |
| 56 | +# Run unit tests in Docker (isolated) |
| 57 | +yarn docker:test:unit |
| 58 | +``` |
| 59 | + |
| 60 | +#### E2E Testing (Cypress) |
| 61 | +```bash |
| 62 | +# Run E2E tests headless |
| 63 | +yarn test:e2e |
| 64 | + |
| 65 | +# Run E2E tests with Cypress UI |
| 66 | +yarn test:e2e:open |
| 67 | + |
| 68 | +# Run E2E tests with user creation (local) |
| 69 | +yarn test:e2e:local |
| 70 | + |
| 71 | +# Run E2E tests in Docker |
| 72 | +yarn docker:test:e2e |
| 73 | +yarn docker:test:e2e:local |
| 74 | +``` |
| 75 | + |
| 76 | +#### Comprehensive Testing |
| 77 | +```bash |
| 78 | +# Run all tests (unit + E2E) |
| 79 | +yarn test:all |
| 80 | +yarn docker:test:all |
| 81 | + |
| 82 | +# Clean Docker test resources |
| 83 | +yarn docker:test:clean |
| 84 | +``` |
| 85 | + |
| 86 | +### Docker Operations |
| 87 | +```bash |
| 88 | +# Development with Docker |
| 89 | +docker-compose up |
| 90 | +# or |
| 91 | +make up |
| 92 | + |
| 93 | +# Production deployment |
| 94 | +docker-compose -f docker-compose.prod.yml up -d |
| 95 | +# or |
| 96 | +make prod-up |
| 97 | + |
| 98 | +# Test environment |
| 99 | +docker-compose -f docker-compose.test.yml --profile unit up |
| 100 | +docker-compose -f docker-compose.test.yml --profile e2e up |
| 101 | +``` |
| 102 | + |
| 103 | +### Linting and Code Quality |
| 104 | +```bash |
| 105 | +# Next.js linting |
| 106 | +yarn lint |
| 107 | + |
| 108 | +# Detect unused dependencies |
| 109 | +yarn knip |
| 110 | +``` |
| 111 | + |
| 112 | +### Single Test Execution |
| 113 | +```bash |
| 114 | +# Run specific Cypress test |
| 115 | +npx cypress run --spec "cypress/e2e/specific-test.cy.ts" |
| 116 | + |
| 117 | +# Run specific unit test |
| 118 | +npx vitest run path/to/test.test.ts |
| 119 | + |
| 120 | +# Run tests matching pattern |
| 121 | +npx vitest run --reporter=verbose --grep "test pattern" |
| 122 | +``` |
| 123 | + |
| 124 | +## Architecture Overview |
| 125 | + |
| 126 | +### File Organization |
| 127 | +The codebase uses a **user-centric component architecture** rather than technical grouping: |
| 128 | + |
| 129 | +- **`src/components/classification/`** - Image/data classification mechanics (viewports, telescopes, AI tools) |
| 130 | +- **`src/components/deployment/`** - Structure & mission deployment (buildings, equipment, missions) |
| 131 | +- **`src/components/discovery/`** - Exploration & data discovery (planets, anomalies, weather) |
| 132 | +- **`src/components/research/`** - Scientific progression (projects, skill trees) |
| 133 | +- **`src/components/social/`** - Community features (comments, posts, activity) |
| 134 | +- **`src/components/profile/`** - User management (auth, dashboard, inventory) |
| 135 | +- **`src/components/ui/`** - Reusable UI components |
| 136 | +- **`src/components/layout/`** - Application layout components |
| 137 | + |
| 138 | +### Core Architecture |
| 139 | +- **`app/`** - Next.js 14 App Router with file-based routing |
| 140 | +- **`src/core/`** - Core application logic and context providers |
| 141 | +- **`src/shared/`** - Shared utilities and helper functions |
| 142 | +- **`lib/`** - External library configurations |
| 143 | +- **`hooks/`** - Custom React hooks |
| 144 | +- **`types/`** - TypeScript type definitions |
| 145 | + |
| 146 | +### Key Technologies |
| 147 | +- **Frontend**: Next.js 14, React 18, TypeScript, Tailwind CSS |
| 148 | +- **Database**: Supabase with Drizzle ORM (PostgreSQL) |
| 149 | +- **3D Graphics**: Three.js with React Three Fiber |
| 150 | +- **Testing**: Vitest (unit), Cypress (E2E) |
| 151 | +- **Styling**: Tailwind CSS, Radix UI, Framer Motion |
| 152 | +- **Auth**: Supabase Auth with NextAuth helpers |
| 153 | + |
| 154 | +### Import Patterns |
| 155 | +```typescript |
| 156 | +// Absolute imports using @ alias |
| 157 | +import { Component } from '@/src/components/classification/...' |
| 158 | +import { utility } from '@/src/shared/utils' |
| 159 | +import { type } from '@/types/...' |
| 160 | + |
| 161 | +// UI components |
| 162 | +import { Button } from '@/src/components/ui/button' |
| 163 | +``` |
| 164 | + |
| 165 | +### Environment Configuration |
| 166 | +- **`.env`** - Production environment variables |
| 167 | +- **`.env.local`** - Local development overrides |
| 168 | +- **`.env.example`** - Template with required variables |
| 169 | +- **`.env.test`** - Testing environment configuration |
| 170 | + |
| 171 | +### Docker Architecture |
| 172 | + |
| 173 | +#### Container Services |
| 174 | +- **nextapp**: Main Next.js application container |
| 175 | +- **nextapp-test**: Test application server |
| 176 | +- **unit-tests**: Isolated unit testing service |
| 177 | +- **e2e-tests-headless**: Headless E2E testing |
| 178 | +- **e2e-tests-local**: Local E2E testing with user creation |
| 179 | +- **db**: PostgreSQL database |
| 180 | +- **redis**: Redis cache |
| 181 | +- **drizzle-studio**: Database UI tool |
| 182 | + |
| 183 | +#### Testing Profiles |
| 184 | +- **`unit`**: Fast, isolated unit testing |
| 185 | +- **`e2e`**: Full application integration testing |
| 186 | +- **`local-test`**: Comprehensive testing with user creation |
| 187 | +- **`all`**: Complete test suite validation |
| 188 | + |
| 189 | +### Flask API Integration |
| 190 | +The application integrates with a Flask backend for citizen science features: |
| 191 | +- Flask routes are proxied through Next.js using `/citizen/*` paths |
| 192 | +- Development uses `http://flask:5001` container communication |
| 193 | +- API routes remain at `/api/*` for Next.js server functions |
| 194 | + |
| 195 | +### Key Development Notes |
| 196 | +- Components are organized by **user mechanics** not technical implementation |
| 197 | +- Database schema is managed through Drizzle ORM in `src/core/database/schema.ts` |
| 198 | +- All routes have been validated for the user-centric reorganization |
| 199 | +- Docker testing environment provides consistent CI/CD integration |
| 200 | +- Three.js components use React Three Fiber patterns |
| 201 | +- Supabase handles authentication, real-time subscriptions, and data storage |
| 202 | + |
| 203 | +### Testing Strategy |
| 204 | +- **Unit tests** focus on individual component logic and utilities |
| 205 | +- **E2E tests** cover complete user workflows and integration scenarios |
| 206 | +- **Docker profiles** enable different testing scopes (unit, e2e, combined) |
| 207 | +- Tests can skip user creation with `SKIP_USER_CREATION_TESTS=true` |
0 commit comments