SwasthyaChain is a healthcare records platform combining a FastAPI backend and a React (Vite) frontend. The project demonstrates secure medical record storage and sharing with auxiliary services (IPFS, encryption, blockchain) and AI-assisted insights.
Tech stack
- Backend:
Python+FastAPI - Frontend:
React+Vite - Data/storage helpers: IPFS + blockchain integration (in
server/app/services) - Dev/test:
uvicorn,pytest
Repository layout
server/— FastAPI backend, API routers, services, and testsserver/app— application codeserver/requirements.txt— backend dependenciesserver/run.py— quick-run script
swasthyachain-frontend/— React + Vite frontendswasthyachain-frontend/src— React source filesswasthyachain-frontend/package.json— frontend dependencies & scripts
Requirements / Prerequisites
- macOS / Linux / Windows with a POSIX-like shell (examples use
zsh) - Node >= 16 (for Vite)
- Python 3.10+ (or the version required by
server/requirements.txt) - (Optional)
gitfor cloning and managing branches
Backend — Setup & Run
- Create and activate a Python virtual environment (example using
venv):
cd server
python -m venv .venv
# macOS / Linux
source .venv/bin/activate
# Windows (PowerShell)
# .\.venv\Scripts\Activate.ps1- Install backend dependencies:
pip install -r requirements.txt- Run the API server (development mode):
# from repository root
cd server
# using run.py helper (if present)
python run.py
# or directly with uvicorn:
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000- Quick check:
- Open
http://localhost:8000/docsto view the interactive OpenAPI docs.
Frontend — Setup & Run
- Install Node dependencies and run dev server:
cd swasthyachain-frontend
npm install
npm run dev- The Vite dev server default URL is printed in the console (commonly
http://localhost:5173). Open that in your browser.
Environment variables
- If the backend or frontend require
.envvalues, create.envfiles in the corresponding folders. Typical variables:BACKEND_URL(frontend) — e.g.http://localhost:8000- Any API keys used by services (IPFS, blockchain providers, AI services)
Testing
- Backend tests (example):
# from repository root
cd server
pytest -qCommon troubleshooting
- "Import could not be resolved" in VS Code: ensure VS Code uses the same Python interpreter as your virtual environment. Use the Command Palette → "Python: Select Interpreter" and choose
.venv/bin/python. Restart the language server. - Tailwind /
@applywarnings: ensuretailwindcssandpostcssare set up in the frontend and that your editor postcss/stylelint settings allow Tailwind at-rules. - Fast Refresh warnings (React): move React contexts to files that export only contexts and keep providers as component-only files.
Contributing
- Create feature branches off
main. - Run backend and frontend locally while developing.
- Add tests for backend changes and ensure existing tests pass.
Useful commands (summary)
- Backend install & run:
cd server
python -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
uvicorn app.main:app --reload --port 8000- Frontend install & run:
cd swasthyachain-frontend
npm install
npm run dev