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
-
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?
- Run
docker exec -it backend_db_1 /bin/sh
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 exec backend_web_1 /usr/bin/python3 ../src/db_seed.py
- Run
- 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: [email protected]
-- 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 draft api server. We're using a draft api server with canned response before backend is ready
- To set up draft api server,
cd
into thedraft_server
directory and install necessary node modules by runningyarn install
. - Then, run
yarn start
- The draft server is configured to run on port
9000
. Try navigating to http://localhost:9000/users to see if draft server is working properly.
- To set up draft api server,
- Then set up the frontend app.
-
To set up frontend dev server,
cd
into thefrontend
directory and install necessary node modules by runningyarn install
. -
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"
-
To set up for connection with server (draft api or backend)
- rename file
frontend\src\.env.example
tofrontend\src\.env.local
- rename file
-
To set up for connection with draft api server, update frontend\src\.env.local file
REACT_APP_USE_DRAFT_API=false
toREACT_APP_USE_DRAFT_API=true
-
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:
[email protected]
- password:
123
- username:
-