ratesspot-api
v1.0.0
Published
RatesSpot Headless Booking Engine API
Downloads
117
Maintainers
Readme
🚀 RatesSpot API - Developer Onboarding
Welcome to the RatesSpot team! This guide will get you up and running with our comprehensive booking API platform.
📋 Pre-requisites
Required Software
- Node.js 18+ - Download here
- PostgreSQL 14+ - Download here
- Git - Download here
- Docker (optional) - Download here
Recommended Tools
- VS Code with extensions:
- Prisma
- TypeScript and JavaScript Language Features
- ESLint
- GitLens
- Postman - For API testing
- TablePlus or pgAdmin - Database GUI
🛠️ Local Setup
1. Clone the Repository
git clone https://github.com/your-org/ratesspot-api.git
cd ratesspot-api2. Install Dependencies
npm install
cd website && npm install && cd ..3. Environment Configuration
cp .env.example .envEdit .env with your local configuration:
- Database URL for local PostgreSQL
- Get Clerk keys from team admin
- Optional: Stripe test keys, Twilio, etc.
4. Database Setup
# Generate Prisma client
npm run db:generate
# Run migrations
npm run db:migrate
# Seed test data (optional)
npm run db:seed5. Start Development Server
npm run devThe API will be running at http://localhost:3001
6. Generate Documentation
npm run docs:generate
npm run docs:serveDocumentation available at http://localhost:3001/docs
🏗️ Project Architecture
Directory Structure
ratesspot-api/
├── src/
│ ├── controllers/ # API request handlers
│ ├── middleware/ # Express middleware
│ ├── routes/ # API route definitions
│ ├── services/ # Business logic
│ ├── types/ # TypeScript type definitions
│ ├── utils/ # Helper functions
│ └── app.ts # Express app setup
├── prisma/
│ ├── schema.prisma # Database schema
│ └── migrations/ # Database migrations
├── scripts/ # Build and utility scripts
├── website/ # Docusaurus documentation site
├── tests/ # Test files
└── docs/ # Auto-generated API docsTech Stack
- Runtime: Node.js + TypeScript
- Framework: Express.js
- Database: PostgreSQL + Prisma ORM
- Authentication: Clerk
- Payments: Stripe
- Documentation: Auto-generated + Docusaurus
- Testing: Jest + Supertest
- Deployment: Railway
🔄 Development Workflow
Branch Naming Convention
feature/add-loyalty-system
fix/booking-validation-bug
hotfix/critical-payment-issue
chore/update-dependencies
docs/api-reference-updateGit Workflow
Create branch from
developgit checkout develop git pull origin develop git checkout -b feature/your-feature-nameMake changes and commit
git add . git commit -m "Add loyalty points calculation"Push and create PR
git push origin feature/your-feature-nameCreate PR targeting
developbranchCode review → Merge → Deploy
Pre-commit Hooks
Our Husky setup automatically:
- ✅ Regenerates API documentation
- ✅ Runs linting and type checking
- ✅ Stages updated docs
📝 Development Guidelines
Code Style
# Lint your code
npm run lint
# Auto-fix issues
npm run lint:fix
# Type check
npm run type-checkTesting
# Run all tests
npm test
# Watch mode
npm run test:watch
# Coverage report
npm run test:coverageAPI Development
- Routes: Define in
src/routes/ - Controllers: Handle requests in
src/controllers/ - Services: Business logic in
src/services/ - Types: TypeScript definitions in
src/types/
Example new endpoint:
// src/routes/newFeature.ts
router.post('/api/new-feature', clerkAuthMiddleware, createNewFeature);
// src/controllers/newFeatureController.ts
export const createNewFeature = async (req: Request, res: Response) => {
// Controller logic
};
// src/services/newFeatureService.ts
export class NewFeatureService {
// Business logic
}Database Changes
# 1. Update schema.prisma
# 2. Generate migration
npx prisma migrate dev --name add_new_feature
# 3. Generate client
npm run db:generate🧪 Testing Your Changes
API Testing
# Download Postman collection
curl -o ratesspot.json https://api.ratesspot.com/docs/download/postman
# Or use local docs
npm run docs:serve
# Visit http://localhost:3001/docsDatabase Testing
# View data
npm run db:studio
# Reset database
npm run db:reset
# Re-seed data
npm run db:seed📊 Understanding the Codebase
Key Features
- 431 API endpoints across all business domains
- Multi-location support with location-specific pricing
- Advanced payment flows with Stripe integration
- Team management with role-based permissions
- Customer loyalty programs
- Real-time analytics and monitoring
Important Files
src/app.ts- Express app configurationsrc/middleware/auth.ts- Authentication middlewaresrc/services/bookingService.ts- Core booking logicsrc/services/paymentService.ts- Payment processingprisma/schema.prisma- Database schema
Auto-Generated Documentation
Our docs are generated automatically from:
- Route definitions
- API usage metrics
- Response schemas
- Test collections
🚀 Deployment
Staging Environment
- URL:
https://staging-api.ratesspot.com - Deployment: Automatic on
developbranch push - Database: Staging PostgreSQL instance
Production Environment
- URL:
https://api.ratesspot.com - Deployment: Automatic on
mainbranch push - Database: Production PostgreSQL instance
CI/CD Pipeline
- PR Creation → Quality checks run
- Merge to develop → Deploy to staging
- Merge to main → Deploy to production
- Documentation updates automatically
🆘 Getting Help
Team Communication
- Slack: #ratesspot-dev channel
- Daily Standups: 9:00 AM EST
- Code Reviews: Required for all PRs
Common Issues
Database connection error:
# Check PostgreSQL is running
brew services start postgresql
# Verify connection string in .envPrisma client out of sync:
npm run db:generateTypeScript errors:
npm run type-check
# Fix type issues before committingTests failing:
npm test -- --verbose
# Check specific test failuresResources
- API Documentation: api.ratesspot.com/docs
- Postman Collection: Auto-downloads from docs
- Prisma Docs: prisma.io/docs
- Stripe API: stripe.com/docs/api
🎯 Your First Task
Quick Win: Add Your Info
- Update team page in documentation
- Add your photo to
website/static/img/team/ - Create PR following our workflow
- Get familiar with code review process
Suggested Learning Path
- Week 1: Set up environment, understand architecture
- Week 2: Make small bug fixes, add tests
- Week 3: Implement new feature end-to-end
- Week 4: Work on larger project with mentorship
📚 Additional Resources
External Learning
Internal Knowledge Base
- Architecture Decisions:
/docs/architecture/ - API Design Guidelines:
/docs/api-guidelines.md - Database Patterns:
/docs/database-patterns.md - Security Guidelines:
/docs/security.md
Welcome to the team! 🎉
Questions? Reach out in #ratesspot-dev or schedule time with your mentor.
