{"id":28243915,"url":"https://github.com/uditmahato/kathasajha","last_synced_at":"2026-01-24T05:33:05.619Z","repository":{"id":291915203,"uuid":"979141108","full_name":"uditmahato/KathaSajha","owner":"uditmahato","description":"KathaSajha (कथा साझा) is a Flask-based web application that generates illustrated children's stories from user prompts. ","archived":false,"fork":false,"pushed_at":"2025-05-09T17:55:13.000Z","size":43,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-12T05:40:40.706Z","etag":null,"topics":["ai","aiproject","gemini-api","storybook","storygenerator"],"latest_commit_sha":null,"homepage":"https://kathasajha.onrender.com","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uditmahato.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-05-07T04:06:05.000Z","updated_at":"2025-05-17T07:22:21.000Z","dependencies_parsed_at":"2025-06-12T05:42:04.092Z","dependency_job_id":null,"html_url":"https://github.com/uditmahato/KathaSajha","commit_stats":null,"previous_names":["uditmahato/kathasajha"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/uditmahato/KathaSajha","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uditmahato%2FKathaSajha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uditmahato%2FKathaSajha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uditmahato%2FKathaSajha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uditmahato%2FKathaSajha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uditmahato","download_url":"https://codeload.github.com/uditmahato/KathaSajha/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uditmahato%2FKathaSajha/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28713388,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-24T05:28:26.568Z","status":"ssl_error","status_checked_at":"2026-01-24T05:28:10.840Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","aiproject","gemini-api","storybook","storygenerator"],"created_at":"2025-05-19T07:08:08.767Z","updated_at":"2026-01-24T05:33:05.603Z","avatar_url":"https://github.com/uditmahato.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"# KathaSajha - AI Story Generator\n\nKathaSajha (कथा साझा) is a Flask-based web application that generates illustrated children's stories from user prompts. Users input a story idea, and the app creates a multi-paragraph tale with AI-generated images, downloadable as a PDF. The frontend features a parchment-themed UI with Tailwind CSS, custom fonts, and client-side PDF generation, while the Flask backend handles story and image generation.\n\n## Features\n\n- **Story Generation**: Enter a prompt to generate a unique story with multiple paragraphs.\n- **Illustrations**: Each paragraph is paired with an AI-generated image (or a default image if generation fails).\n- **PDF Download**: Export stories and images as a formatted PDF using `html2pdf.js`.\n- **Responsive Design**: Mobile-friendly layout with a vintage book aesthetic.\n- **Sample Prompt**: Pre-fill with an example prompt (\"Leo the Lion and Lily the Lost Girl\") for testing.\n- **Custom Styling**: Uses Tailwind CSS and custom CSS for spinner, image-text layout, and PDF formatting.\n\n## Project Structure\n\n```\nkathasajha/\n├── app.py                # Flask backend with /generate endpoint\n├── templates/\n│   └── index.html        # Frontend HTML with JS and Tailwind CSS\n├── static/\n│   └── css/\n│       └── styles.css    # Custom CSS for spinner, story layout, and print styles\n├── .env                  # Environment variables (e.g., AI API keys)\n├── requirements.txt      # Python dependencies\n└── README.md             # Project documentation\n```\n\n## Setup\n\n### Prerequisites\n\n- **Python 3.8+**: For running the Flask backend.\n- **Node.js**: Optional, for local development with tools like `http-server`.\n- **Web Browser**: Chrome, Firefox, or Safari recommended.\n- **Internet Connection**: For CDN dependencies (Tailwind, Font Awesome, etc.) and AI API calls.\n\n### Installation\n\n1. **Clone the Repository**:\n   ```bash\n   git clone \u003crepository-url\u003e\n   cd kathasajha\n   ```\n\n2. **Set Up a Virtual Environment**:\n   ```bash\n   python -m venv venv\n   source venv/bin/activate  # On Windows: venv\\Scripts\\activate\n   ```\n\n3. **Install Dependencies**:\n   ```bash\n   pip install -r requirements.txt\n   ```\n   Example `requirements.txt`:\n   ```\n   flask==2.3.3\n   python-dotenv==1.0.0\n   requests==2.31.0  # For AI API calls, adjust based on app.py\n   ```\n\n4. **Create `.env`**:\n   - Create a `.env` file in the project root.\n   - Add API keys for AI services  **Required** AI services (e.g., OpenAI, DALL·E, or equivalent).\n   Example `.env`:\n   ```\n   FLASK_ENV=development\n   OPENAI_API_KEY=your_openai_key\n   IMAGE_API_KEY=your_image_gen_key\n   ```\n\n5. **Run the Flask App**:\n   ```bash\n   flask run\n   ```\n   - Access the app at `http://localhost:5000`.\n\n6. **Frontend Dependencies** (loaded via CDN in `index.html`):\n   - Tailwind CSS: `https://cdn.tailwindcss.com`\n   - Font Awesome: `https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css`\n   - Google Fonts: Merriweather and Playfair Display\n   - html2pdf.js: `https://cdnjs.cloudflare.com/ajax/libs/html2pdf.js/0.10.1/html2pdf.bundle.min.js`\n\n## Usage\n\n1. **Open the App**:\n   - Navigate to `http://localhost:5000` in your browser.\n\n2. **Enter a Prompt**:\n   - In the \"Your Story Idea\" textarea, enter a story idea (e.g., \"Leo the Lion and Lily the Lost Girl\").\n   - Click \"Show Example\" to load a sample prompt.\n\n3. **Generate Story**:\n   - Click \"Generate Story\" to send the prompt to the `/generate` endpoint.\n   - A loading spinner appears while the story and images are generated.\n\n4. **View and Download**:\n   - The generated story appears with each paragraph paired with an image.\n   - Click \"Save Story\" to download a PDF.\n\n## Technical Details\n\n### Backend (`app.py`)\n\n- **Flask App**:\n  - Handles the `/generate` POST endpoint, accepting `{ prompt: \"story idea\" }`.\n  - Uses AI services to generate story text and images.\n  - Returns JSON:\n    ```json\n    {\n      \"title\": \"Story Title\",\n      \"story\": \"Paragraph 1\\n\\nParagraph 2\\n\\n...\",\n      \"images\": [\"base64_image_1\", \"base64_image_2\", ...]\n    }\n    ```\n- **Assumption**: Integrates with AI APIs (e.g., OpenAI for text, DALL·E for images).\n\n### Frontend (`templates/index.html`)\n\n- **HTML Structure**:\n  - Header with branding.\n  - Main section with story generator form and story display.\n  - Footer with social media links and copyright.\n- **JavaScript**:\n  - Handles form submission, API calls, and story rendering.\n  - Uses `fetch` to call `/generate`.\n  - Renders paragraphs with images, using a default image for missing/invalid images.\n  - Generates PDFs with `html2pdf.js` (letter-sized, portrait).\n- **Image Handling**:\n  - Each paragraph has an image from the `images` array.\n  - Uses a default base64 image if an image is missing or invalid (e.g., `BLOCKED:` or `ERROR:`).\n- **Styling**:\n  - Tailwind CSS with custom colors (`parchment`, `sepia`, `oldgold`), fonts, and shadows.\n  - Custom CSS in `static/css/styles.css` for spinner, image-text layout, and print styles.\n\n### CSS (`static/css/styles.css`)\n\n- Defines styles for:\n  - Loading spinner animation.\n  - Story paragraph sections (image above text, centered).\n  - Image containers (max-width 350px, shadows).\n  - Print media rules to prevent page breaks within image-text pairs.\n\n### Known Issues and Fixes\n\n- **Issue**: Some PDF paragraphs had \"No image available\" placeholders.\n  - **Fix**: Updated `index.html` to use a default base64 image for missing/invalid images, ensuring every paragraph has an image.\n- **Recommendation**: Update `app.py` to generate images for all paragraphs to avoid relying on the default image.\n\n### Default Image\n\n- Current default: 1x1 grey pixel for demonstration:\n  ```javascript\n  const defaultImage = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAC9gF0Y3X9NgAAAABJRU5ErkJggg==';\n  ```\n- **Action**: Replace with a base64-encoded jungle-themed image. Use an online tool or Python script to convert an image to base64.\n\n## Development Notes\n\n- **Server-Side**:\n  - Ensure `app.py` generates images for all paragraphs.\n  - Handle AI API errors (e.g., rate limits, content violations) with retries or fallback images.\n- **Testing**:\n  - Test with prompts like \"Leo the Lion and Lily the Lost Girl\".\n  - Verify PDF output for consistent images and page breaks.\n- **Improvements**:\n  - Add a \"Regenerate Images\" button.\n  - Show progress in the loading indicator (e.g., \"Generating image 3 of 5\").\n  - Validate prompt length/content client-side.\n\n## Contributing\n\n1. Fork the repository.\n2. Create a feature branch (`git checkout -b feature/your-feature`).\n3. Commit changes (`git commit -m \"Add your feature\"`).\n4. Push to the branch (`git push origin feature/your-feature`).\n5. Open a pull request.\n\n## License\n\n© 2025 KathaSajha. All rights reserved.\n\n## Contact\n\nFor questions or feedback, create an issue in the repository.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuditmahato%2Fkathasajha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuditmahato%2Fkathasajha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuditmahato%2Fkathasajha/lists"}