How yuazhi/yuazhi-chat works
yuazhi-chat is a browser-based AI chat application with PHP account and conversation APIs, a JavaScript chat client, and an AI image-generation proxy. The main flow is an authenticated user opening the chat UI, sending prompts through the client API layer, and seeing responses; image prompts use a separate proxy. PHP also handles account actions and persisted chat history. The README describes broader messaging features, but the sampled files do not verify WebSockets, group chat, offline push, or Redis; those connections are omitted. Database persistence is visible in the PHP API, while db.js appears separate and is not shown in the request path.
Main entry points: index.php Chat page · main.js Chat interactions · api.js API client · login.php Login and registration
Components 20
Chat client
- Chat page
index.php - Chat interactions
main.js - API client
api.js - Offline cache
sw.js
PHP services
- Chat API
api.php
Persistence
- Database config
config.php - MySQL data
- JS data helpers
db.js
Account access
- Login and registration
login.php - Registration page
register.php - Account actions
api.php - Password recovery
forgot-password.php - Password reset
reset-password.php - Logout
logout.php
AI integrations
- Drawing request
api.js - Drawing proxy
draw_proxy.php - Image generation API
- Chat completion API
- Image download proxy
download_proxy.php
Other components
- User
Connections 13
- User → Chat page: opens
index.php - Chat page → Chat interactions: hosts
- Chat interactions → API client: calls
main.js - API client → Chat completion API: sends prompts
api.js - Registration page → Account actions: posts registration
register.php - Login and registration → Account actions: posts login
login.php - Chat API → MySQL data: reads and writes
api.php - Drawing request → Drawing proxy: posts prompt
api.js - Drawing proxy → Image generation API: requests image
draw_proxy.php - Chat page → Offline cache: registers worker
index.php - JS data helpers → MySQL data: queries
db.js - User → Login and registration: signs in
login.php - User → Registration page: registers
register.php