Building Management System - Microservices Backend with Stripe Payment Integration
BMS Backend/
├── services/
│ ├── core-service/ # Main API (Port 8080)
│ │ ├── Auth, Users, Properties, Apartments
│ │ ├── Tenants, Leases, Maintenance
│ │ └── AWS S3 + CloudFront Integration
│ └── payment-service/ # Payments (Port 8082)
│ └── Stripe Integration (Cards, ACH, Webhooks)
├── docker-compose.yml # Full stack
├── docker-compose.prod.yml # Databases only
└── .env # Environment variables
- Docker Desktop
- Stripe CLI (
brew install stripe/stripe-cli/stripe) - jq (
brew install jq) - for test scripts
Create .env in project root (already exists with your config):
# JWT
JWT_SECRET=your_jwt_secret_min_32_chars
JWT_ACCESS_TOKEN_EXPIRATION=900
JWT_REFRESH_TOKEN_EXPIRATION=2592000
# AWS S3
AWS_S3_BUCKET_NAME=bms-app-storage
AWS_S3_REGION=us-east-2
AWS_S3_ACCESS_KEY=your_access_key
AWS_S3_SECRET_KEY=your_secret_key
AWS_S3_BASE_URL=https://s3.us-east-2.amazonaws.com
AWS_CLOUDFRONT_DOMAIN=your_domain.cloudfront.net
AWS_CLOUDFRONT_ENABLED=true
# Stripe
STRIPE_SECRET_KEY=sk_test_xxx
STRIPE_PUBLISHABLE_KEY=pk_test_xxx
STRIPE_WEBHOOK_SECRET=whsec_xxx# Start everything (databases + services)
docker-compose up -d
# Check status
docker-compose ps# Login to Stripe (if session expired)
stripe login
# Forward webhooks to payment service
stripe listen --forward-to localhost:8082/api/webhooks/stripe# Core service
curl http://localhost:8080/api/v1/properties
# Expected: 401 (auth required) - service is running
# Payment service
curl http://localhost:8082/api/payments/stripe/publishable-key
# Expected: {"publishableKey":"pk_test_..."}| Service | Port | Database | Description |
|---|---|---|---|
| core-service | 8080 | PostgreSQL:5432 | Main business logic |
| payment-service | 8082 | PostgreSQL:5434 | Stripe payments |
| postgres-core | 5432 | - | Core DB |
| postgres-payment | 5434 | - | Payment DB |
| redis | 6379 | - | Cache |
# Start all
docker-compose up -d
# Stop all
docker-compose down
# View logs
docker-compose logs -f bms-core-service
docker-compose logs -f bms-payment-service
# Restart a service
docker-compose restart bms-payment-service
# Reset databases (delete volumes)
docker-compose down -v# Full integration test
./complete-setup-and-test.sh
# Simple payment test
./simple-payment-test.sh
# Automated payment test
./automated-payment-test.shPOST /api/v1/auth/signup- RegisterPOST /api/v1/auth/login- LoginPOST /api/v1/auth/verify-email- Verify emailPOST /api/v1/auth/verify-phone- Verify phone
GET/POST /api/v1/properties/buildings- PropertiesGET/POST /api/v1/apartments- Apartments
POST /api/v1/tenants/connect- Create leaseGET /api/v1/tenants/connections- List connectionsGET /api/v1/leases/{id}/payment-details- Payment infoGET /api/v1/leases/{id}/payment-summary- SummaryGET /api/v1/leases/{id}/payment-schedule- Schedule
POST /api/payments/create-card-intent- Create paymentGET /api/payments/stripe/publishable-key- Get Stripe keyPOST /api/webhooks/stripe- Webhook endpoint
GET/POST /api/v1/maintenance/requests- RequestsGET /api/v1/maintenance/categories- Categories
| Card | Result |
|---|---|
| 4242 4242 4242 4242 | Success |
| 4000 0000 0000 0002 | Declined |
| 4000 0025 0000 3155 | 3D Secure |
# Build and push to Docker Hub
./build-and-push.shPort already in use:
lsof -i :8080 # Find process
kill -9 <PID> # Kill itPayment service can't reach core service:
- Ensure
CORE_SERVICE_URL=http://bms-core-service:8080is in docker-compose.yml
Stripe webhook not working:
stripe login # Re-authenticate
stripe listen --forward-to localhost:8082/api/webhooks/stripeReset everything:
docker-compose down -v
docker-compose up -d- Core:
anoshorpaul/bms-core-service:latest - Payment:
anoshorpaul/bms-payment-service:latest