A comprehensive Rails API for managing tenant-landlord relationships with property management, maintenance requests, payments, and communication tools.
- Ruby 3.2.0+
- PostgreSQL 13+
- Redis 6+
- Git
-
Create Rails App
rails new tenant_landlord_api --api --database=postgresql cd tenant_landlord_api -
Replace/Add Files
- Replace
Gemfilewith the downloaded version - Copy
.env.exampleand rename to.env - Add
render.yamlto root directory - Add
bin/render-build.shand make executable:chmod +x bin/render-build.sh - Replace configuration files in
config/directory
- Replace
-
Install Dependencies
bundle install
-
Setup Database
rails db:create rails db:migrate rails db:seed
-
Start Services
# Terminal 1: Start Redis redis-server # Terminal 2: Start Sidekiq bundle exec sidekiq # Terminal 3: Start Rails rails server
Copy .env.example to .env and update with your values:
DATABASE_URL: PostgreSQL connection stringREDIS_URL: Redis connection stringDEVISE_JWT_SECRET_KEY: Generate withrails secretSTRIPE_PUBLISHABLE_KEY&STRIPE_SECRET_KEY: From Stripe dashboardAWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY,AWS_S3_BUCKET: For file uploadsSMTP_*: Email configuration (Gmail example provided)
POST /api/v1/auth/login- User loginPOST /api/v1/auth/register- User registrationGET /api/v1/auth/profile- Get user profileDELETE /api/v1/auth/logout- User logout
GET /api/v1/properties- List propertiesPOST /api/v1/properties- Create property (landlords only)GET /api/v1/properties/:id- Get property detailsPUT /api/v1/properties/:id- Update propertyDELETE /api/v1/properties/:id- Delete property
GET /api/v1/maintenance_requests- List maintenance requestsPOST /api/v1/maintenance_requests- Create request (tenants only)PATCH /api/v1/maintenance_requests/:id/update_status- Update status
GET /api/v1/payments- List paymentsPOST /api/v1/payments- Create payment recordPOST /api/v1/payments/:id/process_payment- Process payment with Stripe
GET /api/v1/messages- List messagesPOST /api/v1/messages- Send messageGET /api/v1/messages/conversations- Get conversations
After running rails db:seed, you can login with:
Landlords:
- Email:
landlord1@example.com/ Password:password123 - Email:
landlord2@example.com/ Password:password123
Tenants:
- Email:
tenant1@example.com/ Password:password123 - Email:
tenant2@example.com/ Password:password123
Admin:
- Email:
admin@tenantlandlord.com/ Password:password123
-
Push to GitHub
git add . git commit -m "Initial commit" git remote add origin https://github.com/yourusername/tenant-landlord-api.git git push -u origin main
-
Deploy on Render
- Go to render.com
- Create account and connect GitHub
- Select "Blueprint" deployment
- Choose your repository
- Render will detect
render.yamland deploy automatically
-
Set Environment Variables In Render dashboard, add all required environment variables from
.env.example
- User: Tenants, landlords, and admins with role-based access
- Property: Rental properties with amenities and images
- TenantProperty: Join table managing tenant-property relationships
- MaintenanceRequest: Maintenance requests with status tracking
- Payment: Payment records with Stripe integration
- Message: Communication between users
- LeaseAgreement: Digital lease management
- Payment reminders
- Overdue payment notifications
- Lease expiration alerts
- AWS S3 for property images and documents
- Active Storage integration
- Stripe integration for rent payments
- Support for recurring payments
- Late fee calculations
bundle exec rspec# Add to Gemfile in development group
gem 'rubocop-rails'
gem 'brakeman'
# Run
bundle exec rubocop
bundle exec brakemanThe API includes built-in documentation. After starting the server, visit:
- Health check:
http://localhost:3000/health - API documentation:
http://localhost:3000/api-docs(if rswag gem added)
- Multi-tenant Architecture: Separate dashboards for tenants and landlords
- Property Management: Full CRUD operations with image uploads
- Maintenance System: Request tracking with priorities and status updates
- Payment Processing: Stripe integration with recurring payments
- Communication: Real-time messaging between users
- File Management: AWS S3 integration for documents and images
- Background Jobs: Automated reminders and notifications
- Role-based Access: Secure endpoints based on user roles
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
This project is licensed under the MIT License.
For issues and questions:
- Check the deployment logs in Render dashboard
- Verify environment variables are set correctly
- Ensure external services (Stripe, AWS) are configured
- Check Redis and PostgreSQL connections
Built with ❤️ using Ruby on Rails