Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tenant-Landlord Platform API

A comprehensive Rails API for managing tenant-landlord relationships with property management, maintenance requests, payments, and communication tools.

🚀 Quick Start

Prerequisites

  • Ruby 3.2.0+
  • PostgreSQL 13+
  • Redis 6+
  • Git

Local Development Setup

  1. Create Rails App

    rails new tenant_landlord_api --api --database=postgresql
    cd tenant_landlord_api
  2. Replace/Add Files

    • Replace Gemfile with the downloaded version
    • Copy .env.example and rename to .env
    • Add render.yaml to root directory
    • Add bin/render-build.sh and make executable: chmod +x bin/render-build.sh
    • Replace configuration files in config/ directory
  3. Install Dependencies

    bundle install
  4. Setup Database

    rails db:create
    rails db:migrate
    rails db:seed
  5. Start Services

    # Terminal 1: Start Redis
    redis-server
    
    # Terminal 2: Start Sidekiq
    bundle exec sidekiq
    
    # Terminal 3: Start Rails
    rails server

Environment Variables

Copy .env.example to .env and update with your values:

  • DATABASE_URL: PostgreSQL connection string
  • REDIS_URL: Redis connection string
  • DEVISE_JWT_SECRET_KEY: Generate with rails secret
  • STRIPE_PUBLISHABLE_KEY & STRIPE_SECRET_KEY: From Stripe dashboard
  • AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_S3_BUCKET: For file uploads
  • SMTP_*: Email configuration (Gmail example provided)

📋 API Endpoints

Authentication

  • POST /api/v1/auth/login - User login
  • POST /api/v1/auth/register - User registration
  • GET /api/v1/auth/profile - Get user profile
  • DELETE /api/v1/auth/logout - User logout

Properties

  • GET /api/v1/properties - List properties
  • POST /api/v1/properties - Create property (landlords only)
  • GET /api/v1/properties/:id - Get property details
  • PUT /api/v1/properties/:id - Update property
  • DELETE /api/v1/properties/:id - Delete property

Maintenance Requests

  • GET /api/v1/maintenance_requests - List maintenance requests
  • POST /api/v1/maintenance_requests - Create request (tenants only)
  • PATCH /api/v1/maintenance_requests/:id/update_status - Update status

Payments

  • GET /api/v1/payments - List payments
  • POST /api/v1/payments - Create payment record
  • POST /api/v1/payments/:id/process_payment - Process payment with Stripe

Messages

  • GET /api/v1/messages - List messages
  • POST /api/v1/messages - Send message
  • GET /api/v1/messages/conversations - Get conversations

🎭 Sample Users

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

🚀 Deployment to Render

  1. 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
  2. Deploy on Render

    • Go to render.com
    • Create account and connect GitHub
    • Select "Blueprint" deployment
    • Choose your repository
    • Render will detect render.yaml and deploy automatically
  3. Set Environment Variables In Render dashboard, add all required environment variables from .env.example

🏗️ Architecture

Models

  • 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

Background Jobs

  • Payment reminders
  • Overdue payment notifications
  • Lease expiration alerts

File Storage

  • AWS S3 for property images and documents
  • Active Storage integration

Payment Processing

  • Stripe integration for rent payments
  • Support for recurring payments
  • Late fee calculations

🔧 Development

Running Tests

bundle exec rspec

Code Quality

# Add to Gemfile in development group
gem 'rubocop-rails'
gem 'brakeman'

# Run
bundle exec rubocop
bundle exec brakeman

API Documentation

The 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)

📦 Key Features

  • 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

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests
  5. Submit a pull request

📄 License

This project is licensed under the MIT License.

🆘 Support

For issues and questions:

  1. Check the deployment logs in Render dashboard
  2. Verify environment variables are set correctly
  3. Ensure external services (Stripe, AWS) are configured
  4. Check Redis and PostgreSQL connections

Built with ❤️ using Ruby on Rails

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages