A simple REST API for managing invoices, built with Python and FastAPI.
- Backend: FastAPI (Python)
- Database: PostgreSQL
- ORM: SQLAlchemy
- Frontend: HTML, CSS, JavaScript
This project covers the core concepts of web development:
| Concept | What It Does |
|---|---|
| REST API | GET, POST, PUT, DELETE operations |
| Database | Store data permanently with PostgreSQL |
| ORM | Talk to database using Python (SQLAlchemy) |
| Frontend | Display data and handle user interactions |
| Method | Endpoint | Description |
|---|---|---|
| GET | /invoices |
List all invoices |
| GET | /invoices/{id} |
Get one invoice |
| POST | /invoices |
Create new invoice |
| PUT | /invoices/{id} |
Update invoice |
| DELETE | /invoices/{id} |
Delete invoice |
invoice-api/
├── main.py # API endpoints
├── database.py # Database connection
├── models.py # Database tables (SQLAlchemy)
├── schemas.py # Request/Response shapes (Pydantic)
├── index.html # Frontend UI
└── README.md
- Install dependencies:
pip install fastapi uvicorn sqlalchemy psycopg2-binary- Start PostgreSQL and create database:
createdb invoice_db- Run the API:
uvicorn main:app --reload- Open
index.htmlin browser or visit http://localhost:8000/docs
API Docs: http://localhost:8000/docs