Skip to content

Commit 21dfab7

Browse files
committed
Add CLAUDE.md for AI coding assistants
1 parent a8f32a3 commit 21dfab7

File tree

1 file changed

+149
-0
lines changed

1 file changed

+149
-0
lines changed

CLAUDE.md

Lines changed: 149 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Project Overview
6+
7+
CloudServer is Scality's open-source, AWS S3-compatible object storage server. It provides a single S3 API interface to access multiple storage backends (Scality RING, file, memory, AWS S3, Azure, GCP, etc.). Part of the S3C/Federation and Zenko stacks.
8+
9+
- **Node.js >= 22** required
10+
- **Package Manager**: Yarn with `--frozen-lockfile`
11+
12+
## Common Commands
13+
14+
### Development
15+
```bash
16+
yarn install --frozen-lockfile # Install dependencies
17+
yarn start # Start S3 + metadata + data servers
18+
yarn dev # Development mode with auto-restart (nodemon)
19+
yarn mem_backend # Start with in-memory backend (S3BACKEND=mem)
20+
yarn start_mongo # Start with MongoDB metadata backend
21+
```
22+
23+
### Testing
24+
```bash
25+
# Unit tests
26+
yarn test # Run unit tests (S3BACKEND=mem)
27+
yarn cover test # Run unit tests with coverage
28+
29+
# Functional tests (require running server)
30+
yarn ft_awssdk # AWS SDK functional tests
31+
yarn ft_awssdk_buckets # Bucket-specific AWS SDK tests
32+
yarn ft_awssdk_versioning # Versioning tests
33+
yarn ft_s3cmd # S3cmd CLI tests
34+
yarn ft_healthchecks # Health check tests
35+
yarn ft_test # Run all functional tests
36+
37+
# Multi-backend tests
38+
yarn multiple_backend_test # Multi-backend unit tests
39+
yarn ft_awssdk_external_backends # External backend functional tests
40+
```
41+
42+
### Linting
43+
```bash
44+
yarn lint # ESLint on all JS files
45+
yarn lint_md # Markdown linting
46+
```
47+
48+
## Architecture
49+
50+
### Entry Points
51+
- `index.js` → Main S3 API server (port 8000)
52+
- `mdserver.js` → Metadata server (port 9990)
53+
- `dataserver.js` → Data storage server (port 9991)
54+
- `pfsserver.js` → Passthrough filesystem server (port 9992)
55+
- `managementAgent.js` → WebSocket management agent (port 8010)
56+
57+
### Core Components
58+
59+
```
60+
lib/
61+
├── server.js # S3Server class - main HTTP server with cluster support
62+
├── Config.js # Configuration management (env vars, config.json)
63+
├── api/ # S3 API implementations (80+ operations)
64+
│ ├── api.js # Main request router and auth handler
65+
│ └── apiUtils/ # Shared utilities (auth, bucket ops, object ops, quotas)
66+
├── auth/ # Authentication (vault.js for IAM, in_memory/ for local)
67+
├── data/ # Data backend abstraction (file, memory, multiple)
68+
├── metadata/ # Metadata backend abstraction
69+
├── routes/ # Special routes (Backbeat, metadata service, Veeam)
70+
├── kms/ # Key management (file, memory, AWS, KMIP)
71+
├── management/ # Management API and configuration
72+
└── utilities/ # Logging, health checks, XML parsing
73+
```
74+
75+
### Backend Configuration
76+
77+
Set via environment variables. Each backend type abstracts multiple implementations:
78+
79+
### Data Backends (`S3DATA`)
80+
81+
| Backend | Port | Description |
82+
|---------|------|-------------|
83+
| `file` | 9991 | Local filesystem via `dataserver.js` - started by `yarn start` |
84+
| `multiple` | - | Multi-backend gateway (AWS S3, Azure, GCP, Sproxyd, etc.) |
85+
| `mem` | - | In-memory (testing only) |
86+
87+
`scality` is an alias for `multiple`. With `multiple`, objects route to backends defined in `locationConfig.json` based on location constraints.
88+
89+
### Metadata Backends (`S3METADATA`)
90+
91+
| Backend | Port | Description |
92+
|---------|------|-------------|
93+
| `file` (default) | 9990 | Local LevelDB via `mdserver.js` - started by `yarn start` |
94+
| `scality` | 9000 | External bucketd service (production Scality RING) |
95+
| `mongodb` | 27017+ | MongoDB replica set |
96+
| `mem` | - | In-memory (testing only) |
97+
98+
**file vs scality**: The `file` backend runs a self-contained metadata server (`mdserver.js`) for development. The `scality` backend connects to external **bucketd** which uses Raft-based distributed metadata (repd) for production HA deployments.
99+
100+
### Auth Backends (`S3VAULT`)
101+
102+
| Backend | Port | Description |
103+
|---------|------|-------------|
104+
| `mem` (default) | - | In-memory accounts from `conf/authdata.json` |
105+
| `vault` | 8500 | External Vault IAM service (vaultd) |
106+
107+
### KMS Backends (`S3KMS`)
108+
109+
| Backend | Description |
110+
|---------|-------------|
111+
| `file` (default) | Local file-based key storage |
112+
| `mem` | In-memory (testing only) |
113+
| `kmip` | External KMIP server |
114+
| `aws` | AWS KMS |
115+
| `scality` | Scality KMS |
116+
117+
### Path Configuration
118+
119+
- `S3DATAPATH`: Data storage directory (default: `./localData`)
120+
- `S3METADATAPATH`: Metadata storage directory (default: `./localMetadata`)
121+
122+
### Key Files
123+
- `config.json` - Default configuration
124+
- `constants.js` - Global constants (splitters, limits, service accounts)
125+
- `locationConfig.json` - Location constraints for multi-backend
126+
127+
## Testing Conventions
128+
129+
- **Framework**: Mocha with Sinon for mocking
130+
- **Timeout**: 40000ms global
131+
- **Coverage**: NYC (Istanbul), 80% patch target
132+
- **Reporters**: mocha-multi-reporters (spec + junit XML)
133+
134+
Run a single test file:
135+
```bash
136+
S3BACKEND=mem yarn mocha tests/unit/path/to/test.js --exit
137+
```
138+
139+
Run tests matching a pattern:
140+
```bash
141+
S3BACKEND=mem yarn mocha --grep "pattern" tests/unit --recursive --exit
142+
```
143+
144+
## Code Style
145+
146+
- ESLint with `@scality/eslint-config-scality`
147+
- `mocha/no-exclusive-tests: error` - Never commit `.only()` tests
148+
- Many formatting rules disabled for legacy compatibility
149+
- ECMAScript 2021, CommonJS modules (`sourceType: "script"`)

0 commit comments

Comments
 (0)