How adrian-cai/automation_platform works
1. Purpose and Runtime Shape
AutoTest is a full-stack test-management and orchestration platform: it stores test assets and tasks, schedules or manually triggers work in Jenkins, receives results, and presents live dashboards and reports. Jenkins performs tests; this system owns lifecycle, persistence, visibility, and control.
Entry points are the React/Vite client at src/main.tsx and Express server at server/index.ts. Shared API/domain contracts reside in shared/types/.
2. Frontend Application
The browser UI is a React 18 SPA with authentication, protected navigation, dashboard, case management, tasks, reports, and an AI workbench.
• Shell, routing, and global state: src/App.tsx, src/contexts/AuthContext.tsx, src/components/ProtectedRoute.tsx
• Operational screens: src/pages/tasks/Tasks.tsx, src/pages/cases/AICases.tsx, src/pages/reports/Reports.tsx
• API and real-time clients: src/api/index.ts, src/services/websocket.ts
UI actions call Express APIs; task and execution state is refreshed via polling and Socket.IO updates.
3. API, Security, and Service Boundary
Express routes form the public control boundary. Middleware applies JWT authentication, callback-specific Jenkins authentication, validation, logging, and rate limits before business services execute.
• Server composition: server/index.ts, server/middleware/auth.ts, server/middleware/JenkinsAuthMiddleware.ts
• Core API domains: server/routes/tasks.ts, server/routes/executions.ts, server/routes/jenkins.ts
• Cross-cutting controls: server/middleware/authRateLimiter.ts, server/middleware/RequestValidator.ts
Auth supports user registration/login and password flows through server/routes/auth.ts and server/services/AuthService.ts.
4. Task Scheduling and Execution Lifecycle
TaskSchedulerService is the central orchestration engine. It restores active jobs, polls persisted task definitions, evaluates five-field cron schedules, deduplicates scheduled windows, enforces FIFO/concurrency policy, and dispatches eligible runs. It also handles retries and cancellation state.
• Scheduler and queue policy: server/services/TaskSchedulerService/service.ts, server/services/TaskSchedulerService/queuePolicy.ts, server/services/TaskSchedulerService/cron.ts
• Execution lifecycle/state synchronization: server/services/ExecutionService/service.ts, server/services/ExecutionService/statusSync.ts
• Task/execution persistence access: server/repositories/ExecutionRepository.ts, server/entities/TaskExecution.ts, server/entities/TestRun.ts
Flow: UI/API or cron creates an execution request → scheduler admits it → Jenkins is triggered → callback/polling updates run and per-case results → live clients and reports observe the final state.
5. Jenkins and External Execution Boundary
Jenkins is an external executor reached through the Jenkins service and routes. The platform records a local execution before/while triggering Jenkins, then accepts authenticated callbacks or uses hybrid polling/status diagnostics to reconcile asynchronous outcomes.
• Trigger and integration logic: server/services/JenkinsService.ts, server/routes/jenkinsExecutionRoutes.ts
• Callback and status handling: server/routes/executions.ts, server/services/CallbackQueue.ts, server/services/HybridSyncService/service.ts
• Monitoring/repair diagnostics: server/services/ExecutionMonitorService.ts, server/services/JenkinsStatusService/service.ts
Results may trigger email notification and Socket.IO broadcasts via server/services/EmailService.ts and server/services/WebSocketService.ts.
6. Persistence, Reporting, and AI Requirement Flow
MariaDB is accessed through TypeORM configuration, entities, and repositories; it is the source of truth for users, cases, tasks, runs, results, workspaces, and daily summaries. Dashboard services derive operational aggregates from this data.
• Database boundary: server/config/dataSource.ts, server/entities/index.ts, server/repositories/DashboardRepository.ts
• Reporting: server/services/DashboardService.ts, server/routes/dashboard.ts
• AI/requirement ingestion and case generation: server/routes/requirementFiles.ts, server/services/requirementFiles/uploadService.ts, server/services/AiCaseGenerationService/service.ts
The AI workbench accepts requirement files/text, parses and stores structured inputs, generates/normalizes case plans, and exposes workspace/case-map views through AI case APIs.
7. Deployment and Automation
Node.js 20 runs both TypeScript services; Vite builds the client. Production uses PM2 and can be containerized. MariaDB, Jenkins, Git repositories, SMTP, and GitHub Actions are material integrations.
• Runtime/deployment: Dockerfile, ecosystem.config.js, server/config/database.ts
• CI/CD and smoke testing: .github/workflows/github-ci.yml, .github/workflows/deploy.yml, perf/smoke.js
• Repository-sync utility: .github/scripts/sync_cases.py
Main entry points: service.ts Execution lifecycle · auth.ts Auth and request controls · index.ts Express server · dataSource.ts MariaDB
Components 20
React client
- SPA entry and shell · Routes and global application state.
src/main.tsx - Protected operations UI · Tasks, AI cases, and reports screens.
src/pages/tasks/Tasks.tsx - API and realtime clients · Calls APIs and receives execution updates.
src/api/index.ts
Express control plane
- Express server · Composes public APIs and Socket.IO.
server/index.ts - Auth and request controls · JWT, Jenkins callback auth, validation, and rate limits.
server/middleware/auth.ts - User authentication · Registration, login, and password flows.
server/services/AuthService.ts - Task and execution APIs · Creates and controls tasks and executions.
server/routes/tasks.ts - Jenkins integration APIs · Trigger endpoints and authenticated callback entry.
server/routes/jenkinsExecutionRoutes.ts
Execution orchestration
- Task scheduler · Cron admission, deduplication, FIFO concurrency, retries, and cancellation.
server/services/TaskSchedulerService/service.ts - Execution lifecycle · Creates local runs and synchronizes lifecycle state.
server/services/ExecutionService/service.ts - Jenkins trigger service · Dispatches eligible runs to Jenkins.
server/services/JenkinsService.ts - Hybrid result sync · Reconciles callbacks, polling, and diagnostics.
server/services/HybridSyncService/service.ts - Live notifications · Broadcasts state changes and sends result email.
server/services/WebSocketService.ts
Data and insights
- MariaDB · Stores users, cases, tasks, runs, results, workspaces, and summaries.
server/config/dataSource.ts - Dashboard and reports · Derives operational aggregates from persisted data.
server/services/DashboardService.ts - Requirement ingestion · Accepts, parses, and stores requirement files and text.
server/services/requirementFiles/uploadService.ts - AI case generation · Generates and normalizes case plans.
server/services/AiCaseGenerationService/service.ts
External systems
- Jenkins · Runs test jobs and emits asynchronous outcomes.
- SMTP
- GitHub Actions · Builds, deploys, and runs smoke automation.
.github/workflows/github-ci.yml
Connections 26
- SPA entry and shell → Protected operations UI: renders routes
- Protected operations UI → API and realtime clients: user actions
- API and realtime clients → Express server: HTTP and Socket.IO
- Express server → Auth and request controls: applies controls
- Auth and request controls → User authentication: auth flows
- Auth and request controls → Task and execution APIs: authorized requests
- Auth and request controls → Jenkins integration APIs: authenticated callbacks
- Task and execution APIs → Task scheduler: manual execution requests
- Task scheduler → Execution lifecycle: admits runs
- Task scheduler → MariaDB: loads tasks and persists scheduling state
- Execution lifecycle → MariaDB: persists runs and results
- Execution lifecycle → Jenkins trigger service: dispatches execution
- Jenkins trigger service → Jenkins: triggers job
- Jenkins → Jenkins integration APIs: callbacks
- Jenkins integration APIs → Hybrid result sync: outcomes and status requests
- Hybrid result sync → Jenkins: polls status
- Hybrid result sync → Execution lifecycle: reconciled state
- Execution lifecycle → Live notifications: execution changes
- Live notifications → API and realtime clients: live updates
- Live notifications → SMTP: result email
- MariaDB → Dashboard and reports: operational data
- Dashboard and reports → Express server: dashboard APIs
- Protected operations UI → Requirement ingestion: requirement input
- Requirement ingestion → AI case generation: structured requirements
- AI case generation → MariaDB: case plans and workspaces
- GitHub Actions → Express server: build and deploy