Skip to content

Commit d29e21c

Browse files
authored
Add AGENTS.md description of working with the repo (#1537)
1 parent 6c6218f commit d29e21c

File tree

2 files changed

+147
-0
lines changed

2 files changed

+147
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ greyGroup_chemInventory*
1515

1616
pydatalab/Pipfile
1717

18+
# coding assistants
19+
CLAUDE.md
1820

1921
*.sublime-workspace
2022
*.sublime-project

AGENTS.md

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
# AGENTS.md
2+
3+
This file provides guidance to coding agents when working with code in this repository.
4+
5+
## Project Overview
6+
7+
datalab is a research data management platform for materials chemistry. It consists of:
8+
- **pydatalab**: Flask-based Python REST API server (`pydatalab/`)
9+
- **webapp**: Vue.js 3 frontend application (`webapp/`)
10+
- **MongoDB**: Database backend for storing annotations and connections
11+
12+
## Development Commands
13+
14+
You should normally assume the user has a development set up already, with API and frontend running locally.
15+
16+
You should not typically perform any deployment related operations unless explicitly instructed.
17+
18+
### Python Backend (pydatalab)
19+
20+
```bash
21+
cd pydatalab
22+
23+
# Install dependencies (use uv)
24+
uv sync --all-extras --dev --locked
25+
26+
# Run development server
27+
uv run flask --app 'pydatalab.main' run --reload --port 5001
28+
29+
# Run tests
30+
uv run pytest
31+
32+
# Run single test file
33+
uv run pytest tests/server/test_items.py
34+
35+
# Run single test
36+
uv run pytest tests/server/test_items.py::test_function_name -v
37+
38+
# Regenerate JSON schemas (when models change)
39+
uv run invoke dev.generate-schemas
40+
```
41+
42+
### Frontend (webapp)
43+
44+
```bash
45+
cd webapp
46+
47+
# Install dependencies
48+
yarn install
49+
50+
# Run development server (serves at localhost:8081)
51+
yarn serve
52+
53+
# Build for production
54+
yarn build
55+
56+
# Run linting
57+
yarn lint
58+
59+
# Run unit tests
60+
yarn test:unit
61+
62+
# Run e2e tests (requires backend at localhost:5001)
63+
yarn test:e2e
64+
yarn test:e2e --headless
65+
```
66+
67+
### Pre-commit Hooks
68+
69+
```bash
70+
# Install pre-commit hooks (run from repo root)
71+
pre-commit install
72+
73+
# Run all hooks manually
74+
pre-commit run --all-files
75+
```
76+
77+
### Docker (production)
78+
79+
```bash
80+
# Start all services
81+
docker compose --profile prod up
82+
83+
# Start only database (for local development)
84+
docker compose up database
85+
```
86+
87+
## Architecture
88+
89+
### Backend Structure (pydatalab/src/pydatalab/)
90+
91+
- `main.py` - Flask app entry point
92+
- `config.py` - Server configuration (loaded from JSON file or env vars prefixed with `PYDATALAB_`)
93+
- `routes/v0_1/` - REST API endpoints organized by resource type:
94+
- `items.py` - Main CRUD operations for samples, cells, starting materials
95+
- `auth.py` - OAuth authentication (GitHub, ORCID)
96+
- `blocks.py` - Data block operations
97+
- `collections.py` - Collection management
98+
- `files.py` - File uploads and remote filesystem sync
99+
- `models/` - Pydantic models for database entities (items, people, files, relationships)
100+
- `blocks/` - Base classes for data blocks (`DataBlock` base class in `base.py`)
101+
- `apps/` - Characterisation technique blocks (XRD, NMR, echem, Raman, TGA, etc.)
102+
- Each app provides a `DataBlock` subclass for visualising/analysing specific data types
103+
- Apps are loaded dynamically; missing dependencies are gracefully handled
104+
- Plugins can register via `pydatalab.apps.plugins` entrypoint
105+
106+
### Frontend Structure (webapp/src/)
107+
108+
- `main.js` - Vue app entry point
109+
- `App.vue` - Root component
110+
- `router/` - Vue Router configuration
111+
- `store/` - Vuex state management
112+
- `views/` - Page components
113+
- `components/` - Reusable UI components
114+
- `server_fetch_utils.js` - API client utilities
115+
- `resources.js` - Resource type definitions
116+
117+
### Key Concepts
118+
119+
- **Items**: Core entities (samples, cells, starting_materials, equipment) with hierarchical relationships
120+
- **Blocks**: Modular data visualisation/analysis units attached to items
121+
- **Collections**: Groups of items for organisation
122+
- **Relationships**: Graph connections between items (synthesised_from, is_part_of, etc.)
123+
- **Refcodes**: Unique identifiers for items (format configured in server config)
124+
125+
## Code Style
126+
127+
### Python
128+
- Formatting: ruff (line length 100) via pre-commit
129+
- Type hints: Required, using Pydantic v1 models
130+
- Logging: Use `pydatalab.logger.LOGGER`
131+
- Tests: pytest with fixtures in `conftest.py`
132+
133+
### JavaScript/Vue
134+
- Formatting: Prettier + ESLint via pre-commit
135+
- Vue 3 composition API
136+
- Component testing with @testing-library/vue
137+
- E2E testing with Cypress
138+
139+
140+
## Environment Variables
141+
142+
Key environment variables (can also be set in config.json):
143+
- `PYDATALAB_MONGO_URI` - MongoDB connection string
144+
- `PYDATALAB_CONFIG_FILE` - Path to JSON config file (default: /app/config.json)
145+
- `PYDATALAB_TESTING` - Disable auth when set to "true"

0 commit comments

Comments
 (0)