How code100x/photo-ai works
Based on our analysis of the file tree and README, here’s an approach tailored to the 100xPhoto project—a full-stack AI image generation platform with a clear separation between a Next.js-based frontend and a Node.js backend, plus shared packages and Docker containerization.
Main Components
• Frontend (apps/web): This is the Next.js application using TypeScript, Tailwind CSS, and Shadcn/UI for the UI. It handles user interaction, displays AI-generated images, and integrates with authentication (Clerk) and payment flows.
• Backend (apps/backend): A Node.js/TypeScript service that provides APIs for image generation, payment processing (routes like payment.routes.ts and webhook.routes.ts), and model training. It likely communicates with a database.
• Shared Packages:
• UI Components (packages/ui) – a shared React component library for both frontend consistency.
• Configuration and Linting (packages/typescript-config, packages/eslint-config) – to ensure consistency across the monorepo.
• Database (packages/db) – contains Prisma schemas and migrations; it represents the data layer.
• Docker Containerization: Dockerfiles for both frontend and backend (in the docker directory) allow deployment of services in isolated containers.
• CI/CD Workflows: Found in the .github/workflows directory handling deployment for both backend and frontend.
Relationships and Interactions
• The Frontend communicates with the Backend primarily via REST or potentially other API mechanisms. It relies on environment (NEXT_PUBLIC_BACKEND_URL) to point to the backend service.
• The Backend interacts with the Database layer (via Prisma configurations found in packages/db) to store and retrieve image data, subscription details, transactions, etc.
• Shared UI components are used in the frontend to provide a consistent user interface.
• The authentication mechanism using Clerk is integrated within the frontend (and possibly backend) components.
• CI/CD workflows, managed with GitHub Actions, trigger deployments for the dockerized images.
Architectural Patterns and Technologies
• Separation of Concerns: Clear separation between frontend and backend.
• Monorepo Management: Managed via Turborepo (as indicated in the README) which coordinates the builds across apps and packages.
• Containerization: Docker is used to build and run isolated environments for the frontend and backend.
• Shared Libraries: Reusing components and configurations across applications.
• API-Driven Interaction: The frontend uses API calls to drive business logic while the backend provides endpoints for operations like payment and image generation.