Build web applications using React.js for the front end and python/flask for your backend API.
- Documentation can be found here: https://4geeks.com/docs/start/react-flask-template
- Here is a video on how to use this template
- Integrated with Pipenv for package managing.
- Fast deployment to Render in just a few steps here.
- Use of .env file.
- SQLAlchemy integration for database abstraction.
- Backend:
src/backendcontains the Tapin Flask API (users, listings, saved searches, email flows). Run it directly withpython src/backend/app.pyor configure your WSGI server to importbackend.app. - Frontend:
src/frontis the Vite/React Leaflet SPA copied fromTapin_/frontend.npmcommands live at the repo root and point to this folder throughvite.config.js. - Build output:
npm run buildwrites to the rootdist/folder.src/app.pyserves those files while re-exporting the Flask backend. - Dependencies: use
python -m venv .venv && pip install -r src/backend/requirements.txtfor the API andnpm installfor the SPA. The top-levelrequirements.txtsimply references the backend list. - Environment: copy
.env.exampleto.envand fill the variables required bysrc/backend/app.py(database URL, JWT secrets, SMTP settings, etc.). The frontend expectsVITE_BACKEND_URLto point at the running API.
If you use Github Codespaces (recommended) or Gitpod this template will already come with Python, Node and the Posgres Database installed. If you are working locally make sure to install Python 3.10, Node
It is recommended to install the backend first. Make sure you have Python 3.10+, Node 20, and whichever database engine you plan to use (SQLite works out-of-the-box for local dev).
-
Create your virtual environment and install dependencies:
cd src/backend python -m venv .venv .venv\Scripts\activate pip install -r requirements.txt
-
Back at the repository root copy the environment template:
cd ../.. # from src/backend back to the repo root copy .env.example .env # or use cp on mac/linux
Set
SQLALCHEMY_DATABASE_URI,SECRET_KEY,JWT_SECRET_KEY, email SMTP creds, etc. as required bysrc/backend/app.py. -
Apply migrations / seed data if needed. The Tapin backend ships with Alembic scripts and helpers such as
manage.py,migrate_db.py, andseed_data.py. Example:flask --app backend.app db upgrade # apply migrations python backend/seed_data.py # optional seed data
-
Run the API:
python backend/app.pyThe service defaults to SQLite at
src/backend/data.dbbut will honor anySQLALCHEMY_DATABASE_URIyou provide.
Where do npm commands live?
package.jsonsits at the repository root, so always runnpm install,npm run dev, etc. from the root folder (.../Tapin_Correct). Those scripts automatically point tosrc/frontviavite.config.js.
-
From the repo root install the Vite dependencies and configure the API URL:
cd C:\Users\BOMAU\OneDrive\Desktop\4geeks\Project\adjustments\Tapin_Correct npm install echo VITE_BACKEND_URL=http://localhost:5000 >> .env # or edit existing .env
-
Run the dev server and tests:
npm run dev npm run test
-
Build for production (output goes to
/dist, which Flask serves automatically):npm run build
- Back end:
cd src/backend && .\.venv\Scripts\activate && python app.py(orflask --app backend.app run).- Default SQLite DB lives at
src/backend/data.db. If you overrideSQLALCHEMY_DATABASE_URI, make sure it resolves from the directory you launch the server in.
- Default SQLite DB lives at
- Front end: from the repo root run
npm run devand open the URL Vite prints (usuallyhttp://localhost:5173). - Ensure
.envhasVITE_BACKEND_URL=http://localhost:5000(or whatever host/port Flask uses) so the SPA can reach the API. - For production-style verification run
npm run buildand then hit the Flask root (http://localhost:5000/); it serves the files fromdist/.
This boilerplate it's 100% read to deploy with Render.com and Heroku in a matter of minutes. Please read the official documentation about it.
This template was built as part of the 4Geeks Academy Coding Bootcamp by Alejandro Sanchez and many other contributors. Find out more about our Full Stack Developer Course, and Data Science Bootcamp.
You can find other templates and resources like this at the school github page.