Prerequisites
Before you begin, ensure you have:- Python 3.8+ installed
- Node.js 16+ and npm
- PostgreSQL 12+ running
- A code editor
Quick Setup
Configure Database
Create a The database will be created automatically on first run.
.env file in the project root:.env
Start the Backend
Launch the FastAPI backend:Your API is now running at
http://localhost:8000. Visit http://localhost:8000/docs to see the interactive API documentation.Create Your First Tenant
Create a tenant (business entity) using the API. First, you’ll need to authenticate as a global admin (this happens automatically on first startup):
This automatically provisions a new database schema for the tenant with complete isolation.
What Just Happened?
Behind the scenes, Torn executed an atomic transaction that:- ✅ Verified the cash session is open
- ✅ Validated product availability and stock
- ✅ Created the sale record
- ✅ Deducted inventory with FIFO/LIFO tracking
- ✅ Recorded the Kardex movement
- ✅ Processed payment method
- ✅ Assigned a fiscal folio (CAF)
- ✅ Generated the DTE XML
- ✅ Committed everything or rolled back on any error
Optional: Start the Frontend
For a complete POS experience, start the Next.js frontend:http://localhost:3000
Troubleshooting
Database connection errors
Database connection errors
Ensure PostgreSQL is running and the connection string in
.env is correct. The format is:No cash session open
No cash session open
You must open a cash session before creating sales. Use
POST /cash/open with an initial cash amount.Product not found or insufficient stock
Product not found or insufficient stock
Verify the product exists and has sufficient stock. Use
GET /products/ to list all products and GET /inventory/ to check stock levels.Authentication errors
Authentication errors
Make sure to include the JWT token in the
Authorization: Bearer TOKEN header for all protected endpoints.Next Steps
Multi-Tenancy
Learn about tenant isolation
Sales Process
Master the complete sales workflow
API Reference
Explore all endpoints