A journaling application to track things you're grateful for. This full-stack app uses an Express API, PostgreSQL for data storage, and a simple HTML/JavaScript front end. Users can create, view, update, and delete their gratitude entries. The public view displays only entries from the current device session, while a secret page (protected by a password) shows all entries and allows deletion. Additionally, a shared word cloud built with D3 visualizes the categories returned by OpenAI.
- Overview
- Features
- Tech Stack
- Installation & Deployment
- Environment Variables
- Usage
- Development
- Future Enhancements
- License
The Gratitude App is designed to help users document daily moments of gratitude. Each entry includes text content and a category automatically determined by OpenAI’s API. The app is designed for deployment on Render.com, with testing and deployment managed on that platform. Public users only see entries from their current session, while an admin/secret view (protected by a password) displays all entries along with a deletion option and a shared word cloud of categories.
-
Create Entries:
Users can add new gratitude entries using a simple form. Each entry is automatically categorized via the OpenAI API. -
Per-Device Public View:
The public page displays only the entries created during the current session (per device). -
Secret Page:
A password-protected secret page lets administrators view all entries and delete any entry. -
Shared Word Cloud:
A word cloud built with D3 displays a summary of categories (from all entries) shared by users (excluding uncategorized items). -
Automatic Table Initialization:
The PostgreSQL table (entries) is created programmatically if it doesn't exist, with columns for content, category, and session ID. -
Responsive UI:
A clean, responsive HTML/JavaScript front end is provided.
- Backend:
- Frontend:
- Deployment:
- Render.com for hosting the application
Since all testing and deployment are done on Render, follow these steps to deploy:
-
Clone the Repository:
git clone https://github.com/your-username/gratitude-app.git cd gratitude-app -
Set Environment Variables on Render:
- In your Render dashboard, add the
DATABASE_URLenvironment variable with your PostgreSQL connection string. - Add the
OPENAI_API_KEYenvironment variable with your OpenAI API key. - Add the
LIST_PASSWORDenvironment variable for the secret page (for example,mySecretPassword). - (Optional) You can provide a
SESSION_SECRET; if not provided, one will be auto-generated per device.
- In your Render dashboard, add the
-
Deploy on Render:
-
Push your repository to GitHub.
-
Create a new Web Service on Render and connect your GitHub repository.
-
Set the Start Command to:
node index.js
-
Render will build and deploy your application.
-
-
DATABASE_URL:
Your PostgreSQL connection string. This must be set on Render for the application to connect to the database. -
OPENAI_API_KEY:
Your OpenAI API key used for categorizing entries. -
LIST_PASSWORD:
The password required to access the secret page which displays all entries and enables deletion. -
SESSION_SECRET: (Optional)
The secret used byexpress-sessionto generate sessions. If not provided, a random secret is generated at server startup.
Once deployed, the app works as follows:
-
Entry Form & Public Entries:
Accessing the root URL (e.g.,https://your-app.onrender.com/) displays the Gratitude Journal UI. Users can add entries, which are visible only on that device/session. -
Word Cloud:
A shared word cloud (built with D3) below the entries shows category frequencies from all entries (ignoring uncategorized).
- Secret Page:
Placesecret.htmlin the public folder. Access it viahttps://your-app.onrender.com/secret.html.
Enter the password (as set inLIST_PASSWORD) to view all entries and delete any entry.
-
GET /api/public-entries:
Returns entries created in the current session. -
GET /api/all-entries:
Returns all entries with a defined category (for the word cloud). -
GET /api/secret-entries?password=YOUR_PASSWORD:
Returns all entries if the password is correct. -
GET /api/entries/:id:
Retrieves a single entry by its ID. -
POST /api/entries:
Creates a new entry with automatic categorization. -
PUT /api/entries/:id:
Updates an existing entry (content only). -
DELETE /api/entries/:id:
Deletes an entry.
To develop or test locally:
-
Install dependencies:
npm install
-
Run the server locally (set the environment variable
DATABASE_URLlocally):node index.js
Note: The primary development workflow is via Render if you are not running a local JavaScript environment.
- Implement user authentication for personalized entries.
- Add sorting and filtering options on the front end.
- Enhance UI/UX with modern frameworks (e.g., React or Next.js).
- Integrate additional visualization tools.
- Use migration tools for managing database schema changes.
This project is licensed under the MIT License.