cd /opt/claude-workspace/L1-SERVICE/pirotehnika/pim
python3 -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
Create .env file with your database credentials:
DATABASE_HOST=91.218.142.168
DATABASE_PORT=5432
DATABASE_USER=noco
DATABASE_PASSWORD=your_password
DATABASE_NAME=nocodb_data
DATABASE_SCHEMA=pt7k98pv0fwi1el
python -m uvicorn main:app --reload --host 0.0.0.0 --port 8000
Once the service is running, check:
# Health check
curl http://localhost:8000/health
# API documentation
open http://localhost:8000/api/v1/docs
curl -X GET "http://localhost:8000/api/v1/products/НФ-00001234"
curl -X GET "http://localhost:8000/api/v1/products/?limit=10"
curl -X POST "http://localhost:8000/api/v1/pricing/calculate" \
-H "Content-Type: application/json" \
-d '{
"article": "НФ-00001234",
"markup_percent": 30
}'
bash CURL_TESTS.sh
pim/
├── api/ # FastAPI endpoints
│ ├── products.py # Product endpoints
│ └── pricing.py # Pricing endpoints
├── core/ # Business logic
│ ├── products.py # Product service
│ └── pricing.py # Pricing service
├── models/ # Database ORM models
│ ├── product.py # Product models
│ └── pricing.py # Pricing models
├── schemas/ # Pydantic validation
│ ├── product.py # Product schemas
│ └── pricing.py # Pricing schemas
├── tests/ # Test cases
│ └── test_api.py # API tests
├── config.py # Configuration
├── database.py # Database setup
└── main.py # FastAPI app
GET /products/{article} - Get productGET /products/ - List productsPOST /products/search - SearchGET /products/brand/{brand} - By brandGET /products/category/{category} - By categoryPOST /pricing/calculate - Calculate pricePOST /pricing/calculate-bulk - Bulk calculateGET /pricing/rules - List cost rulesPOST /pricing/rules - Create rulePUT /pricing/rules/{brand} - Update ruleDELETE /pricing/rules/{brand} - Delete rulecurl -X POST "http://localhost:8000/api/v1/products/search" \
-H "Content-Type: application/json" \
-d '{"query": "фейерверк", "limit": 10}'
curl "http://localhost:8000/api/v1/products/?brand=JF-Pyro&limit=20"
curl -X POST "http://localhost:8000/api/v1/pricing/rules" \
-H "Content-Type: application/json" \
-d '{
"brand": "MyBrand",
"discount_percent": 30,
"description": "My brand discount"
}'
curl -X POST "http://localhost:8000/api/v1/pricing/calculate-bulk" \
-H "Content-Type: application/json" \
-d '{
"articles": ["НФ-00001234", "НФ-00001235", "НФ-00001236"],
"markup_percent": 30
}'
python --version (should be 3.10+)pip listpsql -h HOST -U USER -d DATABASE/api/v1bash CURL_TESTS.shFor detailed documentation:
- API Reference: API_DOCUMENTATION.md
- Usage Guide: USAGE_EXAMPLES.md
- Deployment: DEPLOYMENT.md
- Implementation: IMPLEMENTATION_SUMMARY.md
# Database Connection
DATABASE_HOST=91.218.142.168
DATABASE_PORT=5432
DATABASE_USER=noco
DATABASE_PASSWORD=password
DATABASE_NAME=nocodb_data
DATABASE_SCHEMA=pt7k98pv0fwi1el
# API Configuration
API_V1_PREFIX=/api/v1
API_TITLE=PIM Service API
API_VERSION=1.0.0
LOG_LEVEL=INFO
| File | Purpose |
|---|---|
main.py |
FastAPI application entry point |
config.py |
Settings and configuration |
database.py |
Database connection and sessions |
api/products.py |
Product REST endpoints |
api/pricing.py |
Pricing REST endpoints |
core/products.py |
Product business logic |
core/pricing.py |
Pricing calculations |
models/product.py |
Product database models |
models/pricing.py |
Pricing database models |
schemas/product.py |
Product validation schemas |
schemas/pricing.py |
Pricing validation schemas |
tests/test_api.py |
API test suite |
requirements.txt |
Python dependencies |
README.md |
Project overview |
API_DOCUMENTATION.md |
API reference |
USAGE_EXAMPLES.md |
Code examples |
DEPLOYMENT.md |
Deployment guide |
CURL_TESTS.sh |
Test script |
echo=True in configEnjoy using PIM Service!