# iot-ahmad/psyai architecture

> Architecture diagram of the GitHub repository iot-ahmad/psyai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/iot-ahmad/psyai
- Repository: https://github.com/iot-ahmad/psyai

## Overview

PsyAI is a mental-health consultation platform with user authentication, specialist discovery, appointment booking and payment, plus specialist and administrative portals. The server exposes these workflows through Express routes; controllers handle domain operations and persist through Prisma. Specialist tools include appointment/session management and article publishing. The tree also shows a browser frontend, but its runtime connections to the API are not evidenced by the sampled excerpts or SOURCE INDEX. No README was provided, so additional product capabilities are limited to those visible in the source and tree.

Main entry points: [`server/src/index.js`](https://github.com/iot-ahmad/psyai/blob/main/server/src/index.js) (Express routes), [`server/src/config/db.js`](https://github.com/iot-ahmad/psyai/blob/main/server/src/config/db.js) (Prisma client), [`server/src/controllers/authController.js`](https://github.com/iot-ahmad/psyai/blob/main/server/src/controllers/authController.js) (Authentication), [`server/src/services/whatsappService.js`](https://github.com/iot-ahmad/psyai/blob/main/server/src/services/whatsappService.js) (WhatsApp messaging)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_web_pages["Web pages<br/>[index.html]"]
  node_web_scripts["Browser behavior<br/>[script.js]"]
  node_article_store["Article store<br/>[articles-store.js]"]
end

subgraph group_api["API and workflows"]
  node_api_entry["Express routes<br/>[index.js]"]
  node_auth["Authentication<br/>[authController.js]"]
  node_specialists["Specialist discovery"]
  node_bookings["Booking management"]
  node_payments["Payment routes"]
  node_admin["Administration<br/>[adminController.js]"]
  node_specialist_portal["Specialist portal"]
  node_auth_middleware["Access control<br/>[auth.js]"]
  node_security_middleware["Request security<br/>[security.js]"]
  node_validation["Input validation<br/>[validate.js]"]
end

subgraph group_services["Shared services"]
  node_payment_service["Card processing<br/>[paymentService.js]"]
  node_whatsapp["WhatsApp messaging<br/>[whatsappService.js]"]
  node_security_service["Security utilities<br/>[securityService.js]"]
  node_audit["Audit logging<br/>[auditService.js]"]
end

subgraph group_data["Persistence"]
  node_db_client["Prisma client<br/>[db.js]"]
  node_database[("Application database<br/>[schema.prisma]")]
end

node_visitor(("Platform user"))
node_whatsapp_provider["Meta WhatsApp"]

node_api_entry -->|"routes to"| node_auth
node_api_entry -->|"routes to"| node_specialists
node_api_entry -->|"routes to"| node_bookings
node_api_entry -->|"routes to"| node_payments
node_api_entry -->|"routes to"| node_admin
node_api_entry -->|"routes to"| node_specialist_portal
node_api_entry -->|"applies"| node_auth_middleware
node_api_entry -->|"configures"| node_security_middleware
node_api_entry -->|"applies"| node_validation
node_auth -->|"reads and writes"| node_db_client
node_specialists -->|"queries"| node_db_client
node_bookings -->|"reads and writes"| node_db_client
node_admin -->|"reads and writes"| node_db_client
node_specialist_portal -->|"reads and writes"| node_db_client
node_payments -->|"delegates to"| node_payment_service
node_payment_service -->|"reads and writes"| node_db_client
node_auth -->|"requests OTP"| node_whatsapp
node_auth -->|"uses"| node_security_service
node_auth -->|"records events"| node_audit
node_specialist_portal -->|"sends notices"| node_whatsapp
node_specialist_portal -->|"records events"| node_audit
node_whatsapp -->|"stores OTPs"| node_db_client
node_whatsapp -->|"verifies OTP hash"| node_security_service
node_whatsapp -->|"sends messages"| node_whatsapp_provider
node_audit -->|"writes logs"| node_db_client
node_audit -->|"hashes IP"| node_security_service
node_db_client -.->|"accesses"| node_database

click node_web_pages "https://github.com/iot-ahmad/psyai/blob/main/index.html"
click node_web_scripts "https://github.com/iot-ahmad/psyai/blob/main/script.js"
click node_article_store "https://github.com/iot-ahmad/psyai/blob/main/articles-store.js"
click node_api_entry "https://github.com/iot-ahmad/psyai/blob/main/server/src/index.js"
click node_auth "https://github.com/iot-ahmad/psyai/blob/main/server/src/controllers/authController.js"
click node_specialists "https://github.com/iot-ahmad/psyai/blob/main/server/src/controllers/specialistsController.js"
click node_bookings "https://github.com/iot-ahmad/psyai/blob/main/server/src/controllers/bookingsController.js"
click node_payments "https://github.com/iot-ahmad/psyai/blob/main/server/src/controllers/paymentsController.js"
click node_admin "https://github.com/iot-ahmad/psyai/blob/main/server/src/controllers/adminController.js"
click node_specialist_portal "https://github.com/iot-ahmad/psyai/blob/main/server/src/controllers/specialistPortalController.js"
click node_auth_middleware "https://github.com/iot-ahmad/psyai/blob/main/server/src/middlewares/auth.js"
click node_security_middleware "https://github.com/iot-ahmad/psyai/blob/main/server/src/middlewares/security.js"
click node_validation "https://github.com/iot-ahmad/psyai/blob/main/server/src/middlewares/validate.js"
click node_payment_service "https://github.com/iot-ahmad/psyai/blob/main/server/src/services/paymentService.js"
click node_whatsapp "https://github.com/iot-ahmad/psyai/blob/main/server/src/services/whatsappService.js"
click node_security_service "https://github.com/iot-ahmad/psyai/blob/main/server/src/services/securityService.js"
click node_audit "https://github.com/iot-ahmad/psyai/blob/main/server/src/services/auditService.js"
click node_db_client "https://github.com/iot-ahmad/psyai/blob/main/server/src/config/db.js"
click node_database "https://github.com/iot-ahmad/psyai/blob/main/server/prisma/schema.prisma"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_web_pages,node_web_scripts,node_article_store,node_visitor toneBlue
class node_api_entry,node_auth,node_specialists,node_bookings,node_payments,node_admin,node_specialist_portal,node_auth_middleware,node_security_middleware,node_validation toneAmber
class node_payment_service,node_whatsapp,node_security_service,node_audit toneMint
class node_db_client,node_database toneRose
class node_whatsapp_provider toneIndigo
```

## Components

### Web experience

- [Web pages](https://github.com/iot-ahmad/psyai/blob/main/index.html): `index.html`
- [Browser behavior](https://github.com/iot-ahmad/psyai/blob/main/script.js): `script.js`
- [Article store](https://github.com/iot-ahmad/psyai/blob/main/articles-store.js): `articles-store.js`

### API and workflows

- [Express routes](https://github.com/iot-ahmad/psyai/blob/main/server/src/index.js): `server/src/index.js`
- [Authentication](https://github.com/iot-ahmad/psyai/blob/main/server/src/controllers/authController.js): `server/src/controllers/authController.js`
- [Specialist discovery](https://github.com/iot-ahmad/psyai/blob/main/server/src/controllers/specialistsController.js): `server/src/controllers/specialistsController.js`
- [Booking management](https://github.com/iot-ahmad/psyai/blob/main/server/src/controllers/bookingsController.js): `server/src/controllers/bookingsController.js`
- [Payment routes](https://github.com/iot-ahmad/psyai/blob/main/server/src/controllers/paymentsController.js): `server/src/controllers/paymentsController.js`
- [Administration](https://github.com/iot-ahmad/psyai/blob/main/server/src/controllers/adminController.js): `server/src/controllers/adminController.js`
- [Specialist portal](https://github.com/iot-ahmad/psyai/blob/main/server/src/controllers/specialistPortalController.js): `server/src/controllers/specialistPortalController.js`
- [Access control](https://github.com/iot-ahmad/psyai/blob/main/server/src/middlewares/auth.js): `server/src/middlewares/auth.js`
- [Request security](https://github.com/iot-ahmad/psyai/blob/main/server/src/middlewares/security.js): `server/src/middlewares/security.js`
- [Input validation](https://github.com/iot-ahmad/psyai/blob/main/server/src/middlewares/validate.js): `server/src/middlewares/validate.js`

### Shared services

- [Card processing](https://github.com/iot-ahmad/psyai/blob/main/server/src/services/paymentService.js): `server/src/services/paymentService.js`
- [WhatsApp messaging](https://github.com/iot-ahmad/psyai/blob/main/server/src/services/whatsappService.js): `server/src/services/whatsappService.js`
- [Security utilities](https://github.com/iot-ahmad/psyai/blob/main/server/src/services/securityService.js): `server/src/services/securityService.js`
- [Audit logging](https://github.com/iot-ahmad/psyai/blob/main/server/src/services/auditService.js): `server/src/services/auditService.js`

### Persistence

- [Prisma client](https://github.com/iot-ahmad/psyai/blob/main/server/src/config/db.js): `server/src/config/db.js`
- [Application database](https://github.com/iot-ahmad/psyai/blob/main/server/prisma/schema.prisma): `server/prisma/schema.prisma`

### Other components

- **Platform user**
- **Meta WhatsApp**

## Connections

- Express routes → Authentication: routes to (evidence: `server/src/index.js`)
- Express routes → Specialist discovery: routes to (evidence: `server/src/index.js`)
- Express routes → Booking management: routes to (evidence: `server/src/index.js`)
- Express routes → Payment routes: routes to (evidence: `server/src/index.js`)
- Express routes → Administration: routes to (evidence: `server/src/index.js`)
- Express routes → Specialist portal: routes to (evidence: `server/src/index.js`)
- Express routes → Access control: applies (evidence: `server/src/index.js`)
- Express routes → Request security: configures (evidence: `server/src/index.js`)
- Express routes → Input validation: applies (evidence: `server/src/index.js`)
- Authentication → Prisma client: reads and writes (evidence: `server/src/controllers/authController.js`)
- Specialist discovery → Prisma client: queries (evidence: `server/src/controllers/specialistsController.js`)
- Booking management → Prisma client: reads and writes (evidence: `server/src/controllers/bookingsController.js`)
- Administration → Prisma client: reads and writes (evidence: `server/src/controllers/adminController.js`)
- Specialist portal → Prisma client: reads and writes (evidence: `server/src/controllers/specialistPortalController.js`)
- Payment routes → Card processing: delegates to (evidence: `server/src/controllers/paymentsController.js`)
- Card processing → Prisma client: reads and writes (evidence: `server/src/services/paymentService.js`)
- Authentication → WhatsApp messaging: requests OTP (evidence: `server/src/controllers/authController.js`)
- Authentication → Security utilities: uses (evidence: `server/src/controllers/authController.js`)
- Authentication → Audit logging: records events (evidence: `server/src/controllers/authController.js`)
- Specialist portal → WhatsApp messaging: sends notices (evidence: `server/src/controllers/specialistPortalController.js`)
- Specialist portal → Audit logging: records events (evidence: `server/src/controllers/specialistPortalController.js`)
- WhatsApp messaging → Prisma client: stores OTPs (evidence: `server/src/services/whatsappService.js`)
- WhatsApp messaging → Security utilities: verifies OTP hash (evidence: `server/src/services/whatsappService.js`)
- WhatsApp messaging → Meta WhatsApp: sends messages (evidence: `server/src/services/whatsappService.js`)
- Audit logging → Prisma client: writes logs (evidence: `server/src/services/auditService.js`)
- Audit logging → Security utilities: hashes IP (evidence: `server/src/services/auditService.js`)
- Prisma client → Application database: accesses
