How hitesh22rana/chronoverse works
Main Components
a. Core API & Services:
• API Gateway (“Server”): Located in cmd/server and internal/server. This handles client requests, authentication (using JWT as seen in internal/pkg/auth), and routing to appropriate services.
• Users Service: Found under cmd/users-service with supporting business logic in internal/app/users, internal/service/users, and related repository code. It manages authentication, authorization, and user profiles.
• Workflows Service: Seen in cmd/workflows-service along with its internal implementations. It manages the creation, update, and configuration of workflow definitions.
• Jobs Service: Present as cmd/jobs-service with supporting modules in internal/app/jobs and internal/service/jobs. This service manages scheduled job instances and their lifecycle.
b. Worker Components:
• Scheduling Worker: (cmd/scheduling-worker and internal/app/scheduler) Responsible for reading schedules (for example, based on cron expressions) and determining when jobs should be executed.
• Workflow Worker: (cmd/workflow-worker, internal/app/workflow) Prepares and builds jobs prior to their execution.
• Execution Worker: (cmd/execution-worker, internal/app/executor) In charge of running jobs in isolated environments (leveraging container functionality from internal/pkg/kind/container).
• Joblogs Processor: (cmd/joblogs-processor, internal/app/joblogs) Manages logging and state changes of job executions.
c. Integration & Shared Components:
• Communication / Messaging: The system uses Kafka (internal/pkg/kafka) to enable reliable messaging between the services and workers.
• Databases:
– Postgres: Handles core transactional data (users, workflows, jobs). Look for migrations and repository code in internal/pkg/postgres.
– ClickHouse: Likely used for high-speed ingestion and querying of job logs (internal/pkg/clickhouse).
• Observability: OpenTelemetry integrations (internal/pkg/otel) are used to trace and monitor distributed processes.
• Shared utilities: Common libraries for logging (internal/pkg/logger), crypto (internal/pkg/crypto), and configurations (internal/config).
Relationships and Interactions
• The API Gateway receives client calls (possibly via HTTP or gRPC given the protobuf definitions in pkg/proto) and routes them to the relevant service (Users, Workflows, Jobs).
• Upon scheduling, the Scheduling Worker identifies due jobs and signals the Workflow and Execution Workers to start processing.
• After running a job, log data is gathered and processed by the Joblogs Processor.
• The services and workers communicate via a message broker (Kafka) to ensure asynchronous, reliable messaging.
• Each service and worker loads configuration from internal/config files; these configurations are environment-variable driven (as noted in the README and docker-compose.yaml).
• Common functionalities such as authentication, logging, and error handling are abstracted into internal/pkg modules.
Architectural Patterns and Design Principles
• Microservices Architecture: Each component (API gateway, core services, workers) is independently deployable, containerized (using Docker and orchestrated with docker-compose).
• Separation of Concerns: Business logic is segmented among different service folders (internal/app, internal/service) and further decoupled through dedicated workers.
• Message-driven Communication: Utilizes Kafka to decouple services and ensure fault tolerance.
• Observability and Security: Built-in support for tracing (with OTEL) and JWT-based authentication.
• Use of Code Generation: The presence of buf.yaml and the proto directories indicate that protobuf and gRPC are used for inter-service communication.