# konnn04/rent-house-app architecture

> Architecture diagram of the GitHub repository konnn04/rent-house-app, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-06-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/konnn04/rent-house-app
- Repository: https://github.com/konnn04/rent-house-app

## Overview

##### Project Type and Purpose
- This is a full-stack “Rent House” application comprising:
- A mobile frontend built with React Native (Expo)
- A backend REST API built with Django & Django REST Framework
- A relational database (MySQL/PostgreSQL)
- Cloudinary for image storage, OAuth2 for authentication, email notifications, chat, reporting, and an admin console

##### File-Structure Analysis
- Top level:
- rent_house/ → React Native app
- rent_house_server/ → Django backend
- Frontend folders:
- components/ (UI organized by feature & screen)
- services/ (API wrappers using Axios)
- contexts/, hooks/, utils/, constants/, styles/, assets/
- Backend folders (rent_house_server/rent_house/):
- models/, serializers/, views/ (REST endpoints)
- admin/ (Django admin configuration)
- templates/, static/ (admin UI & email templates)
- management/commands/ (data seeding, OAuth app creation)
- Deployment scripts: buildspec.yml, appspec.yml, CI/CD hooks, shell scripts

##### Key Architecture Insights from README
- Frontend communicates over HTTP(s) to backend OAuth-protected endpoints
- Backend handles user roles (owner/tenant), chat, notifications, reporting
- External integrations: Cloudinary (images), SMTP (email), OAuth2 toolkit
- Admin console is part of the Django app

##### Main Components
a. Mobile Client (React Native/Expo)
- UI Screens & Navigation (AuthStack, Main TabScreens)
- State management (Redux or Contexts)
- API layer (services/*.js via Axios/AsyncStorage)
b. API Gateway (Django REST Framework)
- Authentication (OAuth2 endpoints)
- Business logic in views/serializers/services
- Django admin interface
c. Database
- User, House, Chat, Post, Rate, Comment tables
d. Cloudinary
- Image upload & thumbnail generation
e. Email/Notifications
- SMTP server for emails (reset password, verify email, new house alerts)
- Push notifications (Firebase credentials present)
f. External Services
- OAuth2 provider (Django OAuth Toolkit)
- Optional Telegram for alerts

##### Relationships and Interactions
- Mobile client → REST API calls (login, fetch listings, chat, post)
- API → Database CRUD via Django ORM
- API → Cloudinary for media storage
- API → SMTP for transactional emails
- API → Notification Service (push)
- Admin user → Django admin UI → interacts with the same API/database

##### Architectural Patterns and Principles
- Separation of concerns: UI vs services vs data vs business logic
- RESTful API design with token-based OAuth2 authentication
- Modular React Native components by feature
- Django app structured by model-view-serializer-service
- Management commands for data population and setup

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Mobile Client
    subgraph "Mobile Client"
        UIAuth["AuthStackScreen.jsx"]:::mobile
        UITab["TabScreens.jsx"]:::mobile
        Contexts["Contexts"]:::mobile
        Hooks["useForm Hook"]:::mobile
        APILayer["API Layer (Axios Services)"]:::mobile
        Assets["Assets & Styling"]:::mobile
    end

    %% Backend API
    subgraph "Backend REST API" 
        API_Gateway["Django REST API (DRF)"]:::api
        Auth["Authentication (OAuth2 Endpoints)"]:::api
        BizLogic["Business Logic & Services"]:::api
        Models["Models (DB Tables)"]:::api
        Serializers["Serializers"]:::api
        Views["Views / API Endpoints"]:::api
        Permissions["Permissions & Error Handling"]:::api
        AdminConsole["Admin Console (Django Admin)"]:::api
        Templates["Admin UI Templates & Static"]:::api
        EmailTemplates["Email Templates"]:::api
        Management["Management Commands"]:::api
        APIDocs["API Documentation"]:::api
        CICD["Deployment & CI/CD Scripts"]:::api
    end

    %% Database
    Database[(Relational Database)]:::db

    %% External Services
    Cloudinary((Cloudinary)):::ext
    SMTP((SMTP Email Service)):::ext
    FCM((Firebase Push Service)):::ext
    OAuth2Provider((OAuth2 Toolkit)):::ext
    Telegram((Telegram Alerts)):::ext

    %% Connections
    UIAuth -->|uses| API_Gateway
    UITab -->|uses| API_Gateway
    Contexts -->|manages state| APILayer
    Hooks -->|manages state| APILayer
    APILayer -->|HTTP/HTTPS| API_Gateway
    Assets -->|resources| UIAuth

    API_Gateway -->|SQL| Database
    API_Gateway -->|image upload| Cloudinary
    API_Gateway -->|SMTP| SMTP
    API_Gateway -->|push notifications| FCM
    API_Gateway -->|OAuth2 validation| OAuth2Provider
    API_Gateway -->|alerts| Telegram

    API_Gateway --> Auth
    API_Gateway --> BizLogic
    API_Gateway --> Views
    Views --> Serializers
    Views --> Permissions
    BizLogic --> Models
    BizLogic --> Serializers
    API_Gateway --> AdminConsole
    AdminConsole --> Templates
    API_Gateway --> EmailTemplates
    API_Gateway --> Management
    API_Gateway --> APIDocs
    API_Gateway --> CICD

    %% Click Events - Mobile Client
    click UIAuth "https://github.com/konnn04/rent-house-app/blob/main/rent_house/components/auth/AuthStackScreen.jsx"
    click UITab "https://github.com/konnn04/rent-house-app/blob/main/rent_house/components/main/TabScreens.jsx"
    click Contexts "https://github.com/konnn04/rent-house-app/tree/main/rent_house/contexts/"
    click Hooks "https://github.com/konnn04/rent-house-app/blob/main/rent_house/hooks/useForm.js"
    click APILayer "https://github.com/konnn04/rent-house-app/blob/main/rent_house/services/Api.js"
    click Assets "https://github.com/konnn04/rent-house-app/tree/main/rent_house/assets/"

    %% Click Events - Backend API
    click Auth "https://github.com/konnn04/rent-house-app/blob/main/rent_house_server/rent_house/views/auth.py"
    click Auth "https://github.com/konnn04/rent-house-app/blob/main/rent_house_server/rent_house/auth_validators.py"
    click Auth "https://github.com/konnn04/rent-house-app/blob/main/rent_house_server/rent_house/management/commands/create_oauth_app.py"
    click BizLogic "https://github.com/konnn04/rent-house-app/blob/main/rent_house_server/rent_house/services/notification_service.py"
    click Models "https://github.com/konnn04/rent-house-app/tree/main/rent_house_server/rent_house/models/"
    click Serializers "https://github.com/konnn04/rent-house-app/tree/main/rent_house_server/rent_house/serializers/"
    click Views "https://github.com/konnn04/rent-house-app/tree/main/rent_house_server/rent_house/views/"
    click Permissions "https://github.com/konnn04/rent-house-app/blob/main/rent_house_server/rent_house/permissions.py"
    click Permissions "https://github.com/konnn04/rent-house-app/blob/main/rent_house_server/rent_house/views/error_handler.py"
    click AdminConsole "https://github.com/konnn04/rent-house-app/tree/main/rent_house_server/rent_house/admin/"
    click AdminConsole "https://github.com/konnn04/rent-house-app/blob/main/rent_house_server/rent_house/admin_view.py"
    click AdminConsole "https://github.com/konnn04/rent-house-app/blob/main/rent_house_server/rent_house/admin_config.py"
    click Templates "https://github.com/konnn04/rent-house-app/tree/main/rent_house_server/rent_house/templates/admin/"
    click Templates "https://github.com/konnn04/rent-house-app/tree/main/rent_house_server/rent_house/static/"
    click EmailTemplates "https://github.com/konnn04/rent-house-app/tree/main/rent_house_server/rent_house/templates/email/"
    click Management "https://github.com/konnn04/rent-house-app/blob/main/rent_house_server/rent_house/management/commands/populate_data.py"
    click Management "https://github.com/konnn04/rent-house-app/blob/main/rent_house_server/rent_house/test_telegram.py"
    click APIDocs "https://github.com/konnn04/rent-house-app/tree/main/rent_house_server/api_documentation/"
    click CICD "https://github.com/konnn04/rent-house-app/blob/main/buildspec.yml"

    %% Styles
    classDef mobile fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef api fill:#90EE90,stroke:#333,stroke-width:1px
    classDef db fill:#FFA500,stroke:#333,stroke-width:1px
    classDef ext fill:#D3D3D3,stroke:#333,stroke-width:1px
```
