Development
Prerequisites
- Node.js 20+
- npm 10+
- MongoDB 7+ (local or Docker)
- Git
Setup
git clone https://github.com/Dynamic-API-Platform/Dynamic-API-Platform.git
cd Dynamic-API-Platform
# Start MongoDB only
docker run -d --name dap-mongo -p 27017:27017 mongo:7
# Backend
cd backend
cp ../.env.example .env
npm install
npm run dev # tsx watch on port 3001
# Frontend (new terminal)
cd frontend
npm install
npm run dev # Vite on port 5173
Open http://localhost:5173 — Vite proxies /api to the backend on port 3001.
UI themes
Light and dark themes are available. Toggle in the admin header; preference is stored in localStorage under key theme.
Scripts
Backend
| Command | Description |
|---|---|
npm run dev |
Hot reload with tsx |
npm run build |
Compile TypeScript |
npm start |
Run compiled dist/index.js |
npm run seed |
Run seed script manually |
npm test |
Run unit tests (Vitest) |
npm run test:watch |
Unit tests in watch mode |
npm run test:load |
Load test against running API (autocannon) |
Frontend
| Command | Description |
|---|---|
npm run dev |
Vite dev server |
npm run build |
Production build to dist/ |
npm run preview |
Preview production build |
Project conventions
Adding a new management endpoint
- Add route in
backend/src/routes/ - Add service method in
backend/src/services/ - Add repository method if DB access needed
- Register route in
backend/src/app.ts - Add API client method in
frontend/src/services/api.ts - Create/update page in
frontend/src/pages/ - Add navigation link in
frontend/src/components/Layout.tsx - Document in
docs/api-reference.md
Adding a permission
- Add to
Permissiontype inbackend/src/types/index.ts - Add to Group model enum in
backend/src/models/Group.ts - Add to
ALL_PERMISSIONSinfrontend/src/pages/GroupsPage.tsx - Use in
requirePermission()on routes - Document in
docs/rbac.md
Adding a settings key
- Add to
settings.service.tsdefaults and key map - Add UI field in
SettingsPage.tsx - Use in relevant middleware/service
TypeScript
Both packages use strict TypeScript. Build before committing:
cd backend && npm run build
cd ../frontend && npm run build
Testing
See the full guide: Testing
cd backend
npm test # unit tests (30 tests, no MongoDB required)
npm run test:load # load test (requires running backend)
CI runs npm test on every push to main.
Testing API manually
Use the built-in endpoint tester or:
# VS Code REST Client, Postman, or curl
curl -H "Authorization: Bearer $TOKEN" http://localhost:3001/api/endpoints
Docker development
docker compose up -d --build
docker compose logs -f backend
Common development issues
See Troubleshooting.
Contributing
See CONTRIBUTING.md on GitHub.