|
| 1 | +# Pythonfast |
| 2 | + |
| 3 | +Energy-focused FastAPI learning repository with a React tutorial frontend and FastAPI backend examples. |
| 4 | + |
| 5 | +## Live Links |
| 6 | + |
| 7 | +- GitHub Pages (tutorial app): https://niranjanxprt.github.io/Pythonfast/ |
| 8 | +- Repository: https://github.com/niranjanxprt/Pythonfast |
| 9 | + |
| 10 | +## Repository Layout |
| 11 | + |
| 12 | +```text |
| 13 | +. |
| 14 | +├── fastapi-tutorial/ # React + Vite interactive FastAPI tutorial (deployed to GitHub Pages) |
| 15 | +├── my-fastapi-app/ # FastAPI example backend and Pydantic models |
| 16 | +└── .github/workflows/ # CI/CD workflows (Pages deployment) |
| 17 | +``` |
| 18 | + |
| 19 | +## What This Repo Includes |
| 20 | + |
| 21 | +- FastAPI basics: routing, request validation, query/path params |
| 22 | +- Pydantic models and validation patterns |
| 23 | +- Energy-domain examples (panels, readings, monitoring) |
| 24 | +- Pandas and NumPy examples for energy data analysis |
| 25 | +- React tutorial UI deployed to GitHub Pages |
| 26 | + |
| 27 | +## Quick Start |
| 28 | + |
| 29 | +### 1. Frontend tutorial app |
| 30 | + |
| 31 | +```bash |
| 32 | +cd fastapi-tutorial |
| 33 | +npm ci |
| 34 | +npm run dev |
| 35 | +``` |
| 36 | + |
| 37 | +Open: http://localhost:5173 |
| 38 | + |
| 39 | +### 2. FastAPI backend examples |
| 40 | + |
| 41 | +```bash |
| 42 | +cd my-fastapi-app |
| 43 | +python -m venv .venv |
| 44 | +source .venv/bin/activate # Windows: .venv\Scripts\activate |
| 45 | +pip install fastapi "uvicorn[standard]" |
| 46 | +uvicorn main:app --reload |
| 47 | +``` |
| 48 | + |
| 49 | +Open: |
| 50 | + |
| 51 | +- API root: http://127.0.0.1:8000 |
| 52 | +- Swagger UI: http://127.0.0.1:8000/docs |
| 53 | + |
| 54 | +## Deployment |
| 55 | + |
| 56 | +The frontend is deployed automatically with GitHub Actions: |
| 57 | + |
| 58 | +- Workflow: `.github/workflows/deploy-fastapi-tutorial-pages.yml` |
| 59 | +- Trigger: push to `main` for files under `fastapi-tutorial/**` |
| 60 | +- Publish target: `gh-pages` branch |
| 61 | +- Vite base path: `/Pythonfast/` |
| 62 | + |
| 63 | +## Best Practices Followed |
| 64 | + |
| 65 | +- Keep frontend and backend concerns separated by directory. |
| 66 | +- Deploy only static frontend assets to Pages; keep API runtime separate. |
| 67 | +- Use lockfiles (`package-lock.json`) for reproducible frontend builds. |
| 68 | +- Use CI/CD workflow for repeatable deployment on every push. |
| 69 | +- Keep secrets out of source code and use environment variables in real deployments. |
| 70 | + |
| 71 | +## Notes |
| 72 | + |
| 73 | +- This repository is tutorial-oriented and optimized for learning. |
| 74 | +- For production APIs, add authentication, persistent storage, tests, and observability. |
0 commit comments