MalikShehram's picture
Update app.py
c0c0dbb verified
import os
import gradio as gr
def generate_scaffold(tech_stack: str) -> str:
"""
Simulate a detailed step-by-step guide for setting up a project using the given tech stack.
The output includes installation instructions, a suggested project structure, and clickable markdown links
to the official documentation for each technology.
Parameters:
tech_stack (str): A comma-separated list of technologies (e.g., "React, Node.js, MongoDB")
Returns:
str: A markdown-formatted guide.
"""
tech_list = [tech.strip() for tech in tech_stack.split(",") if tech.strip()]
if not tech_list:
return "No tech stack provided. Please enter at least one technology."
guide = "## Project Setup Guide\n\n"
guide += "### Installation Instructions\n"
for idx, tech in enumerate(tech_list, start=1):
# Create a clickable markdown link that searches for the official documentation.
doc_link = f"[Official {tech} Documentation](https://www.google.com/search?q={tech}+official)"
guide += f"{idx}. **Install {tech}:**\n - Follow instructions here: {doc_link}\n\n"
guide += "### Recommended Project Structure\n"
guide += "- `src/` : Contains your source code\n"
guide += "- `public/` : Contains public assets (e.g., images, static files)\n"
guide += "- `package.json` or `requirements.txt` : Project configuration and dependencies\n"
guide += "- `README.md` : Project documentation\n\n"
guide += "### Setup Steps\n"
guide += "1. Install the above technologies using the provided commands/instructions.\n"
guide += "2. Create your project structure as suggested.\n"
guide += "3. Initialize your project (e.g., using `npm init` for Node.js projects or creating a virtual environment for Python projects).\n\n"
guide += "---\n"
guide += "*Thank you for using our Automated Tech Stack Setup Assistant! Feel free to try another tech stack or provide feedback.*"
return guide
def gradio_interface(tech_stack_input: str) -> str:
"""Interface function to generate the project guide from the tech stack input."""
return generate_scaffold(tech_stack_input)
# Friendly welcome message and instructions.
title = "Welcome to the Automated Tech Stack Setup Assistant!"
description = (
"Hello there! This is your friendly assistant to help you quickly set up a development project. "
"Enter your desired tech stack below (e.g., **React, Node.js, MongoDB**) and get a step-by-step guide "
"with installation instructions, project structure recommendations, and clickable links to official documentation.\n\n"
"### How to Use:\n"
"1. Type your tech stack in the input box.\n"
"2. Click the **Submit** button.\n"
"3. View your detailed project setup guide in markdown format.\n"
"4. Click on any link to visit the official website for more information.\n\n"
"Enjoy your coding journey!"
)
# Build the Gradio interface with examples.
iface = gr.Interface(
fn=gradio_interface,
inputs=gr.Textbox(lines=2, placeholder="Enter tech stack (e.g., React, Node.js, MongoDB)"),
outputs="markdown",
title=title,
description=description,
examples=[["React, Node.js, MongoDB"], ["Next.js, Express, PostgreSQL"], ["Vue, Django, Redis"]]
)
if __name__ == "__main__":
iface.launch(share=True)