I made this project template to make it easy to quickly bootstrap a full stack application following modern practices ๐.
cookiecutter gh:sicksid/django-nextjs-boilerplate
- Full stack development with Django and Next.js ๐ป
- Authentication with next-auth.js and Django REST framework simplejwt ๐
- Docker-compose for easy setup and deployment ๐ณ
- Automatic API documentation generation with a
/docs
endpoint and exportable/schema
file ๐ - openapi 3 typesafe generated axios client in
./client
by running the commandnpm run generate-client
๐ฆ - Easy management with the
task
command (see available tasks by runningtask --list
after installing task) ๐ - Use .env files for local development ๐ผ
- Github Actions workflows for CI/CD ๐ง
The project is structured with two separate directories for the frontend and backend ๐. The backend, which is built using Django REST framework ๐, is located in the ./backend
directory ๐ป, where you can find the api, settings, shared, urls and wsgi files. The frontend, which is built using Next.js ๐, is located in the ./frontend
directory ๐ป, where you can find the pages, styles, and server files.
For a more detailed view of the project structure ๐, you can run the command tree -L 3 -I 'node_modules|.venv|client|__pycache__'
๐ณ.
Additionally, the project includes:
pyproject.toml
in./backend
for managing python dependencies using pdm ๐package.json
in./frontend
for managing frontend dependencies using npm ๐ฆTaskfile.yml
for easy task running using task ๐docker-compose.yml
that contains the necessary configurations to run the project with Docker ๐ณ
- Docker and Docker Compose ๐ณ
- Node.js and npm (optional) ๐
- Python 3.11 and pdm (optional) ๐
Note: If you don't want to use Docker, you can install the dependencies manually and run the project locally. See the Dockerfile
and docker-compose.yml
for more details.
Optionally install asdf to run asdf install
and get python and node.js automatically installed ๐ ๏ธ
- Clone the repository:
git clone https://github.com/sicksid/django-nextjs-project-template.git
- Rename the project with your desired name:
mv django-nextjs-project-template yourprojectname
andcd yourprojectname
- Build and start the containers:
docker-compose up --build
- The application should now be running at
http://localhost:3000
for the frontend andhttp://localhost:8080
for the backend ๐
- Clone the repository:
git clone https://github.com/sicksid/django-nextjs-project-template.git
- Rename the project with your desired name:
mv django-nextjs-project-template yourprojectname
andcd yourprojectname
- Start the database in the background:
docker-compose up -d database
- Install the python dependencies:
cd backend && pdm install
- Install the frontend dependencies:
cd frontend && npm install
- Run the frontend:
cd frontend && npm run dev
- Run the backend:
cd backend && python manage.py runserver
- The application should now be running at
http://localhost:3000
for the frontend andhttp://localhost:8000
for the backend ๐