How parthsolanke/penman works
Project Overview & Main Components
• Penman is a full-stack handwriting generator app that delivers real-time handwriting effects using a custom Server-Sent Events (SSE) implementation. The project is split into two major parts – a frontend and a backend – each containerized via Docker.
• Frontend: A React/TypeScript single-page application (with Vite, Tailwind, etc.) that hosts pages like Playground and Cards. It manages user interactions, displays live handwriting updates, and provides export options.
• Backend: A Python-based API server handling requests, SSE streaming, and running the handwriting generation engine. It is composed of classic API endpoints (in app/routes.py) and the handwriting generation logic, including model inference and style management.
• Docker Infrastructure: Indicate that both the frontend and backend are containerized and orchestrated using docker-compose.
Analyzing the File Structure
• Under the top-level directories, two primary folders (frontend and backend) directly mirror the two layers of the application.
• The backend directory has a further split:
• The “app” folder (with models.py, routes.py, and utils.py) is where the API endpoints and utility functions reside.
• The “handwriting” folder is the engine core with submodules such as “models” (containing RNN and associated cells/operations), “data” (for loading handwriting and style data), and “utils” (like drawing and TensorFlow helper utilities). It also contains pre-trained model checkpoints and styles files.
• The frontend contains components, pages, contexts, APIs, and configuration files structured for building a modern web UI.
Relationships and Data Flow
• Users interact with the Frontend (browsers sending requests).
• The Frontend queries the Backend via standard HTTP requests or initiates an SSE connection for streaming handwriting generation.
• The Backend’s API layer processes incoming requests (via routes defined in app/routes.py) and, when generating handwriting, invokes the handwriting module.
• Within the handwriting module, data loaders fetch style and character/stroke files, while model inference (using RNN-based models) is performed with the TensorFlow-based components. The generated data is then pushed via SSE back to the frontend.
• The Docker environment (via docker-compose) orchestrates both containers and maps ports (frontend on port 3000 and backend API on port 8000).
Key Architectural Patterns & Technologies
• Separation of concerns (frontend vs. backend) and containerized deployment.
• Main technologies:
• Frontend: React, TypeScript, Vite, Tailwind.
• Backend: Python, TensorFlow (implied by the model checkpoint files and modules), and Docker.
• Infrastructure: Docker/Docker Compose for container orchestration.