Files
MySMSAPio/QUICKSTART.md
2025-10-22 17:22:17 +08:00

2.4 KiB

Quick Start Guide - SMS Gateway API

This guide will help you get the SMS Gateway API up and running quickly.

Prerequisites

Ensure you have the following installed:

  • Ruby 3.4.7
  • PostgreSQL 14+
  • Redis 7+
  • Bundler 2.x

Step-by-Step Setup

1. Install Dependencies

bundle install

2. Set Up Database

# Create databases
bin/rails db:create

# Run migrations
bin/rails db:migrate

# Seed sample data (includes API keys and test gateways)
bin/rails db:seed

⚠️ IMPORTANT: After seeding, you'll see API keys printed. Save these immediately as they won't be shown again!

3. Start Redis

If Redis isn't running:

redis-server

4. Start Sidekiq (Background Jobs)

In a separate terminal:

bundle exec sidekiq

5. Start Rails Server

bin/rails server

The API will be available at http://localhost:3000

Quick Test

Test the Health Check

curl http://localhost:3000/up

Should return 200 OK.

Send a Test SMS

Replace YOUR_API_KEY with the API key from the seed output:

curl -X POST http://localhost:3000/api/v1/sms/send \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "to": "+1234567890",
    "message": "Test message from SMS Gateway API"
  }'

Check System Stats

curl http://localhost:3000/api/v1/admin/stats \
  -H "Authorization: Bearer YOUR_API_KEY"

Next Steps

  1. Read the full API documentation in README.md
  2. Set up an Android gateway device using the gateway API key from seeds
  3. Configure webhooks for real-time SMS notifications
  4. Integrate OTP functionality into your application

Common Issues

Redis Connection Error

Make sure Redis is running:

redis-cli ping

Should return PONG.

Database Connection Error

Check your PostgreSQL is running and accessible:

psql -d my_smsa_pio_development

Sidekiq Not Processing Jobs

Ensure Sidekiq is running:

bundle exec sidekiq

Development Workflow

  1. Console: bin/rails console
  2. Routes: bin/rails routes | grep api
  3. Logs: tail -f log/development.log
  4. Sidekiq Web UI: Add to routes and visit /sidekiq

Getting Help

  • Check README.md for complete API documentation
  • Check CLAUDE.md for development guidance
  • Review logs in log/development.log and log/sidekiq.log

Happy coding! 🚀