How stoyanoff2020/bakery-crm-erp works
Project type and purpose
• This is a full-stack, multi-tenant CRM/ERP for bakery businesses, composed of three primary services (frontend, backend, AI service) plus shared libraries, orchestrated via Docker/Kubernetes, with CI/CD pipelines and monitoring.
File structure
• Top-level directories:
• packages/frontend (React/TypeScript PWA)
• packages/backend (Node.js/Express/TypeScript API)
• packages/ai-service (Python/FastAPI machine-learning endpoints)
• packages/shared (TypeScript types and utilities)
• Configuration/deployment:
• docker-compose.yml and monitoring variant
• k8s manifests under k8s/staging
• CI/CD workflows in .github/workflows
• Scripts: quick-start.sh, backup/restore scripts, comprehensive test harness
Pull architecture insights from README
• Frontend uses Vite, React Context, Tailwind CSS, PWA features.
• Backend uses Express, JWT, PostgreSQL, Swagger docs, multi-tenant via row-level security.
• AI service uses FastAPI, Scikit-learn, async endpoints.
• PostgreSQL is the central data store (single database with row-level security).
• Monitoring/backup via scripts, Prometheus/Grafana likely (docker-compose.monitoring.yml).
Main components and interactions
a. Components
1. Client (Browser/Mobile PWA)
2. Frontend App (React + Service Worker)
3. API Gateway / Load Balancer (NGINX or Cloud LB)
4. Backend Service (Express/TypeScript)
5. AI Service (FastAPI/Python)
6. Shared Type Library (consumed at build time by front/backend)
7. PostgreSQL Database (single instance or cluster)
8. CI/CD Pipeline (GitHub Actions)
9. Monitoring & Logging (Prometheus, Grafana, ELK, custom scripts)
10. External Services: SMTP/email provider, third-party analytics, optional payment gateways
b. Relationships & Data Flows
• Browser ↔ Frontend: HTTPS, JWT stored in localStorage or cookie
• Frontend ↔ API Gateway: REST calls to /api/*
• API Gateway ↔ Backend: Routes mapped to controllers, middleware for auth, rate-limit, etc.
• Backend ↔ PostgreSQL: read/write via connection pool; migrations managed by scripts
• Backend ↔ AI Service: HTTP calls to /ai-service endpoints for forecasting, optimization
• AI Service ↔ PostgreSQL: read analytics tables; populate insights
• Backend ↔ External Services: email service, audit logging, monitoring endpoints
• CI/CD → Kubernetes: automated build, test, and deploy of Docker images
c. Architectural patterns & principles
• Monorepo with Turborepo: shared code, single build root
• Micro-services / modular services: clear separation of frontend, backend, AI
• Multi-tenant via row-level security in PostgreSQL
• API-first design: OpenAPI/Swagger for backend, auto-docs for AI service
• PWA for offline support and mobile UX
• Infrastructure as Code: Docker compose for dev, Kubernetes manifests for staging/production
• Comprehensive automated testing at unit, integration, e2e, security, performance levels