How moazzamfarooqui/n8n-smart-assistant works
This is a Phase 1 Express backend: clients can check service health, register or log in, and retrieve the authenticated user profile. Authentication routes validate requests, use the user model for persistence and password checks, and issue JWTs; protected requests pass through JWT authentication. The repository also defines persistence models for workflows, chat sessions/messages, and execution logs, but the README and sampled routes do not show those capabilities exposed as endpoints. Gemini and n8n settings exist, but no sampled runtime integration is shown.
Main entry points: db.ts MySQL pool · app.ts Express application · auth.ts Auth endpoints · User.ts User accounts
Components 14
API runtime
- Express application
src/app.ts - Auth endpoints
src/routes/auth.ts - Health endpoint
src/routes/health.ts - Error handler
src/middleware/errorHandler.ts
Identity and access
- JWT authentication
src/middleware/auth.ts
Domain persistence
- User accounts
src/models/User.ts - Saved workflows
src/models/Workflow.ts - Chat sessions
src/models/ChatSession.ts - Chat messages
src/models/ChatMessage.ts - Execution logs
src/models/WorkflowExecution.ts
Runtime infrastructure
- MySQL pool
src/config/db.ts - Environment config
src/config/env.ts
Other components
- API client
- MySQL database
Connections 24
- API client → Express application: sends requests
README.md - Express application → Auth endpoints: mounts auth
src/app.ts - Express application → Health endpoint: mounts health
src/app.ts - Express application → Error handler: handles errors
src/app.ts - Express application → MySQL pool: tests connection
src/app.ts - Express application → Environment config: reads settings
src/app.ts - Auth endpoints → User accounts: looks up accounts
src/routes/auth.ts - Auth endpoints → User accounts: creates accounts
src/routes/auth.ts - Auth endpoints → JWT authentication: protects profile
src/routes/auth.ts - Auth endpoints → JWT authentication: issues tokens
src/routes/auth.ts - JWT authentication → User accounts: loads account
src/middleware/auth.ts - JWT authentication → Environment config: reads JWT settings
src/middleware/auth.ts - User accounts → MySQL pool: queries pool
src/models/User.ts - Saved workflows → MySQL pool: queries pool
src/models/Workflow.ts - Chat sessions → MySQL pool: queries pool
src/models/ChatSession.ts - Chat messages → MySQL pool: uses pool
src/models/ChatMessage.ts - Execution logs → MySQL pool: queries pool
src/models/WorkflowExecution.ts - MySQL pool → Environment config: reads DB settings
src/config/db.ts - MySQL pool → MySQL database: opens connection
src/config/db.ts - User accounts → MySQL database: reads and writes
src/models/User.ts - Saved workflows → MySQL database: reads and writes
src/models/Workflow.ts - Chat sessions → MySQL database: reads and writes
src/models/ChatSession.ts - Chat messages → MySQL database: persists messages
src/models/ChatMessage.ts - Execution logs → MySQL database: reads and writes
src/models/WorkflowExecution.ts