A boilerplate for kickstarting my projects with Django backend and React front-end

Overview

Django-React-Boilerplate

This is a boilerplate for kickstarting my projects with Django backend and React front-end. (AND, PostgreSQL) as the database.

Index

Running the project

The easiest way to just run the project is to use the included docker-compose file

Docker running

You may not need to use sudo based on the user permission level.

  • copy the .env.example file to .env

cp .env.example .env

  • update the .env file with the credentials of your liking.
  • Run the project with
sudo docker-compose up --build -d

This will build the necessary images and run the project. You can access the project in localhost:80 or localhost or 127.0.0.1 url.

Docker configurations

  • Change the running port You can change the port during running the compose file with $PORT variable set in environment like so
sudo PORT=1131 docker-compose up --build -d
  • Create superuser
sudo docker exec -it django-react-boilerplate-backend python api/manage.py createsuperuser
  • Change database data directory You can use the environment variable $DATABASE_DATA_VOLUME in .env file or in the environment variable to persist the database data.
  • To change the container names you have to update the docker-compose-file for now.

Development

Or, manual running

Pre-Requisites

  • Python [v3.8]

Please follow the official guide to install/update python if not already running.

  • Postgresql [v13]

Please follow the official guide to install/update and setup postgresql if not already running.

  • Nodejs [v17.3] and npm

Please follow the official guide to install/update and setup nodejs and npm if not already running.

Get the code

  • Fork or clone the repository to local machine
git clone https://github.com/mehedi-shafi/django-react-boilerplate

Setup database

  • Make a new user in postgresql for the application
  • Create a new database in Postgresql and make the previously created user its owner

Setup credentials

  • Copy .env.example to .env
  • Update the .env file
    • Set the database credentails as done in database-setup step.
    • Change the following variables to your liking
    DJANGO_ALLOWED_HOSTS
    DEFAULT_TIME_ZONE
    DJANGO_SECRET_KEY
    MEDIA_ROOT # make sure you have permission to this directory
    LOG_FILE_DIRECTORY # make sure you have permission to this directory

Setup Backend

  • Open a terminal in project root and run the following commands
# create a virtual environment
python -m venv .venv pip wheel
# activate the virtual environment
source .venv/bin/activate
# install the dependencies
pip install -r requirements.txt
# run the migrations
python manage.py migrate
# create a superuser
python manage.py createsuperuser 
# create static files
python manage.py collectstatic
# run the server
python manage.py runserver 0.0.0.0:8000
  • Confirm by going to 127.0.0.1:8000 in your browser.
  • You can terminate the backend by pressing ctrl+c

Setup Frontend

  • Open a terminal in the project root and run the following commands
cd frontend

# install the dependencies
npm ci
# run the frontend
npm run start:frontend
  • Verify if the frontend is running on 127.0.0.1:3000

Running both frontend and backend

There's a npm script in the frontend's package.json that will let you run the project as a whole (frontend and backend). To do that first activate the virtual-environment from project root and then from frontend/ directory run this

npm start
You might also like...

🔍 Remake of Reguleque's front-end, a search engine for government employees. Maintained by the América Transparente foundation.

regulf-react Frontend for Reguleque, a search engine for chilean public workers records' as obtained through transparency databases. Get started To ru

Dec 15, 2022

Fiz uma validação de senhas no Front-End usando RegEx!

Fiz uma validação de senhas no Front-End usando RegEx!

Seja bem vindo a um dos meus #JokeCodes Nesse código vou te mostrar como fazer uma validação de senha no Front-End, com feedback na tela de login!, us

Oct 5, 2022

React Starter Kit — isomorphic web app boilerplate (Node.js, Express, GraphQL, React.js, Babel, PostCSS, Webpack, Browsersync)

React Starter Kit — isomorphic web app boilerplate (Node.js, Express, GraphQL, React.js, Babel, PostCSS, Webpack, Browsersync)

React Starter Kit — "isomorphic" web app boilerplate React Starter Kit is an opinionated boilerplate for web development built on top of Node.js, Expr

Dec 30, 2022

React-Mini-Projects - Simple React mini-applications

React Mini Projects A Fully Responsive React Application contain these mini apps : Todo App Movie App Budget App Flash Card App Factor App This app wa

Jan 1, 2022

Twitter-Clone-Nextjs - Twitter Clone Built With React JS, Next JS, Recoil for State Management and Firebase as Backend

Twitter Clone This is a Next.js project bootstrapped with create-next-app. Getting Started First, run the development server: npm run dev # or yarn de

Feb 7, 2022

A React application for AddressBook to manage contacts on web. It will use JSON-server to create backend apis.

Available Scripts In the project directory, you can run: npm install To install all related packages npm start Runs the app in the development mode. O

Jan 10, 2022

React + Redux starter kit / boilerplate with Babel, hot reloading, testing, linting and a working example app built in

React + Redux starter kit / boilerplate with Babel, hot reloading, testing, linting and a working example app built in

A comprehensive starter kit for rapid application development using React. Why Slingshot? One command to get started - Type npm start to start develop

Dec 22, 2022

Boilerplate to build Cross-Platform Apps with Expo and React Native

Expo and React Native Boilerplate Boilerplate to build Cross-Platform Apps with Expo and React Native What are you going to find in this boilerplate E

Apr 29, 2022

A Minimal Setup & Fast Boilerplate for React.js with Vite.

A Minimal Setup & Fast Boilerplate for React.js with Vite.

A Minimal Setup & Fast Boilerplate for React.js with Vite Features 🚀 Dynamic Pages Routing with react-router-dom from React.js 🚀 Fast development wi

Oct 25, 2022
Owner
Mehedi Shafi
Oh boy.. The awkward `About yourself`. I cannot say what I am like.
Mehedi Shafi
A personal project, made with React, React Native, Typescript and some of the most used front-end libraries.

A personal project, made with React, React Native, Typescript and some of the most used front-end libraries.

Alvaro Junior 1 Jul 23, 2022
Chrome-extension-react-boilerplate - Simple Chrome extension React boilerplate.

Simple Chrome extension React boilerplate This is a simple chrome extension boilerplate made in React to use as a default structure for your future pr

Younes 6 May 25, 2022
Getir.com-react-tailwind - Getir.com anasayfa react + tailwind front-end

Getir.com React + Tailwind Front-end Bir gece uğraşı olarak getir.com'un anasayf

Tayfun Erbilen 102 Dec 17, 2022
Bookstore CMS React Front-End to display a list of books, categorize it, add and remove books and update your reading progress

Bookstore REACT app to manage your books Build an app to display a list of books, categorize it, add and remove books and update your reading progress

Eapen Zacharias 3 Aug 19, 2022
Demo project to deploy front- and backend together on heroku.

spring-boot-react-bundle This is a demo project that shows how it is possible to deploy a react frontend and a Spring Boot backend into a heroku dyno.

André Schreck 5 Jul 22, 2022
Would You Rather App (Front End Developer Udacity Nanodegree)

Would You Rather App Table of Contents Overview Built with Install (How it works) Overview Would You Rather is the Second project with React Redux in

Ahmed Bayoumi 1 Apr 28, 2022
Grid-tool - Small tool that allows you to integrate a predefined or generated grid into your front-end development environment.

Grid tool Small tool that allows you to integrate a predefined or generated grid into your front-end development environment. Tool installation includ

hmongouachon 2 Jan 4, 2022
Next JS micro front-end project

a project to create micro frontend nextjs app in seconds!

Amirreza 4 Sep 1, 2022
Front-end code for teia

Teia UI This repository is the frontend code of the open, community owned Tezos NFT Platform teia.art. Teia is a fork of the Tezos NFT platform Hic et

Teia Community 21 Dec 2, 2022
OpenMaze landing page front-end

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

OpenMaze 6 Dec 15, 2022