docs(residency): move BiteTrack documentation to implementation repository
- Remove project-specific documentation from backend-residency - Establish bitetrack-api (https://github.com/kiskaadee/bitetrack-api) as the single source of truth for project docs - Keep backend-residency focused on learning materials and engineering practice
This commit is contained in:
1 parent
3a7a65eeb6
commit
83f1e58318
6 files changed
-590
No files matched your search
@@ -1,90 +0,0 @@
|
|||||||
# BiteTrack Backend v2
|
|
||||||
|
|
||||||
BiteTrack Backend v2 is a REST API designed for small food businesses that manage perishable inventory.
|
|
||||||
|
|
||||||
The system centralizes customer management, inventory, sales, outstanding payments, inventory losses, and operational reporting into a unified platform, replacing fragmented spreadsheet-based workflows.
|
|
||||||
|
|
||||||
Its goal is to simplify daily operations while preserving historical business data that helps owners make better production and purchasing decisions.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Project Docs Index
|
|
||||||
|
|
||||||
[README](./README.md) \[this documment\] → What is BiteTrack?
|
|
||||||
|
|
||||||
[SRS](./SRS.md) → Software Requirement Specification: What must BiteTrack do?
|
|
||||||
|
|
||||||
[Database](./database.md) → How is the business represented?
|
|
||||||
|
|
||||||
[API Design](./api-design.md) → How is the functionality exposed?
|
|
||||||
|
|
||||||
[Architecture](architecture.md) → How is the software organized internally?
|
|
||||||
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Core Features
|
|
||||||
|
|
||||||
### Authentication & Authorization
|
|
||||||
- Secure user registration and authentication
|
|
||||||
- Role-Based Access Control (Administrator, Staff)
|
|
||||||
|
|
||||||
### Customer Management
|
|
||||||
- Customer directory
|
|
||||||
- Outstanding balance tracking
|
|
||||||
- Payment history
|
|
||||||
|
|
||||||
### Inventory Management
|
|
||||||
- Product catalog
|
|
||||||
- Categories
|
|
||||||
- Stock level management
|
|
||||||
- Inventory adjustments
|
|
||||||
- Inventory loss registration
|
|
||||||
|
|
||||||
### Sales
|
|
||||||
- Sales registration
|
|
||||||
- Payment status
|
|
||||||
- Customer association
|
|
||||||
- Automatic inventory updates
|
|
||||||
|
|
||||||
### Reporting
|
|
||||||
- Sales history
|
|
||||||
- Inventory loss history
|
|
||||||
- Customer balances
|
|
||||||
- Product performance
|
|
||||||
- Operational analytics
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Tech Stack
|
|
||||||
|
|
||||||
- Python
|
|
||||||
- FastAPI
|
|
||||||
- SQLAlchemy (Async)
|
|
||||||
- PostgreSQL
|
|
||||||
- Alembic
|
|
||||||
- pytest
|
|
||||||
- Docker
|
|
||||||
- Ruff
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Getting Started
|
|
||||||
|
|
||||||
### Prerequisites
|
|
||||||
|
|
||||||
- Docker
|
|
||||||
- Docker Compose
|
|
||||||
|
|
||||||
### Run
|
|
||||||
|
|
||||||
```bash
|
|
||||||
docker compose up --build
|
|
||||||
```
|
|
||||||
|
|
||||||
Interactive documentation:
|
|
||||||
|
|
||||||
```
|
|
||||||
http://localhost:8000/docs
|
|
||||||
```
|
|
||||||
|
|
||||||
-253
@@ -1,253 +0,0 @@
|
|||||||
# BiteTrack v2 — Software Requirements Specification (SRS)
|
|
||||||
|
|
||||||
Version: 0.1 (Draft)
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# 1. Purpose
|
|
||||||
|
|
||||||
BiteTrack is an operational management system designed for small food businesses producing and selling perishable products.
|
|
||||||
|
|
||||||
The system centralizes inventory management, customer management, sales, payment tracking, inventory loss registration, and operational reporting into a unified workflow.
|
|
||||||
|
|
||||||
Its objective is to reduce operational overhead while preserving historical business information that supports better production and inventory decisions.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# 2. Scope
|
|
||||||
|
|
||||||
The system shall provide functionality for:
|
|
||||||
|
|
||||||
- User authentication
|
|
||||||
- User authorization
|
|
||||||
- Customer management
|
|
||||||
- Product catalog management
|
|
||||||
- Category management
|
|
||||||
- Inventory management
|
|
||||||
- Sales registration
|
|
||||||
- Payment tracking
|
|
||||||
- Inventory loss registration
|
|
||||||
- Business reporting
|
|
||||||
|
|
||||||
The current version does not attempt to replace accounting or ERP software.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# 3. Stakeholders
|
|
||||||
|
|
||||||
- Business Owner
|
|
||||||
- Administrator
|
|
||||||
- Staff Member
|
|
||||||
|
|
||||||
Future versions may include customer-facing functionality.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# 4. Business Problem
|
|
||||||
|
|
||||||
Small food businesses frequently rely on multiple spreadsheets to independently manage:
|
|
||||||
|
|
||||||
- Customers
|
|
||||||
- Inventory
|
|
||||||
- Sales
|
|
||||||
- Outstanding payments
|
|
||||||
- Inventory waste
|
|
||||||
- Business reports
|
|
||||||
|
|
||||||
This fragmentation makes it difficult to answer questions such as:
|
|
||||||
|
|
||||||
- Which customers still owe money?
|
|
||||||
- Which products generate the most waste?
|
|
||||||
- How much inventory expires every week?
|
|
||||||
- Which products are most profitable?
|
|
||||||
- How much inventory should be produced tomorrow?
|
|
||||||
|
|
||||||
BiteTrack consolidates these operational workflows into a single system.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# 5. Functional Requirements
|
|
||||||
|
|
||||||
## 5.1 Identity & Access
|
|
||||||
|
|
||||||
FR-001
|
|
||||||
The system shall allow administrators to register users.
|
|
||||||
|
|
||||||
FR-002
|
|
||||||
The system shall authenticate registered users.
|
|
||||||
|
|
||||||
FR-003
|
|
||||||
The system shall enforce role-based authorization.
|
|
||||||
|
|
||||||
FR-004
|
|
||||||
The system shall allow administrators to activate or deactivate user accounts.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 5.2 Customer Management
|
|
||||||
|
|
||||||
FR-010
|
|
||||||
The system shall maintain a customer directory.
|
|
||||||
|
|
||||||
FR-011
|
|
||||||
A customer record shall contain:
|
|
||||||
|
|
||||||
- Full name
|
|
||||||
- Phone number
|
|
||||||
- Optional email address
|
|
||||||
|
|
||||||
FR-012
|
|
||||||
The system shall associate sales with customers.
|
|
||||||
|
|
||||||
FR-013
|
|
||||||
The system shall determine each customer's outstanding balance from recorded sales and payments.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 5.3 Product Management
|
|
||||||
|
|
||||||
FR-020
|
|
||||||
The system shall manage product categories.
|
|
||||||
|
|
||||||
FR-021
|
|
||||||
The system shall create, update and archive products.
|
|
||||||
|
|
||||||
FR-022
|
|
||||||
Products shall define a default shelf life.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 5.4 Inventory
|
|
||||||
|
|
||||||
FR-030
|
|
||||||
The system shall maintain current inventory levels.
|
|
||||||
|
|
||||||
FR-031
|
|
||||||
The system shall automatically decrease inventory when sales are recorded.
|
|
||||||
|
|
||||||
FR-032
|
|
||||||
The system shall allow manual registration of inventory losses.
|
|
||||||
|
|
||||||
FR-033
|
|
||||||
Inventory losses shall record a reason.
|
|
||||||
|
|
||||||
Examples include:
|
|
||||||
|
|
||||||
- Expired
|
|
||||||
- Damaged
|
|
||||||
- Quality issue
|
|
||||||
- Manual adjustment
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 5.5 Sales
|
|
||||||
|
|
||||||
FR-040
|
|
||||||
The system shall register product sales.
|
|
||||||
|
|
||||||
FR-041
|
|
||||||
A sale shall contain one or more sale items.
|
|
||||||
|
|
||||||
FR-042
|
|
||||||
The system shall calculate sale totals automatically.
|
|
||||||
|
|
||||||
FR-043
|
|
||||||
The system shall associate every sale with the staff member who created it.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 5.6 Payments
|
|
||||||
|
|
||||||
FR-050
|
|
||||||
The system shall record payments associated with a sale.
|
|
||||||
|
|
||||||
FR-051
|
|
||||||
A sale may receive multiple payments.
|
|
||||||
|
|
||||||
FR-052
|
|
||||||
The system shall calculate outstanding balances from recorded payments.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 5.7 Reporting
|
|
||||||
|
|
||||||
FR-060
|
|
||||||
Display current inventory.
|
|
||||||
|
|
||||||
FR-061
|
|
||||||
Display inventory loss history.
|
|
||||||
|
|
||||||
FR-062
|
|
||||||
Display customer balances.
|
|
||||||
|
|
||||||
FR-063
|
|
||||||
Display sales history.
|
|
||||||
|
|
||||||
FR-064
|
|
||||||
Display product performance.
|
|
||||||
|
|
||||||
FR-065
|
|
||||||
Provide historical operational reports.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# 6. Non-functional Requirements
|
|
||||||
|
|
||||||
## Performance
|
|
||||||
|
|
||||||
The system shall provide responsive interaction during normal business operations.
|
|
||||||
|
|
||||||
## Security
|
|
||||||
|
|
||||||
Passwords shall be stored using an adaptive cryptographic password hashing algorithm.
|
|
||||||
|
|
||||||
The system shall authenticate users before granting access to protected resources.
|
|
||||||
|
|
||||||
Role-based authorization shall restrict access to administrative functionality.
|
|
||||||
|
|
||||||
## Reliability
|
|
||||||
|
|
||||||
Operational data shall remain persistent and recoverable after unexpected failures.
|
|
||||||
|
|
||||||
## Maintainability
|
|
||||||
|
|
||||||
The software architecture shall support incremental feature additions with minimal impact on existing functionality.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# 7. Constraints
|
|
||||||
|
|
||||||
- Backend-first development.
|
|
||||||
- Single business deployment.
|
|
||||||
- Lightweight deployment on commodity hardware.
|
|
||||||
- Designed primarily for small food businesses.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# 8. Assumptions
|
|
||||||
|
|
||||||
- One deployment corresponds to one business.
|
|
||||||
- Inventory quantities are entered manually.
|
|
||||||
- Products belong to one category.
|
|
||||||
- Staff members authenticate before using the system.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# 9. Out of Scope
|
|
||||||
|
|
||||||
The current version does not include:
|
|
||||||
|
|
||||||
- Accounting
|
|
||||||
- Supplier management
|
|
||||||
- Payment gateway integration
|
|
||||||
- Online ordering
|
|
||||||
- Multi-tenant deployments
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
# 10. Planned Future Features
|
|
||||||
|
|
||||||
- Bootstrap initialization using a one-time deployment key.
|
|
||||||
- QR-based administrator recovery.
|
|
||||||
- Automatic inventory expiration.
|
|
||||||
- Production recommendations based on historical sales and inventory losses.
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
# Project Sprint Backlog
|
|
||||||
|
|
||||||
This is the operational TODO list for your flagship backend project.
|
|
||||||
|
|
||||||
## Currently Doing
|
|
||||||
- [x] Initialize repository with `uv`
|
|
||||||
- [x] Set up Docker Compose for local development (PostgreSQL & FastAPI)
|
|
||||||
|
|
||||||
## To Do (Backlog)
|
|
||||||
- [ ] Implement Users CRUD
|
|
||||||
- [ ] Implement Password Hashing & JWT Flow
|
|
||||||
- [ ] Implement Category & Product tables
|
|
||||||
- [ ] Implement Order placement endpoint with database transactions
|
|
||||||
- [ ] Add listing filters, sorting, and pagination
|
|
||||||
- [ ] Write integration tests for API endpoints
|
|
||||||
- [ ] Add GitHub Actions testing workflow
|
|
||||||
|
|
||||||
## Done
|
|
||||||
- [x] Create project files and folders structure
|
|
||||||
@@ -1,78 +0,0 @@
|
|||||||
# BiteTrack API Design
|
|
||||||
|
|
||||||
## Endpoint Specification
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Authentication
|
|
||||||
|
|
||||||
- `POST /auth/register` - Register a new user.
|
|
||||||
- `POST /auth/token` - Authenticate a user and issue access & refresh tokens.
|
|
||||||
- `POST /auth/refresh` - Rotate an access token using a refresh token.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Users
|
|
||||||
|
|
||||||
- `GET /users/me` - Retrieve the authenticated user's profile.
|
|
||||||
- `PATCH /users/me` - Update the authenticated user's profile.
|
|
||||||
- `GET /users` - List users (Administrator only).
|
|
||||||
- `POST /users` - Create a new staff or administrator account (Administrator only).
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Customers
|
|
||||||
|
|
||||||
- `POST /customers` - Create customer.
|
|
||||||
- `GET /customers` - List customers.
|
|
||||||
- `GET /customers/{id}` - Retrieve customer information.
|
|
||||||
- `PATCH /customers/{id}` - Update customer information.
|
|
||||||
- `DELETE /customers/{id}` - Archive customer.
|
|
||||||
- `GET /customers/{id}/balance` - Retrieve current outstanding balance.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Categories
|
|
||||||
|
|
||||||
- `POST /categories` - Create category.
|
|
||||||
- `GET /categories` - List categories.
|
|
||||||
- `GET /categories/{id}` - Retrieve category details.
|
|
||||||
- `PUT /categories/{id}` - Update category.
|
|
||||||
- `DELETE /categories/{id}` - Delete category.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Products
|
|
||||||
|
|
||||||
- `POST /products` - Create product.
|
|
||||||
- `GET /products` - List products.
|
|
||||||
- `GET /products/{id}` - Retrieve product details.
|
|
||||||
- `PUT /products/{id}` - Update product.
|
|
||||||
- `DELETE /products/{id}` - Delete product.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Sales
|
|
||||||
|
|
||||||
- `POST /sales` - Register a sale and update inventory.
|
|
||||||
- `GET /sales` - List sales.
|
|
||||||
- `GET /sales/{id}` - Retrieve sale details.
|
|
||||||
- `POST /sales/{id}/payments` - Register a payment for an existing sale.
|
|
||||||
- `GET /sales/{id}/payments` - List payments associated with a sale.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Inventory
|
|
||||||
|
|
||||||
- `POST /inventory/losses` - Register inventory loss.
|
|
||||||
- `GET /inventory/losses` - List inventory losses.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Reports
|
|
||||||
|
|
||||||
- `GET /reports/sales`
|
|
||||||
- `GET /reports/customer-balances`
|
|
||||||
- `GET /reports/inventory`
|
|
||||||
- `GET /reports/product-performance`
|
|
||||||
- `GET /reports/waste`
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
# BiteTrack Backend v2 Architecture
|
|
||||||
|
|
||||||
BiteTrack follows a layered architecture that separates HTTP concerns, data validation, business rules, and persistence.
|
|
||||||
|
|
||||||
## Core Architectural Layout
|
|
||||||
The system follows a layered architecture to decouple routing, validation, business rules, and database access.
|
|
||||||
|
|
||||||
```mermaid
|
|
||||||
graph TD
|
|
||||||
Client[Client / curl] -->|HTTP Request| Routers[FastAPI Routers]
|
|
||||||
Routers -->|Pydantic Validation| Schemas[Pydantic Schemas]
|
|
||||||
Routers -->|Service Call| Services[Business Services]
|
|
||||||
Services -->|Query / Mutate| DB[SQLAlchemy Models]
|
|
||||||
DB -->|Read/Write| Postgres[(PostgreSQL Database)]
|
|
||||||
```
|
|
||||||
|
|
||||||
## Layers
|
|
||||||
|
|
||||||
### Routers (`routers/`)
|
|
||||||
|
|
||||||
Responsible for:
|
|
||||||
|
|
||||||
- HTTP routing
|
|
||||||
- Status codes
|
|
||||||
- Dependency injection
|
|
||||||
- Authentication
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### Schemas (`schemas/`)
|
|
||||||
|
|
||||||
Responsible for:
|
|
||||||
|
|
||||||
- Request validation
|
|
||||||
- Response serialization
|
|
||||||
- API contracts
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### Services (`services/`)
|
|
||||||
|
|
||||||
Responsible for:
|
|
||||||
|
|
||||||
- Business rules
|
|
||||||
- Workflow orchestration
|
|
||||||
- Database transactions
|
|
||||||
- Coordination between repositories and domain models
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
### Models (`models/`)
|
|
||||||
|
|
||||||
Responsible for:
|
|
||||||
|
|
||||||
- Relational database mapping
|
|
||||||
- Persistence
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
# Database Design
|
|
||||||
|
|
||||||
## Planned Domain Model
|
|
||||||
|
|
||||||
```mermaid
|
|
||||||
erDiagram
|
|
||||||
|
|
||||||
USER {
|
|
||||||
uuid id PK
|
|
||||||
string email UK
|
|
||||||
string password_hash
|
|
||||||
string role
|
|
||||||
boolean is_active
|
|
||||||
datetime created_at
|
|
||||||
}
|
|
||||||
|
|
||||||
CUSTOMER {
|
|
||||||
uuid id PK
|
|
||||||
string name
|
|
||||||
string phone
|
|
||||||
string email
|
|
||||||
datetime created_at
|
|
||||||
}
|
|
||||||
|
|
||||||
CATEGORY {
|
|
||||||
uuid id PK
|
|
||||||
string name
|
|
||||||
string description
|
|
||||||
}
|
|
||||||
|
|
||||||
PRODUCT {
|
|
||||||
uuid id PK
|
|
||||||
string name
|
|
||||||
string sku UK
|
|
||||||
string description
|
|
||||||
decimal unit_price
|
|
||||||
int stock_level
|
|
||||||
int shelf_life_days
|
|
||||||
}
|
|
||||||
|
|
||||||
SALE {
|
|
||||||
uuid id PK
|
|
||||||
uuid customer_id FK
|
|
||||||
uuid created_by FK
|
|
||||||
decimal total_amount
|
|
||||||
datetime created_at
|
|
||||||
}
|
|
||||||
|
|
||||||
SALE_ITEM {
|
|
||||||
uuid id PK
|
|
||||||
uuid sale_id FK
|
|
||||||
uuid product_id FK
|
|
||||||
int quantity
|
|
||||||
decimal unit_price
|
|
||||||
}
|
|
||||||
|
|
||||||
PAYMENT {
|
|
||||||
uuid id PK
|
|
||||||
uuid sale_id FK
|
|
||||||
decimal amount
|
|
||||||
string payment_method
|
|
||||||
datetime paid_at
|
|
||||||
}
|
|
||||||
|
|
||||||
INVENTORY_LOSS {
|
|
||||||
uuid id PK
|
|
||||||
uuid product_id FK
|
|
||||||
int quantity
|
|
||||||
string reason
|
|
||||||
datetime created_at
|
|
||||||
}
|
|
||||||
|
|
||||||
CATEGORY ||--o{ PRODUCT : contains
|
|
||||||
|
|
||||||
CUSTOMER ||--o{ SALE : places
|
|
||||||
|
|
||||||
USER ||--o{ SALE : records
|
|
||||||
|
|
||||||
SALE ||--|{ SALE_ITEM : contains
|
|
||||||
|
|
||||||
SALE ||--o{ PAYMENT : receives
|
|
||||||
|
|
||||||
PRODUCT ||--o{ SALE_ITEM : sold_as
|
|
||||||
|
|
||||||
PRODUCT ||--o{ INVENTORY_LOSS : discarded
|
|
||||||
```
|
|
||||||
|
|
||||||
## Notes
|
|
||||||
|
|
||||||
- Outstanding customer balances are **derived** from sales and payments rather than stored directly.
|
|
||||||
- A sale may receive multiple payments.
|
|
||||||
- Product stock is maintained as a `stock_level` field during the initial project milestones.
|
|
||||||
- Inventory losses represent products removed from inventory without completing a sale.
|
|
||||||
- Payment status is derived (calculated field) from recorded payments rather than stored explicitly.
|
|
||||||
Reference in new issue
Block a user