|
1 | | -# Exercism Website |
| 1 | +# Exercism Website - GitHub Copilot Instructions |
2 | 2 |
|
3 | | -Exercism Website is a comprehensive Ruby on Rails application with React/TypeScript frontend that provides the main website for the Exercism platform. It's a complex application with multiple services, databases, and build processes. |
4 | | - |
5 | | -Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here. |
6 | | - |
7 | | -## Documentation |
8 | | - |
9 | | -There is a subdirectory called `docs/llm-support` which contains detailed information that an LLM might find useful on different areas of the application. When working with specific components, always reference the RELEVANT docs in that directory first: |
10 | | - |
11 | | -- `running-the-app.md` - Complete guide for environment setup, dependencies, and running the application |
12 | | -- `API.md` - Detailed API architecture, authentication, and patterns |
13 | | -- `SPI.md` - Service Provider Interface for internal AWS services |
14 | | -- `commands.md` - Complete Command Pattern documentation with Mandate gem usage |
15 | | -- `serializers.md` - Data serialization patterns for JSON API responses |
16 | | -- `assemblers.md` - Data assembly patterns for consistent API and SSR responses |
17 | | -- `view-components.md` - Server-side component architecture with encapsulated logic |
18 | | -- `react-components.md` - Client-side React component integration and data passing |
19 | | -- `testing/` - Comprehensive testing patterns for models, commands, controllers, and system tests |
20 | | - |
21 | | -These files provide comprehensive context that supplements the workflow guidance in this document. |
22 | | - |
23 | | -## Working Effectively |
24 | | - |
25 | | -For comprehensive guidance on environment setup, dependency installation, building assets, running tests, and starting the development server, see [`docs/llm-support/running-the-app.md`](../docs/llm-support/running-the-app.md). |
26 | | - |
27 | | -## Validation and Testing |
28 | | - |
29 | | -### Manual Validation Requirements |
30 | | -After making changes, ALWAYS test core functionality: |
31 | | -1. Browse to http://localhost:3020 |
32 | | -2. Test user registration/login flow |
33 | | -3. Navigate key sections (tracks, exercises, community) |
34 | | -4. Test JavaScript interactions (code editor, modals) |
35 | | -5. Verify CSS styling renders correctly |
36 | | - |
37 | | -### Pre-commit Validation |
38 | | -ALWAYS run before committing (for changed files only): |
39 | | -```bash |
40 | | -bundle exec rubocop --except Metrics |
41 | | -yarn test |
42 | | -bundle exec rails test:zeitwerk |
43 | | -``` |
44 | | - |
45 | | -## Critical Warnings and Limitations |
46 | | - |
47 | | -### Build Timing - NEVER CANCEL |
48 | | -- **Bundle install: 15-20 minutes** - Native extensions for grpc, skylight, commonmarker take time |
49 | | -- **Ruby test suite: 10-15 minutes** - Full suite with database operations |
50 | | -- **System tests: 15-20 minutes** - Browser automation with Capybara/Selenium |
51 | | -- **Asset builds: 2-5 minutes each** - CSS and JavaScript compilation |
52 | | - |
53 | | -### Authentication Requirements |
54 | | -- **NPM Token required**: Private package access needs `NPM_TOKEN` environment variable |
55 | | -- **AWS LocalStack**: Required for S3, DynamoDB, and other AWS service mocking |
56 | | -- **Database credentials**: Must match config/database.yml settings |
57 | | - |
58 | | -### Version Dependencies (CRITICAL) |
59 | | -- **Ruby 3.4.4**: Exact version required - Gemfile.lock specifies this |
60 | | -- **Node.js 20+**: Required for esbuild and modern JS features |
61 | | -- **MySQL 5.7**: Database schema depends on this version |
62 | | -- **Bundler 2.6.9**: Locked version in Gemfile.lock |
63 | | - |
64 | | -### Known Limitations |
65 | | -- Ruby version managers (setup-ruby and chruby) recommended for version management |
66 | | -- Some JS packages require private NPM access (will fail in some environments) |
67 | | -- Docker services must be running before Rails server starts |
68 | | -- Database must be properly configured with utf8mb4 collation |
69 | | -- Large codebase - initial setup can take 30+ minutes total |
70 | | - |
71 | | -## Important Directories |
72 | | - |
73 | | -### Application Structure |
74 | | -- `app/controllers/` - Rails controllers |
75 | | -- `app/models/` - ActiveRecord models and business logic |
76 | | -- `app/commands/` - Mandate command objects for business logic (see Command Pattern below) |
77 | | -- `app/javascript/` - React/TypeScript frontend code |
78 | | -- `app/css/` - PostCSS stylesheets with Tailwind |
79 | | -- `app/views/` - HAML view templates |
80 | | -- `test/` - All test files (unit, integration, system) |
81 | | -- `test/system/` - Capybara system tests |
82 | | -- `test/javascript/` - Jest test files |
83 | | - |
84 | | -## Command Pattern with Mandate |
85 | | - |
86 | | -**Exercism uses the command pattern for most business logic operations.** The `/app/commands` directory contains command objects that encapsulate business logic using the Mandate gem. |
87 | | - |
88 | | -For comprehensive documentation on command structure, patterns, and implementation details, see [`docs/llm-support/commands.md`](../docs/llm-support/commands.md). |
89 | | - |
90 | | -### API, SPI and Route Architecture |
91 | | - |
92 | | -For detailed information about API and SPI architectures, see: |
93 | | -- [`docs/llm-support/API.md`](../docs/llm-support/API.md) - API endpoints, authentication, and patterns |
94 | | -- [`docs/llm-support/SPI.md`](../docs/llm-support/SPI.md) - Internal service endpoints and AWS integration |
95 | | - |
96 | | -#### Quick Reference |
97 | | - |
98 | | -#### API Routes (`/api`) |
99 | | - |
100 | | -Public endpoints for authenticated users (CLI, frontend, third-party integrations) |
101 | | -- Require Bearer token authentication |
102 | | -- Delegate business logic to Mandate commands |
103 | | -- Consistent JSON error responses |
104 | | -- Routes defined in `config/routes/api.rb` |
105 | | - |
106 | | -#### SPI Routes (`/spi`) |
107 | | - |
108 | | -Internal endpoints for AWS Lambda functions and microservices |
109 | | -- No application-level authentication (secured at AWS infrastructure level) |
110 | | -- Used by Lambda functions to post results back to main application |
111 | | -- Routes defined in `config/routes/spi.rb` |
112 | | - |
113 | | -#### Standard Routes |
114 | | - |
115 | | -Regular Rails routes for user-facing web pages, authentication flows, webhooks, and admin interfaces. |
116 | | - |
117 | | -### Configuration |
118 | | -- `config/database.yml` - Database configuration |
119 | | -- `Procfile.dev` - Development server orchestration |
120 | | -- `.dockerimages.json` - Docker service versions |
121 | | -- `package.json` - JavaScript dependencies and scripts |
122 | | -- `Gemfile` - Ruby dependencies |
123 | | - |
124 | | -### Build System |
125 | | -- `app/javascript/esbuild.js` - JavaScript build configuration |
126 | | -- `postcss.config.js` - CSS build configuration |
127 | | -- `tailwind.config.js` - Tailwind CSS customization |
128 | | - |
129 | | -## Common Tasks and Debugging |
130 | | - |
131 | | -### Database Issues |
132 | | -- Reset database: `bundle exec rails db:drop db:create db:migrate db:seed` |
133 | | -- Check migrations: `bundle exec rails db:migrate:status` |
134 | | - |
135 | | -### Asset Issues |
136 | | - |
137 | | -- Clear assets: `rm -rf .built-assets/` |
138 | | -- Rebuild: `yarn build:css && yarn build` |
139 | | - |
140 | | -### Service Issues |
141 | | -- Check Docker services: `docker ps` |
142 | | -- Restart LocalStack: `docker restart <localstack-container-id>` |
143 | | -- Check AnyCable: `bundle exec anycable --version` |
144 | | - |
145 | | -### Common Error Patterns |
146 | | -- "Ruby version mismatch": Install Ruby 3.4.4 exactly |
147 | | -- "NPM authentication failed": Need NPM_TOKEN for private packages |
148 | | -- "Database connection failed": Check MySQL service and credentials |
149 | | -- "Asset compilation failed": Ensure Node.js and Yarn versions are compatible |
150 | | - |
151 | | -This setup is complex but necessary for the full Exercism platform. When in doubt, refer to the CI configuration in `.github/workflows/tests.yml` for authoritative build commands and timing expectations. |
152 | | - |
153 | | -## Testing Patterns |
154 | | - |
155 | | -There are tests for models, commands, controllers, and system testing - check the docs in `docs/llm-support/testing/...` for comprehensive details when creating or amending tests. |
| 3 | +For comprehensive documentation about this codebase, see the `/AGENTS.md` file in the repository root. |
0 commit comments