Core Technologies Used in AiToEarn: Complete Tech Stack Breakdown
AiToEarn is built on a modern TypeScript monorepo architecture featuring NestJS for the backend API, Next.js for the web frontend, MongoDB and Redis for data persistence, BullMQ for asynchronous job processing, and Docker for containerized deployment.
AiToEarn is an open-source AI-driven content monetization platform that combines video generation, automated publishing, and engagement tools into a unified ecosystem. The project is organized as a full-stack TypeScript monorepo managed with Nx and pnpm, targeting Node.js 20 across all services. Understanding the core technologies used in AiToEarn reveals how the system orchestrates complex AI workflows while maintaining type safety and scalability.
Monorepo Architecture: Nx, pnpm, and Node.js 20
The entire codebase targets Node.js 20.x, as indicated by the engine requirements in the repository configuration. The project uses Nx to manage the monorepo structure, enabling fast incremental builds and shared libraries across the backend, frontend, and desktop applications.
Package management is handled exclusively by pnpm, evident from the pnpm-lock.yaml files throughout the project. This choice provides disk space efficiency and strict dependency resolution across the workspace.
# Install all dependencies across the monorepo
pnpm install
# Serve the backend application
cd project/aitoearn-backend
pnpm nx serve aitoearn-server
# Start the web development server
cd ../aitoearn-web
pnpm run dev
The workspace configuration lives in nx.json and workspace.json at the repository root, defining project boundaries and build orchestration.
Backend Framework: NestJS with Express
The API server is built on NestJS, utilizing the Express platform. The bootstrap entry point resides in project/aitoearn-backend/libs/common/src/starter.ts, where the Nest application factory initializes the server with CORS, Swagger documentation, and global interceptors.
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
// Global filters, interceptors, and pipes applied here
await app.listen(3000);
}
bootstrap();
Key architectural patterns implemented include:
- Filters and Interceptors for centralized error handling and response transformation (located in
libs/common/src/interceptors/) - Pipes for input validation and transformation
- Swagger/OpenAPI integration patched via
patchNestJsSwagger()inlibs/common/src/utils/zod-openapi.util.tsto merge Zod schemas automatically into the API documentation
Frontend Stack: Next.js and Tailwind CSS
The web interface resides in project/aitoearn-web as a Next.js application written in TypeScript. The configuration uses ESM modules via next.config.mjs and integrates Tailwind CSS for styling, configured in tailwind.config.ts.
// pages/index.tsx example
export default function Home() {
return (
<main className="p-4">
<h1 className="text-2xl font-bold">AiToEarn Dashboard</h1>
</main>
);
}
The frontend consumes the NestJS backend API and provides the user interface for content creation, scheduling, and analytics. Build tooling and linting are configured through eslint.config.mjs and .prettierrc in the web directory.
Data Persistence: MongoDB and Redis
Persistent data storage uses MongoDB through a custom abstraction layer. The backend includes a dedicated MongoDB library (libs/mongodb) that wraps the official driver and provides typed repositories for entities like posts, users, and transactions.
import { MongoClient } from 'mongodb';
const client = new MongoClient(process.env.MONGODB_URI);
await client.connect();
const db = client.db('aitoearn');
const posts = db.collection<Post>('posts');
For caching and ephemeral data, Redis is deployed via the libs/redis library. Redis handles rate-limiting counters, session storage, and serves as the message broker for job queues.
Background Processing: BullMQ Job Queues
Asynchronous task processing uses BullMQ, backed by Redis. The system queues video generation jobs, content publishing tasks, and AI-driven comment replies through dedicated processors defined in project/aitoearn-backend/libs/aitoearn-queue.
import { Queue } from 'bullmq';
const videoQueue = new Queue('video-generation', {
connection: { host: 'localhost', port: 6379 },
});
await videoQueue.add('generate', { postId: '123' });
The queue processors utilize decorators defined in libs/aitoearn-queue/src/decorators/queue-processor.decorator.ts, allowing NestJS-style dependency injection within job handlers.
AI Integration Layer
AiToEarn integrates multiple generative AI services through HTTP clients wrapped in service classes under libs/aitoearn-ai-client. Supported models include:
- Grok, Veo, and Seedance for video generation
- Nano Banana for image generation
These services are invoked from the backend and queued via BullMQ to handle long-running generation tasks without blocking the API.
Validation and Documentation: Zod and OpenAPI
Runtime type safety is enforced using Zod schemas, which are also transformed into OpenAPI specifications via zod-to-json-schema. The utility in project/aitoearn-backend/libs/common/src/utils/zod-openapi.util.ts patches NestJS Swagger to automatically reflect Zod validation rules in the API documentation.
import { z } from 'zod';
export const CreatePostSchema = z.object({
title: z.string(),
content: z.string(),
});
This ensures that API contracts remain synchronized between TypeScript code and the Swagger UI interface.
Deployment and Containerization: Docker
Production deployment is streamlined through Docker Compose, defined in docker-compose.yml at the repository root. The configuration orchestrates:
- The NestJS API server
- MongoDB database
- Redis cache
- Optional Relay service for OAuth handling
git clone https://github.com/yikart/AiToEarn.git
cd AiToEarn
docker compose up -d
This single-command deployment provisions the entire stack including persistent storage volumes and networking.
Desktop Client: Electron with SQLite
An optional Electron desktop application exists in project/aitoearn-electron, providing a native OS experience. The Electron client bundles better-sqlite3 for local data persistence and reuses backend libraries for business logic.
cd project/aitoearn-electron
npm install
npm run dev # Launches the Electron window
The desktop client is configured via package.json in the electron directory, with entry points handling window management and IPC communication with the embedded backend services.
Summary
- AiToEarn utilizes Node.js 20 with TypeScript throughout the monorepo
- Nx and pnpm manage the workspace architecture and dependencies
- NestJS powers the backend API with Zod validation and Swagger documentation
- Next.js with Tailwind CSS delivers the web frontend
- MongoDB provides primary data persistence while Redis handles caching
- BullMQ manages background job processing for AI generation tasks
- Docker Compose enables one-command production deployment
- Electron offers an optional desktop client with SQLite storage
Frequently Asked Questions
What backend framework does AiToEarn use?
AiToEarn uses NestJS with the Express platform as its backend framework. The application bootstrap occurs in project/aitoearn-backend/libs/common/src/starter.ts, utilizing NestJS modules, decorators, and dependency injection. The backend also implements filters, interceptors, and pipes for request handling, and integrates Swagger for API documentation via the patchNestJsSwagger() utility in zod-openapi.util.ts.
How does AiToEarn handle asynchronous AI processing?
The platform uses BullMQ for job queue management, with Redis as the backing store. When users trigger AI generation tasks (such as video creation with Grok or Veo), these jobs are enqueued in BullMQ rather than processed synchronously. Processor decorators in libs/aitoearn-queue/src/decorators/queue-processor.decorator.ts define how these background workers handle tasks like video generation and content publishing.
What database technologies does AiToEarn use for data storage?
AiToEarn employs MongoDB as its primary database for persistent storage of posts, users, and transactions, accessed through the mongodb library in project/aitoearn-backend/libs/mongodb. Redis is used for caching, rate limiting, and as the message broker for BullMQ queues. The optional Electron desktop client uses SQLite via better-sqlite3 for local storage.
Is AiToEarn containerized for deployment?
Yes, AiToEarn includes full Docker support through a docker-compose.yml file that orchestrates the entire stack. The compose configuration spins up the NestJS API, MongoDB, Redis, and optional OAuth relay services. This allows single-command deployment (docker compose up -d) for production or development environments without manual dependency installation.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →