How danishaft/photo-ai works
Main Components
• Frontend (apps/web): Built with Next.js 14 and integrated with Clerk for authentication. This component contains multiple pages, UI elements (many lie in apps/web/components) and leverages shared UI packages.
• Backend (apps/backend): A Node.js (TypeScript) service, handling routes (like payment and webhook endpoints), middleware, models, and service logic for payments and likely AI-related functionality.
• Shared Packages (packages/): Includes:
– Shared UI library (@repo/ui) that provides reusable React components.
– TypeScript and ESLint configurations which enforce style and coding conventions across the monorepo.
– A database package (packages/db) that likely encapsulates database interactions using Prisma with migration scripts.
• Docker Configuration (docker/): Contains Dockerfiles for both frontend and backend — these are used for containerizing the two major applications.
• Infrastructure & CI/CD (GitHub workflows in .github/workflows): Automates deployment and other operations.
• External Services: Authentication is handled via Clerk. Payment processing is part of both the backend services (payment routes and service) and the frontend (payment components and related pages). There could be additional integrations through external APIs for image generation or model training.
Relationships and Interactions
• The Frontend interacts with the Backend via API calls (using NEXT_PUBLIC_BACKEND_URL) to trigger processes like image generation, payment processing, model training, etc.
• Authentication flows (with Clerk) begin at the Frontend and the Backend validates based on the passed information.
• The Backend communicates with the database (from packages/db) and leverages ORM via Prisma to manage models and migrations.
• Shared packages are used by both apps to maintain consistency in UI, linting, and TypeScript setups.
• Containerization ties together infrastructure aspects with Docker commands, ensuring both services run within their own container environments.
Architectural Patterns and Design Principles
• Monorepo structure managed with Turborepo, ensuring modularity and reusability of packages.
• Separation of concerns with distinct frontend and backend modules.
• Component-based design in the frontend (using Next.js pages, React components, hooks, etc.).
• Microservice-like separation (even if within one repository): the backend service handles API routing and business logic separately from UI concerns.
• CI/CD pipelines (GitHub workflows) automate deployments for both frontend and backend.
Relevant Technologies & Frameworks
• Next.js 14 with App Router, Tailwind CSS, and Shadcn/UI for the frontend.
• Node.js and TypeScript for the backend.
• Prisma (inside the packages/db folder) for database migrations and data modeling.
• Docker for containerization and deployment.
• Clerk for authentication management.
• Bun as the package manager for local development.
• Turborepo for monorepo orchestration.
• Notes on deployment (e.g., container orchestration with Docker, automated deployments via GitHub workflows).
• On the monorepo structure by showcasing both the Apps (frontend and backend) and the shared Packages to emphasize the reusability and centralized configuration.