# aelassas/movinin architecture

> Architecture diagram of the GitHub repository aelassas/movinin, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/aelassas/movinin
- Repository: https://github.com/aelassas/movinin

## Overview

##### Project Type & Purpose
- This is a monorepo for a full-stack, cross-platform Rental Property Management Platform (“Movin’ In”).
- It comprises:
- An Admin Web SPA (React/TypeScript + Vite) for agencies and admins to manage properties, customers, bookings, payments.
- A Customer Web SPA (React/TypeScript + Vite) for property search, booking, checkout.
- A Mobile App (React Native/Expo) for customers to search and book on iOS/Android.
- A RESTful Backend API (Node.js/Express + TypeScript) with controllers, models, middlewares, payment integration, i18n, notification system.
- Shared internal packages under /packages (helpers, types, social-login, currency converter).
- CI/CD scripts, Docker configurations and auxiliary services (__services, __scripts).

##### File Structure Analysis & Architectural Patterns
- Top-level folders:
- /backend – Express API with MVC-style controllers, routes, models, utilities, tests.
- /admin – Admin SPA.
- /frontend – Customer SPA.
- /mobile – React Native mobile client.
- /packages – Reusable libraries (monorepo pattern).
- docker-compose*.yml, Dockerfiles, CI workflows – containerized deployment.
- Patterns & concerns:
- Single backend application serving JSON REST endpoints.
- Three distinct client personas (admin web, customer web, mobile), each with its own build and deployment.
- Shared services/scripts for deployment, health checks, versioning.
- External integrations: Stripe, PayPal, IP info, email (SMTP), push notifications, Sentry.

##### Key Architectural Components
a. Clients
- Admin Web SPA
- Customer Web SPA
- Mobile App
b. Backend API
- Authentication & Authorization (JWT, social login)
- Controllers & Routes for Agencies, Properties, Bookings, Payments, Notifications, Locations, Users
- Middlewares (CORS, rate-limit, error handling, authJwt)
- Services layer (StripeService, PayPalService, NotificationService, etc.)
- Data Access via ORM/ODM (models under /models)
- Setup & monitoring (Sentry, instrumentation)
c. Data Stores & Cache
- Primary Database (e.g., PostgreSQL, MongoDB – as configured)
- TTL caches or Queues for scheduled notifications
d. External Services
- Stripe API, PayPal API
- Email SMTP service (via mailHelper)
- Geolocation/IP service
- Push Notification providers (FCM/APNs)
- Sentry (error tracking)
e. Infrastructure & Deployment
- Docker containers for each component
- Nginx reverse proxies (per __config/nginx.conf)
- docker-compose for dev/prod
- CI/CD pipelines (GitHub Actions in .github/workflows)

##### Relationships & Data Flow
1. Clients → Backend API: all client apps consume REST endpoints over HTTPS.
2. Backend API → Database: CRUD operations on Domain Entities (Agency, Property, Booking, User, etc.).
3. Backend API → External Payment Gateways (Stripe, PayPal) for checkout sessions & transactions.
4. Backend API → Email Service for user invites, notifications.
5. Backend API → Push Notification Providers for mobile notifications.
6. Backend API → IP info service for geolocation-based filtering.
7. Nginx acts as an ingress layer: routing to the correct service (admin, frontend, API).
8. CI/CD automates build/test/deploy of containers to target environment.

##### Architectural Patterns & Principles
- Separation of Concerns: distinct layers for controllers, services, data models.
- Shared code via monorepo packages to avoid duplication.
- API-First design: clients are thin; all business logic resides in backend services.
- Micro-frontend–like pattern: independent deployments of admin SPA, customer SPA, mobile.
- Containerized and infrastructure-as-code via Docker & docker-compose.
- Event-driven scheduling for auto-notifications.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Clients"
        Admin["Admin Web SPA<br/>(React/TypeScript + Vite)"]:::client
        Customer["Customer Web SPA<br/>(React/TypeScript + Vite)"]:::client
        Mobile["Mobile App<br/>(React Native/Expo)"]:::client
    end

    subgraph "Backend API"
        API["Backend API<br/>(Node.js/Express/TypeScript)"]:::backend

        subgraph "Controllers & Routes"
            AgencyCtrl["agencyController.ts"]:::backend
            BookingCtrl["bookingController.ts"]:::backend
            PropertyCtrl["propertyController.ts"]:::backend
            UserCtrl["userController.ts"]:::backend
            CountryCtrl["countryController.ts"]:::backend
            IpinfoCtrl["ipinfoController.ts"]:::backend
            LocationCtrl["locationController.ts"]:::backend
            NotificationCtrl["notificationController.ts"]:::backend
            PaypalCtrl["paypalController.ts"]:::backend
            StripeCtrl["stripeController.ts"]:::backend
        end

        subgraph "Middlewares"
            AuthJW["authJwt.ts"]:::backend
            CORS["cors.ts"]:::backend
            AllowedMethods["allowedMethods.ts"]:::backend
            ErrorHandler["errorHandler"]:::backend
            RateLimit["rateLimit"]:::backend
        end

        subgraph "Services & Utils"
            StripeSvc["stripe.ts"]:::backend
            PayPalSvc["paypal.ts"]:::backend
            MailHelper["mailHelper.ts"]:::backend
            IpinfoHelper["ipinfoHelper.ts"]:::backend
            DBHelper["databaseHelper.ts"]:::backend
            DBTTLHelper["databaseTTLHelper.ts"]:::backend
            SentryInstr["instrument.ts"]:::backend
            EnvConfig["env.config.ts"]:::backend
        end

        subgraph "Data Models"
            Models["Models (ORM/ODM)"]:::backend
        end
    end

    subgraph "Data Stores & Cache"
        DB["Database (PostgreSQL/MongoDB)"]:::db
        Cache["TTL Cache / Queue"]:::db
    end

    subgraph "External Services"
        StripeAPI["Stripe API"]:::external
        PayPalAPI["PayPal API"]:::external
        EmailSMTP["SMTP Email Service"]:::external
        GeoIP["Geolocation/IP Service"]:::external
        PushNotif["FCM/APNs"]:::external
        SentryExt["Sentry"]:::external
    end

    subgraph "Shared Packages"
        Packages["packages/"]:::packages
    end

    subgraph "Infrastructure & CI/CD"
        Nginx["Nginx Reverse Proxy"]:::infra
        DockerCont["Docker Containers"]:::infra
        Compose["docker-compose"]:::infra
        CICD["CI/CD Pipelines"]:::infra
    end

    Admin -->|HTTPS| API
    Customer -->|HTTPS| API
    Mobile -->|HTTPS| API
    API -->|CRUD operations| DB
    API -->|enqueue notifications| Cache
    API -->|checkout sessions| StripeAPI
    API -->|checkout sessions| PayPalAPI
    API -->|send emails| EmailSMTP
    API -->|geolocation lookup| GeoIP
    API -->|push notifications| PushNotif
    API -->|error tracking| SentryExt
    Packages --> Admin
    Packages --> Customer
    Packages --> Mobile
    Packages --> API
    Nginx --> Admin
    Nginx --> Customer
    Nginx --> API
    CICD --> DockerCont
    DockerCont --> Nginx

    click Admin "https://github.com/aelassas/movinin/tree/main/admin/"
    click Customer "https://github.com/aelassas/movinin/tree/main/frontend/"
    click Mobile "https://github.com/aelassas/movinin/tree/main/mobile/"
    click API "https://github.com/aelassas/movinin/tree/main/backend/"
    click AuthJW "https://github.com/aelassas/movinin/blob/main/backend/src/middlewares/authJwt.ts"
    click CORS "https://github.com/aelassas/movinin/blob/main/backend/src/middlewares/cors.ts"
    click AllowedMethods "https://github.com/aelassas/movinin/blob/main/backend/src/middlewares/allowedMethods.ts"
    click StripeSvc "https://github.com/aelassas/movinin/blob/main/backend/src/payment/stripe.ts"
    click PayPalSvc "https://github.com/aelassas/movinin/blob/main/backend/src/payment/paypal.ts"
    click MailHelper "https://github.com/aelassas/movinin/blob/main/backend/src/utils/mailHelper.ts"
    click IpinfoHelper "https://github.com/aelassas/movinin/blob/main/backend/src/utils/ipinfoHelper.ts"
    click SentryInstr "https://github.com/aelassas/movinin/blob/main/backend/src/monitoring/instrument.ts"
    click DBHelper "https://github.com/aelassas/movinin/blob/main/backend/src/utils/databaseHelper.ts"
    click DBTTLHelper "https://github.com/aelassas/movinin/blob/main/backend/src/utils/databaseTTLHelper.ts"
    click EnvConfig "https://github.com/aelassas/movinin/blob/main/backend/src/config/env.config.ts"
    click Packages "https://github.com/aelassas/movinin/tree/main/packages/"
    click Nginx "https://github.com/aelassas/movinin/blob/main/__config/nginx.conf"
    click Compose "https://github.com/aelassas/movinin/blob/main/docker-compose.yml"
    click CICD "https://github.com/aelassas/movinin/blob/main/.github/workflows/build.yml"
    click AgencyCtrl "https://github.com/aelassas/movinin/blob/main/backend/src/controllers/agencyController.ts"
    click BookingCtrl "https://github.com/aelassas/movinin/blob/main/backend/src/controllers/bookingController.ts"
    click PropertyCtrl "https://github.com/aelassas/movinin/blob/main/backend/src/controllers/propertyController.ts"
    click UserCtrl "https://github.com/aelassas/movinin/blob/main/backend/src/controllers/userController.ts"
    click CountryCtrl "https://github.com/aelassas/movinin/blob/main/backend/src/controllers/countryController.ts"
    click IpinfoCtrl "https://github.com/aelassas/movinin/blob/main/backend/src/controllers/ipinfoController.ts"
    click LocationCtrl "https://github.com/aelassas/movinin/blob/main/backend/src/controllers/locationController.ts"
    click NotificationCtrl "https://github.com/aelassas/movinin/blob/main/backend/src/controllers/notificationController.ts"
    click PaypalCtrl "https://github.com/aelassas/movinin/blob/main/backend/src/controllers/paypalController.ts"
    click StripeCtrl "https://github.com/aelassas/movinin/blob/main/backend/src/controllers/stripeController.ts"
    click Models "https://github.com/aelassas/movinin/tree/main/backend/src/models/"

    classDef client fill:#FDEBD0,stroke:#D35400,stroke-width:1px
    classDef backend fill:#D6EAF8,stroke:#1F618D,stroke-width:1px
    classDef db fill:#D5F5E3,stroke:#196F3D,stroke-width:1px
    classDef external fill:#F5EEF8,stroke:#6C3483,stroke-width:1px
    classDef packages fill:#FCF3CF,stroke:#B7950B,stroke-width:1px
    classDef infra fill:#EBEDEF,stroke:#566573,stroke-width:1px
```
