An AI-powered copilot that automates the generation of production-ready React components directly from Figma design data. The project demonstrates a modern microservice architecture featuring interchangeable backend implementations (FastAPI and Spring Boot), a Next.js frontend, local LLM inference through Ollama, and PostgreSQL storage hosted on Supabase.
Designed as both a learning platform and an enterprise-style architecture showcase, the project emphasizes scalability, maintainability, and clean separation of responsibilities.
- Overview
- System Architecture
- Core Components
- Features
- API Architecture
- Logical Workflow
- Database
- Environment Variables
- Local Installation
- Docker Deployment
- Networking Notes
The application transforms Figma layouts into React (.tsx) components using local Large Language Models running through Ollama.
The architecture intentionally separates concerns into three independent services:
- Next.js frontend for the user interface.
- FastAPI backend optimized for asynchronous AI inference.
- Spring Boot backend focused on enterprise-grade persistence and structured business logic.
Both backend implementations expose the exact same REST API contract, allowing the frontend to switch between them without any code changes.
┌────────────────────────────────────────┐
│ Main Workspace Interface │
│ (Next.js) │
└──────────────────┬─────────────────────┘
│
┌───────────┴───────────┐
│ Ollama Engine │
│ qwen2.5-coder:7b │
└───────────┬───────────┘
│
/api/* Internal Rewrites
│
┌────────────────────────┴────────────────────────┐
▼ ▼
┌───────────────────────┐ ┌───────────────────────┐
│ High-Performance AI │ │ Enterprise Data Layer │
│ Proxy (FastAPI) │ │ (Spring Boot) │
└───────────┬───────────┘ └───────────┬───────────┘
│ │
Async SQLAlchemy JDBC / Spring Data
│ │
▼ ▼
┌───────────────────────┐ ┌───────────────────────┐
│ Supabase Pooler │ │ Supabase PostgreSQL │
│ (Port 6543) │ │ (Port 5432) │
└───────────────────────┘ └───────────────────────┘
The frontend acts as the application's command center.
Responsibilities include:
- Component generation interface
- Live preview panels
- Workspace management
- API proxy through Next.js rewrites
- Code visualization
- History browsing
Instead of communicating directly with backend servers, every request goes through:
/api/*
This abstraction completely hides backend URLs from the client, making backend swapping seamless.
The Python backend is optimized for AI workloads and asynchronous processing.
Main responsibilities:
- Prompt construction
- Ollama communication
- Async request handling
- Context management
- Streaming LLM responses
- Database persistence using SQLAlchemy Async
Technology stack:
- FastAPI
- SQLAlchemy Async
- asyncpg
- Pydantic
- Ollama API
The Java backend demonstrates an enterprise-oriented architecture.
Responsibilities include:
- Persistent workflow management
- Agent metadata
- Business logic
- Database management
- Analytics
- MCP-compatible architecture
Technology stack:
- Spring Boot
- Spring Data JPA
- Hibernate
- PostgreSQL
- Maven
Automatically converts Figma component layouts into production-ready React components.
Parses:
- Layout hierarchy
- Typography
- Colors
- Design tokens
- Spacing
- Component metadata
and generates clean .tsx React code.
Generated components are automatically stored inside PostgreSQL.
Each component includes:
- Name
- Source code
- Creation timestamp
- Metadata
Every execution is logged.
Tracked information includes:
- Execution duration
- Generated component
- Errors
- Model used
- Token statistics
The frontend can transparently switch between:
- FastAPI
- Spring Boot
without changing any frontend code.
Runs entirely locally using Ollama.
Advantages:
- No API costs
- Privacy
- Offline usage
- Faster iteration
Supports Supabase's transaction pooler while avoiding prepared statement conflicts.
Both backend implementations expose the exact same REST API.
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/generate |
Generate React code from Figma data |
| GET | /api/components |
List generated components |
| GET | /api/components/{id} |
Retrieve one component |
| DELETE | /api/components/{id} |
Delete a component |
| GET | /api/logs |
Retrieve execution logs |
| GET | /api/analytics/stats |
Aggregate project statistics |
Because both implementations respect the same API contract, the frontend never needs to know which backend is active.
flowchart TD
A[User submits Figma JSON] --> B[Next.js routes request to /api/generate]
B --> C{Active backend}
C -->|FastAPI| D[Validate request, build prompt, stream from Ollama]
C -->|Spring Boot| E[Map JSON to DTOs, build prompt, call Ollama]
D --> F[Generate React component]
E --> F
F --> G[Persist component in PostgreSQL]
G --> H[Store execution logs]
H --> I[Frontend updates code view and history]
-
User Submission
The user sends a Figma JSON payload. -
Next.js Routing
The request is forwarded to/api/generate. -
Active Backend
The selected backend handles validation, prompt building, and Ollama communication. -
Ollama
Generates the React component code. -
Persistence
The generated component is saved to PostgreSQL. -
Logging
Execution metrics are recorded for auditing. -
Frontend
The UI displays the generated code and updates history.
The application stores information inside Supabase PostgreSQL.
Stores generated React components.
Suggested fields:
| Column | Type |
|---|---|
| id | UUID / SERIAL |
| name | VARCHAR |
| code | TEXT |
| created_at | TIMESTAMP |
Stores execution telemetry.
Typical information:
- Model name
- Generation duration
- Errors
- Token usage
- Timestamp
Each backend follows the configuration conventions of its respective framework.
The FastAPI backend reads its configuration from a standard .env file located in the backend root directory.
This includes:
- Database connection URL
- Ollama host
- LLM model name
- API keys
- Service ports
- Other environment-specific variables
Example:
DATABASE_URL=...
OLLAMA_HOST=http://host.docker.internal:11434
MODEL_NAME=qwen2.5-coder:7b
OPENAI_API_KEY=YOUR_API_KEY
PORT=8080The Spring Boot backend uses Spring Profiles.
For local development, configuration is stored in:
backend-springboot/src/main/resources/application-local.yml
Typical settings include:
- PostgreSQL credentials
- External API keys
- Service URLs
- JPA/Hibernate configuration
- Logging settings
- Spring profile configuration
The application is started using the local profile:
./mvnw spring-boot:run "-Dspring-boot.run.profiles=local"This separation keeps sensitive credentials outside the codebase while allowing different configurations for local development, testing, and production deployments.
Expose the local daemon.
Download and run the desired model with :
$env:OLLAMA_HOST="127.0.0.1:11434"; ollama run qwen2.5-coder:7bcd backend-fastapi
uvicorn app.main:app --reload --port 8000cd backend-springboot
./mvnw spring-boot:run "-Dspring-boot.run.profiles=local"cd frontend
npm install
npm run devOpen:
http://localhost:3000
The project supports multiple Docker Compose profiles.
docker compose up --profile fastapidocker compose up --profile springbootDocker networking automatically resolves service names, allowing internal communication without exposing container IPs.
Containers access the local Ollama daemon using:
http://host.docker.internal:11434
instead of:
localhost
or
127.0.0.1
When using Docker, the project connects through Supabase's connection pooler:
aws-0-[region].pooler.supabase.com:6543
This avoids networking issues while supporting high concurrency.
- Next.js
- React
- TypeScript
- FastAPI
- SQLAlchemy Async
- asyncpg
- Pydantic
- Spring Boot
- Spring Data JPA
- Hibernate
- Maven
- Ollama
- qwen2.5-coder
- Local LLM inference
- PostgreSQL
- Supabase
- Docker
- Docker Compose
- Enterprise-inspired microservice architecture
- Interchangeable backend implementations
- Local AI inference with Ollama
- PostgreSQL persistence using Supabase
- Shared REST API contract across services
- Docker-based deployment
- Modern asynchronous Python backend
- Enterprise Java backend
- Production-oriented networking and connection pooling
- Full-stack TypeScript + Python + Java architecture