sg_project_template

Project Setup

Installing uv project manager

Ensure you have uv installed on your system. If not, install it using the following command:

curl -LsSf https://astral.sh/uv/install.sh | sh

Managing the Virtual Environment

Create the python3.10 .venv virtual environment with this command

uv venv --python 3.10.12

Activate the virtual environment.

# You can activate the virtual environment with the following command.
source .venv/bin/activate

# You can deactivate the virtual environment with the following command.
deactivate

Next time the project workstation is opened, these commands can be used to activate/deactivate the virtual environment.

Setting Up the Project Environment

Once uv is installed and environment is activated, use this to set up the project dependencies:

uv sync
# or
uv pip install -r pyproject.toml

Other Requirements

Put the secret tokens, keys, etc. in .env file in root directory. (Check the example in .env.example file)

Running the Application

Launch the application with:

python -m src.main

Full Structure

.
├── pyproject.toml               # All project details and python dependencies.
├── README.md                    # Project overview and instructions for use.
├── data                         # Directory for data-related files.
│   ├── docs                     # Documentation files related to data.
│   ├── images                   # Directory for storing image assets.
│   ├── ml_models                # Directory for storing LLMs and ML models.
│   └── processed                # Directory for processed data outputs.
├── docker                       # Docker-related configurations and scripts.
│   ├── x.Dockerfile             # Dockerfile for building the project's container for x.
│   ├── docker-build.sh          # Shell script to automate Docker builds.
│   └── docker-compose.yml       # Defining multi-container Docker applications.
└── src                          # Main source code directory.
    ├── application              # Contains high-level application logic.
    │   ├── utils.py             # Helper function for the app.
    │   └── x_services           # Service layer(s) of the application.
    ├── domain                   # Contains core business logic and domain models.
    │   └── models               # Directory for domain-specific data models.
    │       └── data_models.py   # Implementation of domain data models with data classes.
    ├── infra                    # Infrastructure code, particularly for database handling.
    │   └── database             # Database-related configurations and utilities.
    ├── main.py                  # Main entry point for the application.
    ├── presentation             # Presentation layer like APIs and UIs.
    │   ├── dependencies.py      # Dependencies for presentation layer. (api token checks..)
    │   ├── rest                 # API-related presentation logic.
    │   │   └── serve_api.py     # Code to serve the API, possibly using FastAPI or Flask.
    │   └── ui                   # UI-related presentation logic.
    │       ├── asset.py         # Css & Js functions needed for UI.
    │       └── gradio_ui.py     # UI Implementation