How marketcalls/sketchmaker works
Project Type and Purpose
• Sketch Maker AI is a full-stack, monolithic web application built with Flask (Python). It provides an AI-powered image and banner generation platform with features like virtual try-on, custom model training, an admin subscription system, and a responsive user interface.
File Structure Analysis
• Top-level directories:
• blueprints/ – Flask “controllers” organized by feature (auth, admin, gallery, virtual, magix, training, etc.)
• models/ & models.py – SQLAlchemy data models (users, subscriptions, content, API settings)
• migrations/ – Alembic migration scripts for schema evolution
• services/ – Pure-Python helper modules (image_optimizer, scheduler)
• static/ – Client-side assets (CSS, JS, images)
• templates/ – Jinja2 HTML templates grouped by feature
• server/ – System-level deploy scripts and service definitions
• docs/ – Project documentation and API references
• Core configuration: app.py (Flask app factory), extensions.py (Flask-Login, Limiter, APScheduler), requirements.txt, .env.sample
README Insights
• Backend: Flask 3.0.3, SQLAlchemy (SQLite/PostgreSQL), APScheduler for jobs, Cryptography (Fernet), OAuth integration
• Frontend: Tailwind CSS + DaisyUI, Vanilla ES6 JS modules, Fabric.js, GSAP
• External Integrations: OpenAI, Anthropic, Google Gemini, Groq, FAL, SMTP/Amazon SES, Google OAuth
Main Components
a. Client Layer (Browser)
• Static assets: HTML templates (Jinja2), CSS (Tailwind + custom), JS modules (image-gen-controls, form-handler, ui-updater)
• User interactions: Login, generate images, view gallery, admin panel
b. Application Layer (Flask)
• Blueprint modules: auth, admin, core, gallery, generate, virtual, magix, training, banner
• Shared services: extensions.py (DB connection, scheduler, rate limiter), services/image_optimizer.py, services/scheduler.py
• Business logic: credit system, model management, prompt generation, image processing
c. Data Layer
• Database: SQLAlchemy ORM → PostgreSQL/SQLite
• Migrations: Alembic migration scripts
• File storage: Local filesystem (static/uploads, training_files)
d. External Services
• AI Providers: OpenAI, Anthropic, Google Gemini, Groq, FAL (via REST/SDK)
• Email: SMTP server or Amazon SES
• OAuth: Google OAuth endpoints
e. Background Jobs
• APScheduler tasks: credit reset, training progress checks, cleanup jobs
Relationships and Data Flows
• User requests (via browser) → Flask route (blueprint)
• Route invokes controller → business logic → ORM models / services
• If AI generation: service layer calls external AI API → returns image(s) → post-processing (image_optimizer) → store in filesystem + metadata in DB → response to user
• Subscription management: DB triggers via APScheduler → update user credits at schedule → admin dashboard reads/writes DB
• Email flows: controllers call email-sending service → external SMTP/SES → user inbox
Architectural Patterns & Design Principles
• Modular MVC-style separation: Blueprints = Controllers; Models = ORM; Jinja2 Templates + static = Views
• Service layer for cross-cutting concerns (image optimization, scheduling, encryption)
• Configuration-driven model management and subscription system
• Secure design: role-based access, rate limiting, CSRF, Fernet encryption for API keys
Technologies and Frameworks to Annotate
• Flask, SQLAlchemy, Alembic, APScheduler, Cryptography (Fernet)
• Tailwind CSS, DaisyUI, Fabric.js, GSAP, Vanilla ES6 modules
• External APIs: OpenAI, Anthropic, Google Gemini, Groq, FAL
• Email: SMTP / Amazon SES; OAuth: Google
Final Advice
• Every module group (blueprints, services, models) without over-splitting trivial files
• How credit resets and training tasks run asynchronously
• Admin panel under Backend but highlight its management of API keys, models, and subscriptions
• Review the doc/README to ensure no major component is missing (e.g., server install scripts, subscription setup script)