Thank you for your interest in contributing to the ASAP backend. This guide covers environment setup, project conventions, and the PR workflow.
- Node.js with TypeScript (ESM)
- Express 5 for routing
- Prisma 7 ORM with PostgreSQL
- bcryptjs for password hashing
- jsonwebtoken for auth tokens
- tsx / nodemon for development
- Node.js 20+
- Yarn
- PostgreSQL 14+ (local or Docker)
# 1. Fork and clone the repo
git clone https://github.com/asap-open/asap-server.git
cd asap-server
# 2. Install dependencies
yarn install
# 3. Copy and configure environment
cp .env.example .envSet the following in .env:
DATABASE_URL=postgresql://user:password@localhost:5432/asap?schema=public
JWT_SECRET=your-secret-here
TOKEN_EXP=7d
FRONTEND_DOMAIN=http://localhost:5173
PORT=3000# 4. Run database migrations
yarn prisma migrate dev
# 5. (Optional) Seed the exercise data
yarn tsx src/utils/seed.ts
# 6. Start the dev server
yarn devThe API will be available at http://localhost:3000.
| Command | Description |
|---|---|
yarn dev |
Start server with nodemon (auto-restarts on file changes) |
yarn build |
Compile TypeScript to dist/ |
yarn start |
Run compiled output (dist/index.js) |
yarn prisma migrate dev |
Create and apply a new migration |
yarn prisma studio |
Open Prisma Studio to inspect the database |
src/
index.ts # App entry — Express setup, middleware, route mounting
controllers/ # Request handlers (validate input, call services, respond)
middleware/ # Auth and other middleware
routes/ # Route definitions (map paths to controllers)
services/ # Business logic (currently exercise seeding/lookup)
utils/
prisma.ts # Prisma client singleton
seed.ts # Exercise seed script
prisma/
schema.prisma # Database schema
migrations/ # Migration history
The project follows a routes → controllers → Prisma pattern:
- Routes define paths and apply middleware
- Controllers handle request/response, validate inputs, and interact with Prisma directly
- Keep controllers focused — extract repeated logic into
services/orutils/if needed
feat/add-exercise-categories-endpoint
fix/weight-record-date-timezone
refactor/session-controller-error-handling
- Use TypeScript throughout — type all request bodies, params, and responses
- Use
async/await; avoid raw.then()chains - Wrap controller logic in
try/catchand return appropriate HTTP status codes - Use Prisma's generated types from
prisma/generated/for model types - Do not commit
.envfiles
If your contribution requires a database schema change:
- Edit
prisma/schema.prisma - Run
yarn prisma migrate dev --name describe-your-change - Commit both the updated schema and the generated migration files
feat: add GET /exercises/by-equipment/:equipment endpoint
fix: return 404 when session not found instead of 500
chore: update prisma to v7.3
- Fork the repository
- Create a feature branch off
main - Make your changes
- Run
yarn buildto confirm no TypeScript errors - Test your endpoint changes manually or with your preferred HTTP client
- Open a PR describing the change, the motivation, and any migration steps
- New API endpoints that fit the existing resource model
- Bug fixes with a clear description of the issue and reproduction steps
- Performance improvements to queries
- Security improvements
- Schema improvements with well-named migrations
- Improved error handling and validation
Open an issue before starting a large change to align on approach. API design decisions in particular benefit from early discussion.