Skip to content

Commit ef90c6a

Browse files
committed
C360 Fashion Retail demo setup with Docker Compose, Postgres schema, and CSV data seeding
1 parent 148e13c commit ef90c6a

File tree

91 files changed

+775203
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+775203
-1
lines changed
Lines changed: 206 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,206 @@
1+
# C360 Retail Fashion Database Setup
2+
3+
Complete standalone database setup for the C360 Retail Fashion analytics platform.
4+
5+
## 🚀 Quick Start
6+
7+
### Prerequisites
8+
- Docker and Docker Compose installed
9+
- At least 4GB available RAM
10+
- Port 5433 and 8080 available (connects to existing axiomretailfashion_postgres)
11+
12+
### 1. Start the Database
13+
```bash
14+
cd .data/c360-retail-fashion
15+
docker-compose up -d
16+
```
17+
18+
This will:
19+
- ✅ Connect to existing PostgreSQL database on port `5433` (axiomretailfashion_postgres)
20+
- ✅ Reference the `retail_fashion` database with complete schema and data
21+
- ✅ Start PgAdmin web interface on port `8080`
22+
23+
### 2. Access the Database
24+
25+
**Direct PostgreSQL Connection:**
26+
```bash
27+
# Connect via psql (to existing database)
28+
psql -h localhost -p 5433 -U postgres -d retail_fashion
29+
30+
# Connection details:
31+
Host: localhost
32+
Port: 5433
33+
Database: retail_fashion
34+
Username: postgres
35+
Password: hbGciOiJIUzI1NiIsInR5cCI6IkpX (from existing setup)
36+
```
37+
38+
**Web Interface (PgAdmin):**
39+
- URL: http://localhost:8080
40+
41+
- Password: admin
42+
43+
## 📊 Database Contents
44+
45+
### Core Tables (with data)
46+
- `brands` - Fashion brands (30-50 records)
47+
- `categories` - Product categories with hierarchy
48+
- `products` - Product catalog (500-1000 products)
49+
- `product_variants` - Size/color variants (3k-6k records)
50+
- `customers` - Customer profiles (50,000 customers)
51+
- `customer_addresses` - Customer shipping addresses
52+
- `orders` - Order transactions (120k-150k orders)
53+
- `order_items` - Line items for orders
54+
- `returns` - Return requests and processing
55+
- `return_items` - Individual returned items
56+
- `reviews` - Product reviews with ratings
57+
- `social_mentions` - Social media interactions
58+
- `website_sessions` - Web analytics sessions
59+
- `style_similarity_matches` - ML recommendation data
60+
61+
### Analytics Views
62+
```sql
63+
-- View table row counts
64+
SELECT * FROM table_row_counts;
65+
66+
-- Sample queries
67+
SELECT COUNT(*) FROM customers WHERE account_status = 'active';
68+
SELECT brand, COUNT(*) FROM products GROUP BY brand ORDER BY count DESC;
69+
SELECT * FROM style_similarity_matches LIMIT 10;
70+
```
71+
72+
## 🔄 Data Generation
73+
74+
### Generate Fresh Data
75+
```bash
76+
# Generate new dataset (optional)
77+
cd .data/c360-retail-fashion
78+
python3 generate_complete_dataset.py
79+
80+
# Restart database to load new data
81+
docker-compose down
82+
docker-compose up -d
83+
```
84+
85+
### Manual Data Loading
86+
```bash
87+
# If you need to reload data manually
88+
docker exec -i axiomretailfashion_postgres psql -U postgres -d retail_fashion < sql/load_data.sql
89+
```
90+
91+
## 🛠️ Customization
92+
93+
### Change Database Credentials
94+
Edit `compose.yaml`:
95+
```yaml
96+
environment:
97+
POSTGRES_DB: your_database_name
98+
POSTGRES_USER: your_username
99+
POSTGRES_PASSWORD: your_password
100+
```
101+
102+
### Add Custom Tables
103+
1. Add schema to `sql/schema.sql`
104+
2. Add data loading to `sql/load_data.sql`
105+
3. Restart: `docker-compose down && docker-compose up -d`
106+
107+
### External Database Server
108+
Use the SQL files with any PostgreSQL server:
109+
```bash
110+
# On your PostgreSQL server
111+
createdb retail_fashion
112+
psql -d retail_fashion -f sql/schema.sql
113+
psql -d retail_fashion -f sql/load_data.sql
114+
```
115+
116+
## 📁 File Structure
117+
```
118+
.data/c360-retail-fashion/
119+
├── compose.yaml # Docker Compose setup
120+
├── sql/
121+
│ ├── schema.sql # Complete database schema
122+
│ └── load_data.sql # Data loading script
123+
├── postgres/ # CSV data files
124+
│ ├── brands.csv
125+
│ ├── customers.csv
126+
│ ├── products.csv
127+
│ └── ... (all data files)
128+
├── generate_complete_dataset.py # Data generator
129+
└── README.md # This file
130+
```
131+
132+
## 🔧 Troubleshooting
133+
134+
### Database Won't Start
135+
```bash
136+
# Check if port 5433 is available
137+
lsof -i :5433
138+
139+
# View logs
140+
docker-compose logs postgres
141+
```
142+
143+
### Data Loading Issues
144+
```bash
145+
# Check data loading logs
146+
docker-compose logs postgres | grep COPY
147+
148+
# Manual verification
149+
docker exec -it axiomretailfashion_postgres psql -U postgres -d retail_fashion -c "SELECT * FROM table_row_counts;"
150+
```
151+
152+
### Reset Everything
153+
```bash
154+
# Complete reset
155+
docker-compose down -v # Removes volumes
156+
docker-compose up -d # Fresh start
157+
```
158+
159+
## 📈 Performance Optimization
160+
161+
The database includes optimized indexes:
162+
- Product searches: `brand`, `category_l1`
163+
- Customer lookups: `email`
164+
- Order queries: `customer_id`, `order_date`
165+
- Analytics: `style_similarity_matches` indexes
166+
- Review analysis: `customer_id`, `product_id`
167+
168+
## 🔐 Security Notes
169+
170+
**⚠️ This is a development setup with default credentials!**
171+
172+
For production:
173+
1. Change all default passwords
174+
2. Use environment variables for credentials
175+
3. Enable SSL/TLS connections
176+
4. Restrict network access
177+
5. Regular backups
178+
179+
## 💾 Backup & Restore
180+
181+
### Backup
182+
```bash
183+
# Full database backup
184+
docker exec axiomretailfashion_postgres pg_dump -U postgres retail_fashion > backup.sql
185+
186+
# Data-only backup
187+
docker exec axiomretailfashion_postgres pg_dump -U postgres --data-only retail_fashion > data_backup.sql
188+
```
189+
190+
### Restore
191+
```bash
192+
# Restore from backup
193+
docker exec -i axiomretailfashion_postgres psql -U postgres retail_fashion < backup.sql
194+
```
195+
196+
## 📞 Support
197+
198+
This database setup provides a complete C360 retail analytics platform with:
199+
- ✅ 28 tables with proper relationships
200+
- ✅ 700k+ total records across all tables
201+
- ✅ ML recommendation system data
202+
- ✅ Complete customer journey tracking
203+
- ✅ Social media and web analytics
204+
- ✅ Returns and review management
205+
206+
Perfect for development, testing, demos, and analytics experimentation!
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
version: '3.8'
2+
3+
services:
4+
postgres:
5+
image: postgres:15
6+
container_name: axiomretailfashion_postgres
7+
environment:
8+
POSTGRES_DB: retail_fashion
9+
POSTGRES_USER: postgres
10+
POSTGRES_PASSWORD: postgres
11+
ports:
12+
- "5433:5432"
13+
volumes:
14+
- postgres_data:/var/lib/postgresql/data
15+
- ./postgres:/docker-entrypoint-initdb.d
16+
- ./sql/schema.sql:/docker-entrypoint-initdb.d/01-schema.sql
17+
- ./sql/load_data.sql:/docker-entrypoint-initdb.d/02-load_data.sql
18+
healthcheck:
19+
test: ["CMD-SHELL", "pg_isready -U postgres"]
20+
interval: 5s
21+
timeout: 5s
22+
retries: 5
23+
24+
pgadmin:
25+
image: dpage/pgadmin4:latest
26+
container_name: axiomretailfashion_pgadmin
27+
environment:
28+
PGADMIN_DEFAULT_EMAIL: [email protected]
29+
PGADMIN_DEFAULT_PASSWORD: admin
30+
ports:
31+
- "8080:80"
32+
depends_on:
33+
- postgres
34+
35+
volumes:
36+
postgres_data:

0 commit comments

Comments
 (0)