thingaha-web is a web application to make life easier for thingaha donation group monthly donation data tracking and workflows.
For project background and current goals for v1.0, please read the Wiki Home Page.
- Flask with python3
- PostgreSQL == 12.3
- You can set up backend using either Docker based setup or Native env setup using Anaconda. You only need to setup one of them.
-
Install Docker Engine from Docker Official Site
-
Setup docker containers
- cd into the
backend
directory and rundocker-compose up
. (Note: all the following commands assume we're inbackend
directory as working directory) - it should create
backend_web_1
container andbackend_db_1
containers. - you can check using
docker ps
command for 2 containers. - Then, optionally, seed database using the following command:
docker exec backend_web_1 /usr/bin/python3 ../src/db_seed.py
- You should be able to go to
http://localhost:5000/api/v1/users
and should see a json error message.
For backend developers, who want to use docker for backend development, please refer to the following commands:
- If there is any change in
requirements.txt
, we will need to rebuild the containers. To rebuild containers, we use:docker-compose build
command.
Troubleshooting with docker FAQ
- I need to delete the database and recreate it again. What do I do?
- Make sure you are in the
backend
directory and rundocker-compose up
if you haven't already. - Run
docker-compose stop web
to stop the web container to make sure there is no connection to the db. - Run
docker-compose exec db /bin/bash
to get into the shell of db container. - TO delete the db:
- Run
dropdb -U thingaha thingaha_dev
(Using default username thingaha and password thingaha here. Replace with your credentials if you happen to have overriden it.)
- Run
- Then, to recreate db:
- Run
createdb -U thingaha thingaha_dev
(Using default username thingaha and password thingaha here. Replace with your credentials if you happen to have overriden it.)
- Run
- After db is created, exit the db container shell using
exit
command and restart currently runningdocker-compose up
. - Once it's up and migrated, run the db seeding command back again into the backend_web_1 container.
docker-compose exec web /usr/bin/python3 ../src/db_seed.py
- Make sure you are in the
- cd into the
- Install anaconda from anaconda webpage
- Install pgadmin4 (optional)
- Install PostgreSQL database server. We use PostgreSQL Official Site to install it. But, please free to use any custom installation method.
- Create a database named
thingaha_dev
(You can give any name you want but you need to update the configuration files inbackend/conf
directory if you use a different database name.) - Update username and password in
backend/conf/config_dev.yaml
andbackend/conf/conf_test.yaml
files with the credentials you used to install the database.
- Create a database named
conda create -n <envname>
conda activate <envname>
pip install -r ~/thingaha/backend/requirements.txt
- DB migrate
create table and insert data to table
for linux, macOS -> go backend/bin and run -> ./db_migrate.sh
for windows -> go to backend\bin and run -> db_migrate.bat
#memo
postgres url be like [DB_TYPE]+[DB_CONNECTOR]://[USERNAME]:[PASSWORD]@[HOST]:[PORT]/[DB_NAME]
- DB Seeding
for linux, macOS -> go backend/bin and run -> ./db_seed.sh
for windows -> go to backend\bin and run -> db_seed.bat
#memo
Put all testing data to DB
- ERD Diagram for Thingaha Project
- Start the server
for linux, macOS -> go backend/bin and run -> ./start_app.sh
for windows -> go to backend\bin and run -> start_app.bat
- Start using API
- Default server port is 5000:
- All API required JWT token for access data
- Get the access token from login.
-- init user_email: moemoe@gmail.com
-- init user_pass: 123
-- login URL : =>
-- [POST] http://localhost:5000/api/v1/login
- API docs can be found in https://github.com/thingaha/thingaha-web/tree/master/backend/docs
- Start the test case
for linux, macOS -> go backend/bin and run -> ./start_test.sh
for windows -> go to backend\bin and run -> start_test.bat
- For the Postman user, please import bin/db_seed/thingaha.postman_collection.json for API testing
This project was bootstrapped with Create React App.
Main UI framework is Material UI. For component styling, styled-components is used.
-
First, install tools listed in pre-requisite section.
-
Then set up the frontend app.
-
To set up frontend dev server,
cd
into thefrontend
directory and install necessary node modules by runningyarn install
. -
To set up for connection with backend server
- copy env file (
frontend\src\.env.example
) and rename to (frontend\src\.env.local
)
- copy env file (
-
Then, run
yarn start
-
To set up for windows developmemt, please update frontend\package.json
"start": "PORT=5001 react-scripts start"
to"start": "set PORT=5001 && react-scripts start"
-
The frontend dev server is configured to run on port
5001
. Try navigating to http://localhost:5001/ to see the app in action. -
initial login information
- username:
moemoe@gmail.com
- password:
123
- username:
-
Check your local language in terminal
locale
LANG="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_CTYPE="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_ALL="en_US.UTF-8"
- If there is no en_US.UTF-8, please try adding or editing the following line in
~/.profile
or~/.zshrc
file for it to correctly export your locale settings upon initiating a new session.
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8
- Then check
locale -a
orlocale
in terminal again. - You should see the above locale setting in your terminal. Then restart the postgresql.
brew services list
brew services restart postgresql@12
- Try to create
test db
by using the following command.
CREATE DATABASE db_test WITH TEMPLATE = templateUTF_8 ENCODING = 'UTF8' LC_COLLATE = 'en_US.UTF-8' LC_CTYPE = '
en_US.UTF-8';
- If there is no error , drop the thingaha_dev db and create again by following SQL.
CREATE DATABASE thingaha_dev
WITH OWNER = XXXX
TEMPLATE = templateUTF_8
ENCODING = 'UTF8'
LC_COLLATE = 'en_US.UTF-8'
LC_CTYPE = 'en_US.UTF-8'
TABLESPACE = pg_default
CONNECTION LIMIT = -1;
- rerun
db_migrate
anddb_seed
again