How danielp41/engine_api_workflow works
Project Type and Purpose
• This is a Go‐based, monolithic API backend (“Engine API Workflow”) built on the Fiber framework.
• It exposes HTTP endpoints to configure and execute business workflows, persists data in MongoDB, uses Redis for asynchronous queue processing, authenticates via JWT, and integrates with Slack, webhooks, or other external APIs.
File Structure
• Top level:
• cmd/api/main.go → entry point (Fiber server).
• internal/ → core application code, organized by layers:
– api/handlers, middleware, routes → HTTP layer
– services/ → business logic (auth, queue, workflow, integrations)
– repository/ → data access interfaces & implementations (MongoDB, Redis)
– models/ → domain entities (User, Workflow, Log)
– config, utils → configuration loading, error handling, validation, response helpers
• pkg/ → shared utilities (database connectors, logger, JWT lib)
• docker-compose.yml, Dockerfile, Makefile → container orchestration & build scripts
• .github/workflows → CI/CD pipeline definitions
README for Additional Insights
• Confirms tech stack: Go + Fiber, MongoDB, Redis, Docker, GitHub Actions
• Core features: configurable workflows, async processing, integrations, JWT/RBAC, logging/metrics
Main Components
a. Client Layer
• Web UI / CLI / External caller (sends HTTP requests carrying JWTs)
b. API Layer (cmd/api)
• Fiber HTTP server
• Middleware: Authentication (JWT + RBAC), CORS, Request Logging
• Router: maps paths to Handlers
• Handlers: auth.go, workflow.go, trigger.go, log.go
c. Service Layer (internal/services)
• AuthService
• WorkflowService (builds, reads, updates workflows)
• QueueService (publishes/subscribes to Redis)
• IntegrationService(s): Slack, Webhook
d. Data Access Layer (internal/repository + pkg/database)
• MongoDB repositories: user, workflow, log
• Redis repository: queue operations
• Shared connectors in pkg/database
e. Data Stores & Infrastructure
• MongoDB instance (container)
• Redis instance (container as queue store)
• Docker network orchestrating API, DB, Redis
• GitHub Actions CI/CD (build, test, Docker publish)
f. External Services
• Slack API
• Third‐party webhooks / external REST APIs
Relationships & Data Flows
• Client → HTTP(S) → API Layer (middleware → handlers)
• Handler → Service Layer (business logic)
• Service → Repository → Data Stores (read/write from MongoDB, enqueue/dequeue in Redis)
• QueueService → asynchronously triggers goroutines → IntegrationService → calls external Slack/Webhook
• AuthService ↔ JWT lib (pkg/jwt) for token signing/validation
• Logs: Handler/Service → LogRepository → MongoDB
• CI/CD pipeline: pushes code → GitHub Actions → builds Docker image → publishes
Architectural Patterns & Principles
• Layered architecture (HTTP → Services → Repositories → Data Store)
• Dependency inversion: handlers depend on service interfaces; services depend on repository interfaces
• Asynchronous processing via Redis queue + goroutines
• Configuration-driven (internal/config + .env)
• Containerized micro‐environments (not microservices, but separate containers)
Final Checklist
• Components labeled (e.g., “Auth Middleware”, “WorkflowRepository”).
• Boundaries drawn around containers (API app, DB, Queue).
• Annotations for async vs. sync flows, and any retries or error‐handling paths if relevant.