|
1 | | -# Claude Code Configuration |
| 1 | +# CLAUDE.md |
2 | 2 |
|
3 | | -## Frontend Tests |
| 3 | +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. |
| 4 | + |
| 5 | +## Project Overview |
| 6 | + |
| 7 | +RocketAdmin is a database administration panel that allows users to manage database connections, tables, and data. It consists of multiple components in a monorepo structure: |
| 8 | + |
| 9 | +- **backend/** - NestJS API server (TypeScript, ES modules) |
| 10 | +- **frontend/** - Angular 19 web application (standalone components) |
| 11 | +- **rocketadmin-agent/** - NestJS agent for connecting to databases behind firewalls |
| 12 | +- **autoadmin-ws-server/** - WebSocket server for agent communication |
| 13 | +- **shared-code/** - Shared data access layer and utilities used by backend and agent |
| 14 | + |
| 15 | +## Development Commands |
| 16 | + |
| 17 | +### Backend |
| 18 | + |
| 19 | +```bash |
| 20 | +cd backend |
| 21 | +yarn start:dev # Start dev server with hot reload |
| 22 | +yarn build # Build for production |
| 23 | +yarn lint # ESLint with auto-fix |
| 24 | +yarn test # Run non-saas AVA tests (serial) |
| 25 | +yarn test-all # Run all AVA tests (5min timeout, serial) |
| 26 | +yarn test-saas # Run SaaS-specific tests |
| 27 | +``` |
| 28 | + |
| 29 | +### Frontend |
| 30 | + |
| 31 | +```bash |
| 32 | +cd frontend |
| 33 | +yarn start # Start Angular dev server |
| 34 | +yarn build # Production build |
| 35 | +yarn test:ci # Run tests headlessly (CI mode) |
| 36 | +yarn test --browsers=ChromeHeadlessCustom --no-watch --no-progress # Headless tests |
| 37 | +yarn lint # TSLint (deprecated, needs ESLint migration) |
| 38 | +``` |
| 39 | + |
| 40 | +### Running Backend Tests with Docker |
| 41 | + |
| 42 | +The project uses `just` for test orchestration: |
4 | 43 |
|
5 | | -To run frontend tests: |
6 | 44 | ```bash |
7 | | -cd frontend && yarn test --browsers=ChromeHeadlessCustom --no-watch --no-progress |
8 | | -``` |
| 45 | +just test # Run all backend tests with Docker Compose |
| 46 | +just test "path/to/test.ts" # Run specific test file |
| 47 | +``` |
| 48 | + |
| 49 | +This spins up test databases (MySQL, PostgreSQL, MSSQL, Oracle, IBM DB2, MongoDB, DynamoDB) via `docker-compose.tst.yml`. |
| 50 | + |
| 51 | +### Migrations |
| 52 | + |
| 53 | +```bash |
| 54 | +cd backend |
| 55 | +yarn build # Must build first |
| 56 | +yarn migration:generate src/migrations/MigrationName # Generate migration |
| 57 | +yarn migration:run # Run pending migrations |
| 58 | +yarn migration:revert # Revert last migration |
| 59 | +``` |
| 60 | + |
| 61 | +## Architecture |
| 62 | + |
| 63 | +### Monorepo Structure |
| 64 | + |
| 65 | +- Uses Yarn workspaces with packages: `backend`, `rocketadmin-agent`, `shared-code` |
| 66 | +- `shared-code` is imported as `@rocketadmin/shared-code` workspace dependency |
| 67 | +- Frontend is a separate Angular project (not a workspace member) |
| 68 | + |
| 69 | +### Backend (NestJS) |
| 70 | + |
| 71 | +- **Entities pattern**: Each entity has its own directory under `src/entities/` containing: |
| 72 | + - `*.entity.ts` - TypeORM entity |
| 73 | + - `*.module.ts` - NestJS module |
| 74 | + - `*.controller.ts` - REST endpoints |
| 75 | + - `*.service.ts` - Business logic (use cases) |
| 76 | + - `dto/` - Request/response DTOs with class-validator decorators |
| 77 | + - `*.controller.ee.ts` - Enterprise edition controllers (SaaS features) |
| 78 | +- **Guards**: Authentication and authorization in `src/guards/` |
| 79 | +- **Data access**: Uses `shared-code` for database operations via Knex |
| 80 | +- **Testing**: AVA test framework with tests in `test/ava-tests/` |
| 81 | + - `non-saas-tests/` - Core functionality tests |
| 82 | + - `saas-tests/` - SaaS-specific feature tests |
| 83 | + - `complex-table-tests/` - Complex table operation tests |
| 84 | + |
| 85 | +### Frontend (Angular 19) |
| 86 | + |
| 87 | +See `frontend/CLAUDE.md` for detailed frontend architecture. |
| 88 | + |
| 89 | +Key points: |
| 90 | +- Standalone components (no NgModules) |
| 91 | +- BehaviorSubject-based state management (no NgRx) |
| 92 | +- Multi-environment builds (development, production, saas, saas-production) |
| 93 | +- Jasmine/Karma testing with ChromeHeadless |
| 94 | + |
| 95 | +### Shared Code |
| 96 | + |
| 97 | +Located in `shared-code/src/`: |
| 98 | +- `data-access-layer/` - Database abstraction supporting MySQL, PostgreSQL, MSSQL, Oracle, MongoDB, DynamoDB, IBM DB2, Cassandra, Elasticsearch |
| 99 | +- `knex-manager/` - Knex connection management |
| 100 | +- `caching/` - LRU cache utilities |
| 101 | +- `helpers/` - Shared utilities |
| 102 | + |
| 103 | +### Agent Architecture |
| 104 | + |
| 105 | +The rocketadmin-agent connects to databases in private networks: |
| 106 | +1. Agent runs inside customer's network |
| 107 | +2. Connects to `autoadmin-ws-server` via WebSocket |
| 108 | +3. Backend communicates with agent through WebSocket server |
| 109 | +4. Agent executes database queries and returns results |
| 110 | + |
| 111 | +## Database Support |
| 112 | + |
| 113 | +The application supports: MySQL, PostgreSQL, MongoDB, DynamoDB, Cassandra, OracleDB, MSSQL, IBM DB2, Elasticsearch, Redis |
| 114 | + |
| 115 | +Database-specific DAOs are in `shared-code/src/data-access-layer/`. |
| 116 | + |
| 117 | +## Testing Database Connections |
| 118 | + |
| 119 | +Test databases are defined in `docker-compose.tst.yml`: |
| 120 | +- MySQL: `testMySQL-e2e-testing:3306` |
| 121 | +- PostgreSQL: `testPg-e2e-testing:5432` |
| 122 | +- MSSQL: `mssql-e2e-testing:1433` |
| 123 | +- Oracle: `test-oracle-e2e-testing:1521` |
| 124 | +- IBM DB2: `test-ibm-db2-e2e-testing:50000` |
| 125 | +- MongoDB: `test-mongo-e2e-testing:27017` |
| 126 | +- DynamoDB: `test-dynamodb-e2e-testing:8000` |
| 127 | + |
| 128 | +## Coding Conventions |
| 129 | + |
| 130 | +### Class Member Ordering |
| 131 | + |
| 132 | +- Private methods must be placed at the end of the class, after all public methods |
0 commit comments