diff --git a/README.md b/README.md index d83e9e0..cbe3630 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,9 @@ https://github.com/masai-oss/open-template/wiki/Backend-Guide ​ ### Frontend Guide https://github.com/masai-oss/open-template/wiki/Frontend-Guide + https://github.com/masai-oss/open-template/wiki/Cypress-Guide + https://github.com/masai-oss/open-template/wiki/OAuth-Guide ​ It is very important to read these documents throughly before starting to code. \ No newline at end of file diff --git a/project_guide/Venv_guide.md b/project_guide/Venv_guide.md index d6f8acf..24784df 100644 --- a/project_guide/Venv_guide.md +++ b/project_guide/Venv_guide.md @@ -4,19 +4,88 @@ Virtual environments are independent groups of Python libraries, one for each pr Python 3 comes bundled with the venv module to create virtual environments. -## Create an environment -Create a project folder and a venv folder within. +## Install pyenv + +To manage multiple versions of python the most popular app is pyenv: + +#### Install dependencies +```bash +sudo apt-get install -y make build-essential libssl-dev zlib1g-dev \ +libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \ +libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl ``` -mkdir -cd -python3 -m venv venv + +#### Install pyenv + +1. `curl https://pyenv.run | bash` + + you should see a message like + +```shell +WARNING: seems you still have not added 'pyenv' to the load path. + +# Load pyenv automatically by adding +# the following to ~/.bashrc: + +export PATH="$HOME/.pyenv/bin:$PATH" +eval "$(pyenv init -)" +eval "$(pyenv virtualenv-init -)" ``` -### Activate the environment -Before you work on your project, activate the corresponding environment: + 2. `nano ~/.bashrc` + 3. paste the message into the file + 4. restart the shell + +P.S if you're using other shell like `zsh` replace the `bash` and `bashrc` accordingly + +#### Install python version + +`pyenv install ` + +The new python version should be installed in the directory `~/.pyenv/versions/` + +## Create an environment +One of the most popular virtual environment manager is `virtualenv` + +### Install `virtualenv` +##### Install pip + +```shell +sudo apt-get install python3-pip ``` + +##### Install `virtualenv ` using `pip3` + +`sudo pip3 install virtualenv` + +##### Create virtual environment + +1. It's recommended to create the virtual environment in their respective folder + +2. `virtualenv -p ` + + ex: + + ​ `virtualenv -p ~/.pyenv/versions/3.7.3/bin/python venv` + +##### Activate the environment +Before you work on your project, activate the corresponding environment: + +```shell source venv/bin/activate ``` -Your terminal will change to show the name of the activated environment. \ No newline at end of file +Your terminal will change to show the name of the activated environment. + +##### Deactivate the environment + +`deactivate` + +### Create `requirements.txt` + +You need `requirements.txt` file to keep track of all the installed packages in your app to create it, follow the following steps + +1. activate the virtual environment +2. `pip freeze` This command shows you all the packages in your virtual environment +3. `pip freeze > requirements.txt`redirects all the package names with their versions into the `requirements.txt` file \ No newline at end of file diff --git a/src/client/README.md b/src/client/README.md index 1b6eeaf..43617f1 100644 --- a/src/client/README.md +++ b/src/client/README.md @@ -1,5 +1,33 @@ # React Project Template +## Folder structure: + +``` +├── /build/ # compiled output +├── /docs/ # Documentation files +├── /node_modules/ # 3rd party lib +├── /public/ # Static files +├── /src/ # The source code of the application +├───── /components/ # React components +├──────├──────/admin # dashboard, admin +├──────├──────/common # shared components +├──────├──────/icons # icons +├──────├──────/news # news specific components +├──────├──────/static # static page +├────── redux/ # redux (Seperate into sub folders based on functions as well as complexity rises) +├──────├──────/actions # action types, action creators +├──────├──────/reducers # reducers +├──────├──────store.js # store.js +├────── /utils/ # server schema and data models +├────── /routes/ # Routes/Page files +├────── /clientScript.js # Client-side startup script +├────── /config.js # application settings +├────── ... +├── /test/ # Unit tests +├── package.json +└── yarn.lock +``` + ## Instructions 1. Install the necessary dependencies. diff --git a/src/client/src/routes/NavbarPublic.jsx b/src/client/src/routes/NavbarPublic.jsx index f016bf0..37bca8b 100644 --- a/src/client/src/routes/NavbarPublic.jsx +++ b/src/client/src/routes/NavbarPublic.jsx @@ -7,6 +7,13 @@ const NavBar = ({ location: { pathname } }) => { if (pathname.startsWith("/dash")) return null; return (
+ + masai open source logo + Home Login Register diff --git a/src/server/README.md b/src/server/README.md index 4c9bb16..d3684d7 100644 --- a/src/server/README.md +++ b/src/server/README.md @@ -3,6 +3,8 @@ ## Requirements 1. Setup the database server based on the project requirement + For MySQL installation refer to [this](https://www.digitalocean.com/community/tutorials/how-to-install-mysql-on-ubuntu-18-04) link. + ### After cloning follow the steps to setup 1. Create virtual environment with `pipenv/virtualenv` for python version 3.7.3 (or higher), visit this [link](https://github.com/masai-oss/open-template/wiki/Virtual-Environment-Guide) for Virtualenv Guide. @@ -54,7 +56,7 @@ ##### To change the DB settings 1. Create data-base in respective server -2. Open the `settings.py` in the src/server/app/main/ folder +2. Open the `settings.py` in the `src/server/app/main/ ` 3. Change the database URI in `SQLALCHEMY_DATABASE_URI` based on the development env ##### To create migrations folder @@ -228,8 +230,8 @@ from flask import g oauth = OAuth() github = oauth.remote_app('github', - consumer_key="c1d53a4b044962c3379a", - consumer_secret="a2b7acacd1b94dde26fc1dae18b8c6e7f9e1f22f", + consumer_key="", + consumer_secret="", request_token_params={"scope": "user:email"}, base_url="https://api.github.com/", request_token_url=None, @@ -300,3 +302,38 @@ Add the required tokens/credentials as specified under `SECRET_KEYS` in `setting ``` +### Few things to keep in mind + +1. Run the command `make clean`to clear out all the `__pycache__` folders and files, before you push files to github + +2. Follow `pep8` rules to avoid commit issues including the docstrings in google format + + Example for methods: + + ```python + """method to add todo to the model Todo + Args: + data (dict): data which needs to be stored into Todo table + using Todo model + Returns: + dict: response object containing appropriate response based on the response from save changes, + int: http response code specifying the success or failure of storing data into table + """ + ``` + + + + Example for classes: + + ```python + """SQLAlchemy model for Todo items + containing fileds id and todo_item + id: unique identifier + todo_item: the todo item to be added to the database + Args: + db (object): SQLAlchemy object imported from main + """ + ``` + +3. Add docstrings to the file to describe the function of the file in brief +4. Add your static files to `server/src/app/main/static` folder