https://github.com/xbt-a4224j/invoice-manager
A simple invoice management system with inventory tracking\
https://github.com/xbt-a4224j/invoice-manager
demo ecommerce-application etl fastapi python streamlit
Last synced: 5 months ago
JSON representation
A simple invoice management system with inventory tracking\
- Host: GitHub
- URL: https://github.com/xbt-a4224j/invoice-manager
- Owner: xbt-a4224j
- Created: 2025-12-19T07:53:48.000Z (6 months ago)
- Default Branch: main
- Last Pushed: 2025-12-20T17:10:54.000Z (6 months ago)
- Last Synced: 2025-12-22T18:42:36.613Z (6 months ago)
- Topics: demo, ecommerce-application, etl, fastapi, python, streamlit
- Language: Python
- Homepage:
- Size: 24.4 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Invoice Demo API
A simple invoice management system with inventory tracking, built with FastAPI and Streamlit.

-----

---
## 🚀 Quick Start
### 1. Install Dependencies
```bash
pip install -r requirements.txt
```
### 2. Start the API Server
```bash
uvicorn app.main:app --reload
```
Server runs at: **http://localhost:8000**
### 3. Access the UI
**Option A: Streamlit UI (Recommended)**
```bash
streamlit run ui.py
```
Open browser to: **http://localhost:8501** or **http://localhost:8502**
**Option B: Swagger UI (API Documentation)**
Open browser to: **http://localhost:8000/docs**
Interactive API documentation with request/response examples and try-it-out functionality.
---
## Features
- **Invoice Management**: Create draft invoices, add items, and finalize
- **Inventory Tracking**: Automatic inventory decrement on invoice finalization
- **Validation**: Prevents modifications to finalized invoices and insufficient inventory checks
- **Admin Tools**: Database seeding and clearing via UI sidebar
## Tech Stack
- **Backend**: FastAPI, SQLAlchemy
- **Frontend**: Streamlit
- **Database**: SQLite (embedded, no separate service needed)
## API Endpoints
### Invoices
- `POST /invoices` - Create new invoice
- `GET /invoices` - List all invoices
- `GET /invoices/{id}` - Get invoice with items
- `POST /invoices/{id}/items` - Add item to invoice
- `POST /invoices/{id}/finalize` - Finalize invoice (decrements inventory)
### Inventory
- `GET /inventory` - List inventory items
- `POST /inventory` - Add inventory item
### Admin
- `POST /admin/clear-database` - Clear all data
- `POST /admin/seed-database` - Load sample data
## Project Structure
```
.
├── app/
│ ├── main.py # FastAPI app and route handlers
│ ├── models.py # SQLAlchemy ORM models
│ ├── schemas.py # Pydantic request/response schemas
│ ├── services.py # Business logic layer
│ └── db.py # Database configuration
├── migrations/
│ ├── 001_init.sql # Initial schema
│ └── 002_seed.sql # Sample data
├── tests/
│ └── test_api.py # Integration tests
├── ui.py # Streamlit frontend
└── invoice_demo.db # SQLite database (auto-created)
```
## Database
SQLite database is automatically created as `invoice_demo.db` on first run.
### Seed Sample Data
Use the Streamlit UI sidebar buttons:
- **Clear**: Remove all data
- **Seed**: Load sample inventory and invoices
Or use API endpoints:
```bash
curl -X POST http://localhost:8000/admin/seed-database
```
### Reset Database
```bash
rm invoice_demo.db
# Restart the app to recreate it
```
## Testing
Run integration tests:
```bash
pytest tests/test_api.py -v
```
## Development
The API server runs with `--reload` flag, automatically restarting on code changes.
CORS is configured to allow requests from:
- http://localhost:8501 (Streamlit default)
- http://localhost:8502 (Streamlit alternate)