# agriya/on-demand-service architecture

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

- Interactive diagram: https://gitdiagram.com/agriya/on-demand-service
- Repository: https://github.com/agriya/on-demand-service

## Overview

##### Project type and purpose
- This is a full-stack, on-demand service booking platform (e.g., dog care, baby care, healthcare, labor services).
- Frontend: AngularJS single-page applications (user portal under `client/app`, admin console under `client/app/ag-admin`), plus a static Swagger API explorer.
- Backend: PHP Slim-based REST API exposing endpoints for bookings, users, payments, messaging, push notifications, etc.
- Persistence: PostgreSQL via Phinx migrations and seeders.
- Media: File storage for uploaded images and avatars under `/media`.
- Build tools: Node/Bower/Grunt for JS/CSS asset compilation; Composer for PHP dependencies.

##### File structure
- Top level:
- `api_explorer/`: static Swagger UI for API documentation & OAuth tester
- `client/`: front-end code, package.json, Bower, Grunt tasks, tests
- `media/`: user- and listing-uploaded files
- `server/php/Slim/`: REST-API code, models, controllers, configuration, migrations, seeders, plugins, public entrypoints, shell scripts
- `sql/`: blank and sample data dumps
- Patterns & components:
- Angular modules structured by domain (controllers, services, views, directives, plugins)
- PHP Slim MVC-light: routes in `public/index.php`, controllers inline in Slim bootstrap, models under `lib/Models`
- Plugins both in frontend (under `client/app/scripts/plugins/...`) and backend (under `server/php/Slim/plugins/...`) following similar directory layout
- Shell/cron jobs in `server/php/Slim/shell` for reminders & notifications
- Database versioning: `server/php/Slim/database/migrations` + `seeds`

##### README for additional insights
- Technology stack: AngularJS, PHP >=5.5.9, PostgreSQL, Nginx/Apache
- Responsibilities: user/provider workflows, OAuth token handling, email, SMS, payment gateways
- Deployment prerequisites and build pipeline

##### Detail is key
- Break out major SPA modules (e.g., Authentication, Booking, Payments, Messaging) as sub-components if desired
- Migration & seeding pipeline under database
- Build pipeline flows (Node/Grunt/Bower → compiled assets → Static Server)

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Client Layer
    subgraph "Client Layer"
        direction TB
        buildSystem["Build System\n(Node/Bower/Grunt)"]:::client
        frontendPlugins["Frontend Plugins"]:::client
        userSPA["User SPA\n(AngularJS)"]:::client
        adminSPA["Admin SPA\n(AngularJS)"]:::client
        swaggerUI["Swagger API Explorer"]:::client
    end

    %% Server Layer
    subgraph "Server Layer"
        direction TB
        staticServer["Static File Server\n(Nginx/Apache)"]:::server
        restEntrypoint["REST API Entrypoint\n(index.php)"]:::server
        restCore["REST API Core & Controllers"]:::server
        backendPlugins["Backend Plugins"]:::server
        shellWorkers["Shell / Cron Workers"]:::server
    end

    %% Data Layer
    subgraph "Data Layer"
        direction TB
        postgres[(PostgreSQL)]:::data
        mediaFS["Media Storage\n(Filesystem)"]:::data
        migrations["DB Migrations"]:::data
        seeds["DB Seeders"]:::data
        models["Models\n(ORM)"]:::data
    end

    %% External Services
    subgraph "External Services"
        direction TB
        oauth["OAuth Providers"]:::external
        payment["Payment Gateways"]:::external
        mailchimp["Mailchimp"]:::external
        push["Push Notification Service"]:::external
        sms["SMS Gateway"]:::external
    end

    %% Build & Deployment Flow
    buildSystem -->|"compiles assets"| staticServer

    staticServer -->|serves SPA| userSPA
    staticServer -->|serves SPA| adminSPA
    staticServer -->|serves docs| swaggerUI

    userSPA -->|"AJAX requests"| restEntrypoint
    adminSPA -->|"AJAX requests"| restEntrypoint

    restEntrypoint -->|"routes to controllers"| restCore
    restCore -->|"uses ORM"| models
    restCore -->|"loads plugins"| backendPlugins
    restCore -->|"reads/writes"| postgres
    restCore -->|"uploads/downloads"| mediaFS

    restCore -->|"calls"| oauth
    restCore -->|"calls"| payment
    restCore -->|"calls"| mailchimp
    restCore -->|"calls"| push
    restCore -->|"calls"| sms

    shellWorkers -->|"runs tasks"| restCore
    shellWorkers -->|"writes logs/data"| postgres
    shellWorkers -->|"sends notifications"| push

    migrations -->|apply schema| postgres
    seeds -->|seed data| postgres

    %% Click Events
    click userSPA "https://github.com/agriya/on-demand-service/tree/master/client/app"
    click adminSPA "https://github.com/agriya/on-demand-service/tree/master/client/app/ag-admin"
    click swaggerUI "https://github.com/agriya/on-demand-service/tree/master/api_explorer/"
    click restEntrypoint "https://github.com/agriya/on-demand-service/blob/master/server/php/Slim/public/index.php"
    click restCore "https://github.com/agriya/on-demand-service/tree/master/server/php/Slim/lib"
    click models "https://github.com/agriya/on-demand-service/tree/master/server/php/Slim/lib/Models"
    click migrations "https://github.com/agriya/on-demand-service/tree/master/server/php/Slim/database/migrations"
    click seeds "https://github.com/agriya/on-demand-service/tree/master/server/php/Slim/database/seeds"
    click backendPlugins "https://github.com/agriya/on-demand-service/tree/master/server/php/Slim/plugins"
    click frontendPlugins "https://github.com/agriya/on-demand-service/tree/master/client/app/scripts/plugins"
    click shellWorkers "https://github.com/agriya/on-demand-service/tree/master/server/php/Slim/shell"
    click mediaFS "https://github.com/agriya/on-demand-service/tree/master/media/"
    click buildSystem "https://github.com/agriya/on-demand-service/blob/master/client/Gruntfile.js"
    click buildSystem "https://github.com/agriya/on-demand-service/blob/master/client/bower.json"
    click buildSystem "https://github.com/agriya/on-demand-service/blob/master/client/package.json"
    click restCore "https://github.com/agriya/on-demand-service/blob/master/server/php/Slim/composer.json"

    %% Styles
    classDef client fill:#BBDEFB,stroke:#0D47A1,color:#0D47A1
    classDef server fill:#C8E6C9,stroke:#1B5E20,color:#1B5E20
    classDef data fill:#FFE0B2,stroke:#E65100,color:#E65100
    classDef external fill:#E1BEE7,stroke:#4A148C,color:#4A148C
```
