This is a FastAPI application for a journal help support buddy.
- Python 3.9+
- PostgreSQL
uv(Ultra-fast Python package installer and resolver)
-
Clone the repository:
git clone https://github.com/yourusername/supportbuddy.git cd supportbuddy/backend -
Install UV (if not already installed):
Windows:
powershell -c "irm https://astral.sh/uv/install.ps1 | iex"
macOS/Linux:
curl -LsSf https://astral.sh/uv/install.sh | sh -
Create virtual environment and install dependencies:
uv venv uv pip install -e .
Click to expand legacy pip instructions
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install the required packages:
pip install -r requirements.txt
Create a .env file in the root directory and add the following environment variables:
DB_NAME=your_db_name
DB_USER=your_db_user
DB_PASSWORD=your_db_password
DB_HOST=your_db_host
DATABASE_URL=your_database_url
MAILGUN_API_KEY=your_mailgun_key
MAILGUN_DOMAIN=your_mailgun_domain
GOOGLE_GENAI_API_KEY=your_google_ai_key# Using UV
uv run start-dev
# Or with make
make start-dev
# Legacy
uvicorn app:app --reload# Using UV
uv run start-server
# Or with make
make start
# Legacy
uvicorn app:app --host 0.0.0.0 --port 8000# Using UV
uv run run-serverless
# Or with make
make serverless
# Legacy
python serverless_runner.pyThe application will be available at `http://127.0.0.1:8000`.
-
Endpoint to create a journal entry:
POST /journal/
Request Body:
{ "content": "Today I had a great day!" } -
Endpoint to generate a motivational message:
POST /generate-message/
Request Body:
{ "content": "Today I had a great day!" }Response:
{ "message": "That's wonderful to hear! Keep up the positive energy." }
The application includes custom exception handling for validation errors. If the request body does not match the expected schema, a detailed error message will be returned.
The application uses parameterized queries to prevent SQL injection attacks. Always ensure that user inputs are properly sanitized and validated.
This project is licensed under the MIT License.