{"id":25616671,"url":"https://github.com/unqdlphn/web-app-starter","last_synced_at":"2026-04-15T14:02:52.115Z","repository":{"id":278635328,"uuid":"936276853","full_name":"unqdlphn/web-app-starter","owner":"unqdlphn","description":"A standardized process for initiating new Python web application projects using macOS, Flask, Streamlit and  SQLite3 as the foundation. It aims to ensure consistency, best practices, and efficient web app building.","archived":false,"fork":false,"pushed_at":"2025-02-28T14:55:02.000Z","size":11,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-28T20:22:40.058Z","etag":null,"topics":["flask","macos","python","sqlite","streamlit"],"latest_commit_sha":null,"homepage":"","language":"Python","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/unqdlphn.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}},"created_at":"2025-02-20T20:19:38.000Z","updated_at":"2025-02-28T14:55:06.000Z","dependencies_parsed_at":"2025-02-20T21:25:18.307Z","dependency_job_id":"bc17a3d3-9e07-4bce-8df6-45095d0c4d03","html_url":"https://github.com/unqdlphn/web-app-starter","commit_stats":null,"previous_names":["unqdlphn/web-app-starter"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/unqdlphn/web-app-starter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unqdlphn%2Fweb-app-starter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unqdlphn%2Fweb-app-starter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unqdlphn%2Fweb-app-starter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unqdlphn%2Fweb-app-starter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unqdlphn","download_url":"https://codeload.github.com/unqdlphn/web-app-starter/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unqdlphn%2Fweb-app-starter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279023302,"owners_count":26087480,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["flask","macos","python","sqlite","streamlit"],"created_at":"2025-02-22T04:17:57.747Z","updated_at":"2025-10-14T23:15:55.696Z","avatar_url":"https://github.com/unqdlphn.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Starting a Python Web Application Project - Standard Operating Procedure (SOP)\n\nThis Standard Operating Procedure (SOP) defines the standardized process for initiating new Python web application projects. It aims to ensure **consistency, best practices, and efficient project setup** across all development efforts using the specified technology stack. Adherence to this SOP will **facilitate collaboration, simplify onboarding of new developers, and improve the overall quality and maintainability of web applications**. This SOP covers project initialization, dependency management, database setup, basic application structure, version control, and provides guidance for development workflow. It serves as a foundation for building robust and scalable web applications.\n\n## 1. Technology Stack:\n\n*   **Operating System:** macOS (specifically tested on 15.3.1, but generally applicable to other macOS versions)\n*   **Hardware:** Mac Mini M1 (ARM-based architecture)\n*   **Integrated Development Environment (IDE):** Visual Studio Code (VS Code)\n*   **Programming Language:** Python 3 (managed with Pyenv)\n*   **Virtual Environment:** `venv` (built-in Python module)\n*   **Web Frameworks:**\n    *   ***Flask*** (for traditional web applications)\n    *   ***Streamlit*** (for data visualization-focused web applications)\n*   **Version Control:** Git (managed on GitHub)\n*   **Database:** SQLite3\n\n## 2. Project Setup:\n\n2.1. **Create Project Directory:**\n\nReplace with the desired name for your project (e.g., my_webapp).\n\n```bash\nmkdir \u003cproject_name\u003e\ncd \u003cproject_name\u003e\n```\n\n2.2. **Initialize Git Repository:**\n\n```bash\ngit init\n```\n\nThis initializes a new Git repository in the project directory.\n\n2.3. **Create Virtual Environment:**\n\n```bash\npython3 -m venv .venv\n```\n\nThis creates a virtual environment named `.venv` in the project directory.\n\n2.4. **Activate Virtual Environment:**\n\n```bash\nsource .venv/bin/activate\n```\n\nThis activates the newly created virtual environment. Your terminal prompt should now be prefixed with `(.venv)`.\n\n2.5. **Install Project Dependencies:**\n\nCreate a `requirements.txt` file in the project root. This file will list all project dependencies. Initially, it will likely contain:\n\n```\nFlask\nStreamlit\n```\n\nInstall the dependencies:\n\n```bash\npip install -r requirements.txt\n```\n\n2.6. **Create Main Application File:**\n\nCreate a file named `app.py` for Flask and `streamlit_app.py` for Streamlit in the project root. This will be the main entry point for the chosen web application framework.\n\n```bash\ntouch app.py streamlit_app.py\n```\n\n## 3. Project Structure (Example):\n\n```\n/\n├── .git/                      # Repository (Automatically created when ***Step 2.2*** is successful)\n├── .venv/                     # Virtual environment (Automatically created when ***Step 2.3*** is successful)\n├── app.py                     # Main application file - Flask\n├── streamlit_app.py           # Main application file - Streamlit\n├── requirements.txt           # Project dependencies\n├── static/                    # Static files (CSS, JavaScript, images) - Flask\n├── all_pages/                 # For Streamlit\n├── assets/                    # Static files (images, icons) - Streamlit \n├── templates/                 # HTML templates - For Flask\n├── data/                      # Data files (SQLite database, CSVs, etc.)\n└── __init__.py                # Makes the directory a Python package (if needed)\n```\n\n## 4. Database Setup (SQLite3):\n\n4.1. **Create Database File:**\n\n***This template includes a blank database with a generic table name `table1`. You can change the table name as needed for your specific project or delete it and recreate your own.***\n\nCreate a file named `database.db` (or similar) inside the `data` directory. This will be your SQLite database file. You can create it by simply running the sqlite3 command-line tool. You must add something to the database to force it to actually save. See \n\n```bash\nsqlite3 data/database.db\n```\n\nThe above command should return a prompt that looks like this:\n\nsqlite\u003e\n\n***This is example schema. Add your own schema if/when it is determined.***\n\n```sqlite3\nCREATE TABLE table1 (\n    id INTEGER PRIMARY KEY,\n    name TEXT NOT NULL,\n    value TEXT NOT NULL\n);\n.exit\n```\n\n4.2. **Database Interactions:**\n\nUse the `sqlite3` Python library to interact with the database within your `app.py` or `streamlit_app.py` files.\n\n## 5. Flask Application Development (Example `app.py`):\n\n```python\nfrom flask import Flask, render_template # Import necessary modules\nimport sqlite3\n\napp = Flask(__name__)\n\ndef get_db_connection():\n    conn = sqlite3.connect('data/database.db')\n    conn.row_factory = sqlite3.Row  # To access columns by name\n    return conn\n\n@app.route('/')\ndef index():\n    conn = get_db_connection()\n    # Example: Fetch data from the database\n    # ...\n    conn.close()\n    return render_template('index.html')  # Example: Render an HTML template\n\nif __name__ == '__main__':\n    app.run(debug=True)  # Set debug=False in production\n```\n\n## 6. Streamlit Application Development (Example `streamlit_app.py`):\n\n```python\nimport streamlit as st\nimport sqlite3\nimport pandas as pd\n\nst.title(\"My Streamlit App\")\n\ndef get_data():\n    conn = sqlite3.connect('data/database.db')\n    # Example: Fetch data using pandas\n    df = pd.read_sql_query(\"SELECT * FROM your_table\", conn)\n    conn.close()\n    return df\n\ndf = get_data()\nst.dataframe(df)  # Display the dataframe\n# ... other Streamlit elements\n```\n\n## 7. Version Control (Git \u0026 GitHub):\n\n7.1. **Create `.gitignore` file:**\n\nCreate a `.gitignore` file in the project root and add the following to exclude files that should not be committed to version control:\n\n```\n# Created by venv; see https://docs.python.org/3/library/venv.html*\n.venv/\n# Created by virtualenv; see https://virtualenv.pypa.io/en/latest/user_guide.html\nenv/\nvenv/\n# Created by pyenv; see https://github.com/pyenv/pyenv#installation\n.pyenv/\n# Created by pipenv; see https://pipenv.pypa.io/en/latest/\nPipfile\nPipfile.lock\n# Created by poetry; see https://python-poetry.org/docs/\npoetry.lock\n# Created by pip-tools; see https://pip-tools.readthedocs.io/en/latest/requirements.html\nrequirements.txt\n\n# Python cache files\n__pycache__/\n*.py[cod]\n*$py.class\n\n# Distribution / packaging\ndist/\nbuild/\n*.egg-info/\n\n# Unit test / coverage reports\nhtmlcov/\n.tox/\n.nox/\n.coverage\n.coverage.*\n.cache\nnosetests.xml\ncoverage.xml\n*.cover\n*.py,cover\n.hypothesis/\n.pytest_cache/\ncover/\n\n# Jupyter Notebook\n.ipynb_checkpoints\n\n# IPython\nprofile_default/\nipython_config.py\n\n# Environments\n.env\n.venv\nenv/\nvenv/\nENV/\nenv.bak/\nvenv.bak/\n\n# Documentation\ndocs/_build/\nsite/\n\n# mypy\n.mypy_cache/\n.dmypy.json\ndmypy.json\n\n# Pyre type checker\n.pyre/\n\n# IDE specific files\n.idea/\n.vscode/\n*.swp\n*.swo\n.DS_Store\n```\n\n7.2. **Commit Changes:**\n\n```bash\ngit add .\ngit commit -m \"Initial commit\"\n```\n\n7.3. **Create GitHub Repository:**\n\nCreate a new repository on GitHub.\n\n7.4. **Push to GitHub:**\n\n```bash\ngit remote add origin \u003crepository_url\u003e\ngit branch -M main\ngit push -u origin main\n```\n\n## 8. Development Workflow:\n\n*   Make changes to your code.\n*   Test your application thoroughly.\n*   Commit your changes regularly with descriptive commit messages.\n*   Push your changes to GitHub.\n\n## 9. Pyenv Usage (Python Version Management):\n\nPyenv is crucial for managing multiple Python versions on your system. Before starting a new project, follow these steps:\n\n9.1.  **Install Pyenv (if not already installed):** \n\n1. Install Homebrew if not already installed:  \n\n```bash\n/bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\"\n```\n\n2. Install pyenv using Homebrew:\n\n```bash\nbrew update  \nbrew install pyenv\n```\n\n3. Add pyenv to your shell. For example, with Zsh, add the following to ~/.zshrc:\n\n***This is important to get correct. You may need to modify based on your system.***\n\n```bash\nexport PYENV_ROOT=\"$HOME/.pyenv\"  \nexport PATH=\"$PYENV_ROOT/bin:$PATH\"  \neval \"$(pyenv init --path)\"\n```\n\n4. Restart or reload your shell to apply the changes:\n\n```bash\nsource ~/.zshrc\n```\n\n9.2.  **Set the Python version for the project:**\n\n```bash\npyenv local \u003cpython_version\u003e # e.g., pyenv local 3.9.13\n```\n\nThis creates a `.python-version` file in your project directory, automatically setting the Python version when you're in the project.\n\n9.3.  **Verify the Python version:**\n\n```bash\npython --version\n```\n\nThis should show the Python version you set with Pyenv.\n\n## 10. VS Code Integration:\n\n10.1.  **Python Extension:** \n\nInstall the official Python extension for VS Code. This provides support for code completion, linting, debugging, and more.\n\n10.2.  **Select Interpreter:** \n\nIn VS Code, use the \"Python: Select Interpreter\" command to choose the Python interpreter from your `.venv` environment. This ensures VS Code uses the correct dependencies.\n\n## 11. Streamlit Specific Notes:\n\n11.1.  **Running Streamlit Apps:** \n\nUse the command `streamlit run app.py` to start your Streamlit application.\n\n11.2.  **Streamlit Documentation:** \n\nRefer to the official Streamlit documentation for detailed information on available components and functionalities. https://docs.streamlit.io/\n\n## 12. Flask Specific Notes:\n\n12.1.  **Running Flask Apps:** \n\nUse the command `flask run` (after setting the `FLASK_APP` environment variable to your `app.py` file or using Flask's automatic detection if named `app.py`) to start your Flask application, or `python app.py` if you have the `app.run()` call in your main file.\n\n12.2.  **Flask Documentation:** \n\nRefer to the official Flask documentation for detailed information.\n\n## 13. SQLite3 Best Practices:\n\n13.1.  **Connection Management:** \n\nEnsure you properly close database connections after use to prevent resource leaks. The examples provided in this SOP demonstrate this.\n\n13.2.  **Data Modeling:** \n\nConsider using a database migration tool (like Alembic) for more complex projects to manage database schema changes effectively.\n\n## 14. Deployment\n\nDeployment strategies will depend on your chosen platform (e.g., Heroku, AWS, PythonAnywhere). This SOP focuses on project setup.\n\n***This SOP provides a comprehensive starting point for your Python web application project. Remember to adapt it to your specific needs and project requirements. Always consult the official documentation for Flask, Streamlit, and other tools you are using for the most up-to-date information.***\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funqdlphn%2Fweb-app-starter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funqdlphn%2Fweb-app-starter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funqdlphn%2Fweb-app-starter/lists"}