Serenity Scribe is a digital platform that allows users to record their daily moods and journal entries. It aims to help users track their emotional well-being over time, offering insights and affirmations to encourage positive mental health practices. This document outlines the technical design and architecture of the Mood Journal website, including the frontend and backend components, database design, and third-party integrations.
Technology Stack: The frontend will be developed using React for building the user interface and Bootstrap CSS for styling.
Pages and Components:
- Registration/Login Page: Allows users to register an account or log in to the platform.
- Journal Page: A form for users to write and submit their daily journal entries and mood ratings.
- Past Journals Page: Displays a list of past journal entries that users can view and edit.
- Analytics Page: Shows graphs and analytics on past moods and journal entries.
- Affirmations: After submitting a journal entry, users receive a daily affirmation via a third-party API.
Technology Stack: The backend server will be implemented using Flask, with SQLAlchemy for ORM.
API Endpoints:
- User Authentication: Endpoints for user registration and login.
- Journal Management: Endpoints to create, read, update, and delete journal entries.
- Analytics: Endpoints to provide analytics based on user journal entries.
- Affirmations: An endpoint to fetch daily affirmations from a third-party API.
Technology: SQLite
Schema:
- Users: Stores user information, including username, email, and hashed passwords.
- JournalEntries: Stores journal entries, including content, mood rating, and timestamps.
- Daily Affirmations API: A free API to fetch daily affirmations for users upon journal entry submission.
- Set up the Flask application and configure SQLAlchemy.
- Implement database models for users and journal entries.
- Develop the API endpoints for user authentication and journal management.
- Integrate the third-party API for daily affirmations.
- Initialize the React application.
- Develop the UI components for the registration/login, journal, past journals, and analytics pages.
- Implement state management for handling user sessions and journal data.
- Connect the frontend to the backend via API calls.
- Perform unit and integration testing on both the frontend and backend.
- Deploy the backend to a cloud service provider (e.g., Heroku, AWS).
- Deploy the frontend to a static site hosting service (e.g., Vercel, Netlify).
- Conduct end-to-end testing to ensure system integrity and user experience.
- flask import-moods "/src/data/moodData.json"
If you use Github Codespaces (recommended) or Gitpod this template will already come with Python, Node and the Posgres Database installed. If you are working locally make sure to install Python 3.10, Node
It is recomended to install the backend first, make sure you have Python 3.8, Pipenv and a database engine (Posgress recomended)
- Install the python packages:
$ pipenv install
- Create a .env file based on the .env.example:
$ cp .env.example .env
- Install your database engine and create your database, depending on your database you have to create a DATABASE_URL variable with one of the possible values, make sure you replace the valudes with your database information:
Engine | DATABASE_URL |
---|---|
SQLite | sqlite:////test.db |
MySQL | mysql://username:password@localhost:port/example |
Postgress | postgres://username:password@localhost:5432/example |
- Migrate the migrations:
$ pipenv run migrate
(skip if you have not made changes to the models on the./src/api/models.py
) - Run the migrations:
$ pipenv run upgrade
- Run the application:
$ pipenv run start
Note: Codespaces users can connect to psql by typing:
psql -h localhost -U gitpod example
You are also able to undo a migration by running
$ pipenv run downgrade
To insert test users in the database execute the following command:
$ flask insert-test-users 5
And you will see the following message:
Creating test users
[email protected] created.
[email protected] created.
[email protected] created.
[email protected] created.
[email protected] created.
Users created successfully!
Every Github codespace environment will have its own database, so if you're working with more people eveyone will have a different database and different records inside it. This data will be lost, so don't spend too much time manually creating records for testing, instead, you can automate adding records to your database by editing commands.py
file inside /src/api
folder. Edit line 32 function insert_test_data
to insert the data according to your model (use the function insert_test_users
above as an example). Then, all you need to do is run pipenv run insert-test-data
.
- Make sure you are using node version 14+ and that you have already successfully installed and runned the backend.
- Install the packages:
$ npm install
- Start coding! start the webpack dev server
$ npm run start
This boilerplate it's 100% read to deploy with Render.com and Heroku in a matter of minutes. Please read the official documentation about it.