FastAPI + React inventory management system with product dimensions, stock tracking, and dynamic pricing. Backend uses SQLAlchemy + SQLite; frontend uses Vite + React.
This skill provides context and actionable instructions for working with an inventory management system built with FastAPI (backend) and React + Vite (frontend).
The application consists of:
- Entry point: `backend/main.py`
- Database: `backend/inventory.db` (SQLite)
- Location: `frontend/frontend/`
- Dev server: runs on port 5173
- API client: `frontend/frontend/src/api.js`
- Product → Dimension → SliderType/Color → Stock
- Defined in `backend/models.py`
Start the FastAPI server from the repository root:
```bash
cd backend && uvicorn main:app --reload --port 8000
```
Or from root directory:
```bash
uvicorn backend.main:app --reload --port 8000
```
Create and populate the database:
```bash
python backend/seed.py
```
This creates `backend/inventory.db` with seed data.
Start the Vite dev server:
```bash
cd frontend/frontend && npm install && npm run dev
```
The frontend will be available at `http://localhost:5173`.
When making changes, consult these files based on the component:
| Component | File | Purpose |
|-----------|------|---------|
| API routing | `backend/main.py` | FastAPI endpoint definitions |
| Business logic | `backend/crud.py` | Database operations and transactions |
| Database models | `backend/models.py` | SQLAlchemy ORM models |
| API schemas | `backend/schemas.py` | Pydantic v2 request/response models |
| Pricing/sizing | `backend/utils.py` | Pure utility functions |
| Database config | `backend/database.py` | SQLAlchemy setup |
| Seed data | `backend/seed.py` | Initial database population |
| Frontend API | `frontend/frontend/src/api.js` | HTTP client functions |
| Frontend components | `frontend/frontend/src/` | React components |
All Pydantic models use v2 syntax:
```python
class Config:
from_attributes = True
```
Size handling uses `SizeRule` model:
Pricing is centralized in pure functions:
```python
utils.compute_price(base_price, size, base_size)
```
1. **SQLite Path**: Database URL is `sqlite:///./inventory.db` (relative path)
- Run commands from `backend/` directory
- Or adjust path in `backend/database.py`
2. **Code Duplication**: Some endpoints and `get_db()` function appear twice in `backend/main.py`
- Be conservative with cleanup
- Document any refactoring in pull requests
3. **Dependencies**: No `requirements.txt` exists
- Minimum backend dependencies: `fastapi`, `uvicorn`, `sqlalchemy`, `pydantic`
- Frontend: run `npm install` in `frontend/frontend/`
4. **No Test Suite**: Currently no automated tests
- Document test plans in pull requests
- Add unit tests for `backend/utils.py` functions when modifying
1. Add database logic to `backend/crud.py`
2. Define Pydantic schema in `backend/schemas.py` (if needed)
3. Create endpoint in `backend/main.py` with appropriate `response_model`
4. Add frontend API call to `frontend/frontend/src/api.js` (if needed)
Example:
```python
def get_product_names(db: Session):
return db.query(models.Product.name).all()
@app.get("/products/names", response_model=list[schemas.ProductBase])
def list_product_names(db: Session = Depends(get_db)):
return crud.get_product_names(db)
```
1. Edit `backend/utils.py::compute_price()`
2. Keep function pure (no side effects)
3. Add unit tests (create test file if needed)
4. Document changes in pull request
1. Update SQLAlchemy models in `backend/models.py`
2. Update corresponding Pydantic schemas in `backend/schemas.py`
3. Create migration plan (manual migration required)
4. Update seed data in `backend/seed.py` if needed
5. Document migration steps in pull request
1. Modify React components in `frontend/frontend/src/`
2. Update API client in `frontend/frontend/src/api.js` if endpoints change
3. Test with dev server on port 5173
- Database logic → `crud.py`
- Pure functions → `utils.py`
- Routing only → `main.py`
- Include clear migration/seed plan when changing models
- Document any required manual steps
- Describe test plan in PR description
- Consider adding unit tests for new utility functions
Most commands assume execution from specific directories:
If encountering path issues, confirm intended working directory before modifying configuration files.
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/github-copilot-inventory-system/raw