Cursor rule
.cursor/rules/project-architecture.mdcCursor rules
Quality
78/100
Scores the file, not the repository.Length
1,338 words
27 headings · 2 code blocksRepository
118
— · pushed 339 days agoLast changed
3 days ago
First indexed 3 days ago.12345# 🍽️ POS System - Complete Architecture Guide67## 🎯 Project Overview89This is a **modern, enterprise-grade Point of Sale system** built with cutting-edge technologies:1011### 🏗️ Technology Stack12- **Backend:** Golang 1.21+ + Gin framework + PostgreSQL with optimized raw SQL13- **Frontend:** React 18.3+ + TanStack Start + TypeScript 5.6+ + Tailwind CSS + shadcn/ui14- **Database:** PostgreSQL 15 with comprehensive schema, indexes, and constraints15- **Infrastructure:** Docker containers with multi-stage builds and Docker Compose orchestration16- **Authentication:** JWT-based auth with role-based access control (RBAC)1718### 🚀 Core Business Features19- **Multi-Role Support:** Admin, Manager, Server, Counter, Kitchen interfaces20- **Complete Order Lifecycle:** Creation → Kitchen → Payment → Completion21- **Real-time Updates:** WebSocket-like updates across all interfaces22- **Advanced Admin Tables:** Professional data tables with sorting, filtering, pagination23- **Payment Processing:** Multi-step payment flow with receipt generation24- **Kitchen Display System:** Real-time order preparation workflow25- **Table Management:** Advanced seating and table assignment system2627## 📁 Project Structure2829### 🏠 Root Level Files30- [Makefile](mdc:Makefile) - **PRIMARY DEV TOOL** - All development commands (`make dev`, `make backup`, etc.)31- [docker-compose.dev.yml](mdc:docker-compose.dev.yml) - Development environment with hot reloading32- [docker-compose.yml](mdc:docker-compose.yml) - Production orchestration33- [README.md](mdc:README.md) - Complete project documentation with screenshots34- [ROLE_BASED_IMPLEMENTATION.md](mdc:ROLE_BASED_IMPLEMENTATION.md) - Role system implementation guide3536### 🔧 Backend Structure (`backend/`)37- [main.go](mdc:backend/main.go) - Application entry point, CORS, middleware setup38- [go.mod](mdc:backend/go.mod) - Go 1.21+ dependencies (Gin, PostgreSQL driver, JWT)39- [Dockerfile](mdc:backend/Dockerfile) + [Dockerfile.dev](mdc:backend/Dockerfile.dev) - Multi-stage container builds40- **`internal/`** - Clean Go architecture following best practices:41 - **[api/routes.go](mdc:backend/internal/api/routes.go)** - RESTful API route definitions with role-based grouping42 - **[models/models.go](mdc:backend/internal/models/models.go)** - Complete data models, DTOs, and API response structures43 - **[database/connection.go](mdc:backend/internal/database/connection.go)** - PostgreSQL connection with pooling44 - **[middleware/auth.go](mdc:backend/internal/middleware/auth.go)** - JWT authentication + RBAC middleware45 - **`handlers/`** - Domain-specific HTTP handlers:46 - [auth.go](mdc:backend/internal/handlers/auth.go) - Login, logout, user management47 - [orders.go](mdc:backend/internal/handlers/orders.go) - Complete order lifecycle management48 - [products.go](mdc:backend/internal/handlers/products.go) - Menu and category management49 - [tables.go](mdc:backend/internal/handlers/tables.go) - Table and seating management50 - [payments.go](mdc:backend/internal/handlers/payments.go) - Payment processing and history5152### ⚛️ Frontend Structure (`frontend/`)53- [package.json](mdc:frontend/package.json) - React 18.3+, TypeScript 5.6+, TanStack ecosystem54- [vite.config.ts](mdc:frontend/vite.config.ts) - Vite + TanStack Start configuration55- [tailwind.config.js](mdc:frontend/tailwind.config.js) - Tailwind CSS + shadcn/ui theme configuration56- [Dockerfile](mdc:frontend/Dockerfile) + [Dockerfile.dev](mdc:frontend/Dockerfile.dev) - Nginx + Node.js containers57- **`src/`** - Modern React application structure:58 - **[main.tsx](mdc:frontend/src/main.tsx)** - React 18 entry point with StrictMode59 - **[index.css](mdc:frontend/src/index.css)** - Global styles and CSS variables60 - **Core Architecture:**61 - **[types/index.ts](mdc:frontend/src/types/index.ts)** - Comprehensive TypeScript definitions62 - **[api/client.ts](mdc:frontend/src/api/client.ts)** - Axios-based API client with interceptors63 - **[lib/utils.ts](mdc:frontend/src/lib/utils.ts)** - Utility functions (cn, date formatters, etc.)64 - **[lib/form-schemas.ts](mdc:frontend/src/lib/form-schemas.ts)** - Zod validation schemas65 - **UI Components:**66 - **[components/ui/](mdc:frontend/src/components/ui/)** - shadcn/ui base components (Button, Card, Table, etc.)67 - **[components/forms/](mdc:frontend/src/components/forms/)** - Reusable form components with validation68 - **Business Components:**69 - **[components/admin/](mdc:frontend/src/components/admin/)** - Admin dashboard and management interfaces70 - **[components/pos/](mdc:frontend/src/components/pos/)** - POS interface components (cart, product grid, etc.)71 - **[components/kitchen/](mdc:frontend/src/components/kitchen/)** - Kitchen display system components72 - **[components/server/](mdc:frontend/src/components/server/)** - Server-specific interface components73 - **[components/counter/](mdc:frontend/src/components/counter/)** - Counter/checkout interface components74 - **Routing:**75 - **[routes/](mdc:frontend/src/routes/)** - TanStack Start file-based routing76 - **[routeTree.gen.ts](mdc:frontend/src/routeTree.gen.ts)** - Auto-generated route tree77 - **Hooks & State:**78 - **[hooks/](mdc:frontend/src/hooks/)** - Custom React hooks (pagination, toasts, keyboard shortcuts)7980### 🗄️ Database Structure (`database/`)81- **[init/01_schema.sql](mdc:database/init/01_schema.sql)** - Complete PostgreSQL schema:82 - Users with role-based access (admin, manager, server, counter, kitchen)83 - Products and categories with inventory tracking84 - Orders with full lifecycle management85 - Dining tables with occupancy status86 - Payments with multiple payment methods87 - Order status history for audit trails88 - Optimized indexes for performance89- **[init/02_seed_data.sql](mdc:database/init/02_seed_data.sql)** - Demo data for all roles and complete workflows9091### 🛠️ Scripts & Automation (`scripts/`)92- **[create-admin.sh](mdc:scripts/create-admin.sh)** - Interactive super admin creation with validation93- **[backup.sh](mdc:scripts/backup.sh)** - Production-grade system backup (database + files)94- **[restore.sh](mdc:scripts/restore.sh)** - Interactive backup restoration with safety checks95- **[db-reset.sh](mdc:scripts/db-reset.sh)** - Safe database reset with fresh schema and seed data96- **[remove-data.sh](mdc:scripts/remove-data.sh)** - Destructive data removal with multiple confirmations9798### 📚 Documentation (`docs/`)99- **[PRD.md](mdc:docs/PRD.md)** - Complete Product Requirements Document with feature specifications100- **[TODO.md](mdc:docs/TODO.md)** - Detailed project roadmap and development phases101- **[README.md](mdc:README.md)** - Beautiful project documentation with screenshots and quick start102103### ⚙️ Development Infrastructure104- **[Makefile](mdc:Makefile)** - **ESSENTIAL** - All development operations (`make help` for full list)105- **[.gitignore](mdc:.gitignore)** - Comprehensive ignore patterns for all environments106- **Docker Configuration:**107 - Development: [docker-compose.dev.yml](mdc:docker-compose.dev.yml) with hot reloading108 - Production: [docker-compose.yml](mdc:docker-compose.yml) with optimized builds109110## 🎯 Core Architectural Principles111112### 1. 🚀 API-First Design113- **RESTful APIs** - All business logic exposed through clean REST endpoints114- **Client-Server Separation** - Frontend consumes APIs, backend serves data115- **Consistent Response Format** - Standardized JSON responses with success/error patterns116- **Versioned APIs** - `/api/v1/` prefix for future-proofing117118### 2. 🔒 Type Safety & Data Integrity119- **End-to-End TypeScript** - Frontend to backend interface consistency120- **Database Constraints** - PostgreSQL constraints, foreign keys, check constraints121- **Zod Validation** - Runtime validation for forms and API requests122- **Strongly-Typed Models** - Matching data structures across all layers123124### 3. 🛡️ Security-First Architecture125- **JWT Authentication** - Stateless authentication with proper expiration126- **Role-Based Access Control (RBAC)** - Granular permissions per user role127- **SQL Injection Prevention** - Parameterized queries throughout128- **CORS Configuration** - Proper cross-origin resource sharing129- **Input Validation** - Multi-layer validation (frontend + backend + database)130131### 4. ⚡ Performance & Scalability132- **Database Optimization:**133 - Strategic indexes on frequently queried columns134 - Connection pooling for efficient resource usage135 - Proper query optimization to prevent N+1 problems136- **Frontend Optimization:**137 - React.memo and useCallback for expensive components138 - Code splitting and lazy loading139 - Optimized bundle sizes with Vite140- **Caching Strategy:**141 - HTTP caching headers for static resources142 - React Query for client-side caching143144### 5. 👥 Role-Based Architecture145- **Multi-Role Support:** Admin, Manager, Server, Counter, Kitchen146- **Role-Specific Interfaces:** Tailored UX for each role's responsibilities147- **Permission Boundaries:** API endpoints restricted by role148- **Interface Switching:** Admin can access all role interfaces149150### 6. 🔄 Real-Time Updates151- **State Synchronization** - Orders sync across all connected interfaces152- **Kitchen Display System** - Real-time order status updates153- **Payment Flow** - Live payment status across POS interfaces154155### 7. 🛠️ Developer Experience Excellence156- **🎯 Primary Development Workflow:**157```bash158 make dev # Start everything with hot reloading159 make backup # Create system backups before major changes160 make status # Check system health161 make help # See all available commands162```163- **🔐 Safety Features:**164 - Interactive scripts with confirmation prompts165 - Automatic emergency backups before destructive operations166 - Comprehensive error messages with resolution suggestions167- **🐳 Container-First Development:**168 - Consistent environments across development/production169 - Hot reloading in development containers170 - Multi-stage production builds for optimization171- **📊 Monitoring & Debugging:**172 - Comprehensive logging with structured output173 - Real-time log monitoring (`make logs`)174 - Health check endpoints for all services175176### 8. 🏗️ Clean Architecture Patterns177- **Backend:** Standard Go project layout with internal packages178- **Frontend:** Feature-based component organization179- **Database:** Normalized schema with proper relationships180- **Infrastructure:** Infrastructure as Code with Docker Compose181182## 🚀 Quick Development Commands183184Essential commands for daily development (all via Makefile):185186```bash187# 🏁 Getting Started188make dev # Start development environment189make status # Check system status190make help # Show all available commands191192# 🗄️ Database Management193make create-admin # Create admin user interactively194make db-reset # Reset to fresh database with seed data195make backup # Create complete system backup196make restore # Restore from backup (interactive)197198# 📊 Monitoring & Debugging199make logs # View all service logs200make logs-backend # View backend logs only201make logs-frontend# View frontend logs only202203# 🧹 Maintenance204make down # Stop all services205make clean # Clean up Docker resources (with confirmations)206```207208## 🎭 Demo Accounts for Testing209210| Role | Username | Password | Access Level |211|------|----------|----------|-------------|212| **👑 Admin** | `admin` | `admin123` | Full system access + beautiful admin dashboard |213| **🍽️ Server** | `server1` | `server123` | Dine-in orders only |214| **💰 Counter** | `counter1` | `counter123` | All order types + payments |215| **👨🍳 Kitchen** | `kitchen1` | `kitchen123` | Order preparation workflow |
Also in madebyaris/poinf-of-sales
Diff this repo’s formatsOne repository carrying more than one format is the comparison this product exists for: does anyone actually write different content in each file, or is one a copy of the other?
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| madebyaris/poinf-of-sales.cursor/rules/admin-interface-patterns.mdc · 118 | Cursor rules | stylearchsecurityapi+2 | 62/100 | 3 days ago | |
| madebyaris/poinf-of-sales.cursor/rules/api-patterns.mdc · 118 | Cursor rules | lint-formatstylesecuritydatabase+3 | 62/100 | 3 days ago | |
| madebyaris/poinf-of-sales.cursor/rules/authentication-and-security-patterns.mdc · 118 | Cursor rules | setupteststylesecurity+4 | 81/100 | 3 days ago | |
| madebyaris/poinf-of-sales.cursor/rules/backend-golang.mdc · 118 | Cursor rules | testlint-formatstylearch+5 | 69/100 | 3 days ago | |
| madebyaris/poinf-of-sales.cursor/rules/business-logic-patterns.mdc · 118 | Cursor rules | teststyledatabaseperformance+1 | 50/100 | 3 days ago | |
| madebyaris/poinf-of-sales.cursor/rules/database-patterns.mdc · 118 | Cursor rules | stylearchtypessecurity+2 | 62/100 | 3 days ago | |
| madebyaris/poinf-of-sales.cursor/rules/development-workflow.mdc · 118 | Cursor rules | setupbuildteststyle+3 | 86/100 | 3 days ago | |
| madebyaris/poinf-of-sales.cursor/rules/docker-deployment.mdc · 118 | Cursor rules | setupbuildteststyle+8 | 77/100 | 3 days ago | |
| madebyaris/poinf-of-sales.cursor/rules/frontend-react.mdc · 118 | Cursor rules | buildtestlint-formatstyle+4 | 69/100 | 3 days ago | |
| madebyaris/poinf-of-sales.cursor/rules/makefile-scripting.mdc · 118 | Cursor rules | setuplint-formatstylearch+2 | 81/100 | 3 days ago | |
| madebyaris/poinf-of-sales.cursor/rules/performance-optimization-patterns.mdc · 118 | Cursor rules | buildteststyledatabase+3 | 66/100 | 3 days ago | |
| madebyaris/poinf-of-sales.cursor/rules/react-native-mobile-patterns.mdc · 118 | Cursor rules | buildstylearchui+2 | 74/100 | 3 days ago | |
| madebyaris/poinf-of-sales.cursor/rules/role-based-access-patterns.mdc · 118 | Cursor rules | styletypessecuritydatabase+2 | 58/100 | 3 days ago | |
| madebyaris/poinf-of-sales.cursor/rules/tech-debt-prevention.mdc · 118 | Cursor rules | styletesting-strategyui | 50/100 | 3 days ago | |
| madebyaris/poinf-of-sales.cursor/rules/testing-patterns.mdc · 118 | Cursor rules | setupteststylearch+4 | 74/100 | 3 days ago | |
| madebyaris/poinf-of-sales.cursor/rules/user-journey-optimization.mdc · 118 | Cursor rules | styleperformanceagent-behaviour | 50/100 | 3 days ago |
Diff against .cursor/rules/admin-interface-patterns.mdc Diff against .cursor/rules/api-patterns.mdc Diff against .cursor/rules/authentication-and-security-patterns.mdc Diff against .cursor/rules/backend-golang.mdc Diff against .cursor/rules/business-logic-patterns.mdc Diff against .cursor/rules/database-patterns.mdc Diff against .cursor/rules/development-workflow.mdc Diff against .cursor/rules/docker-deployment.mdc Diff against .cursor/rules/frontend-react.mdc Diff against .cursor/rules/makefile-scripting.mdc Diff against .cursor/rules/performance-optimization-patterns.mdc Diff against .cursor/rules/react-native-mobile-patterns.mdc Diff against .cursor/rules/role-based-access-patterns.mdc Diff against .cursor/rules/tech-debt-prevention.mdc Diff against .cursor/rules/testing-patterns.mdc Diff against .cursor/rules/user-journey-optimization.mdc
Similar configs
Same format, overlapping stack, ranked by quality.
| Repository | Format | Stack | Covers | Score | Changed |
|---|---|---|---|---|---|
| hiromaily/go-crypto-wallet.cursor/rules/typescript.mdc · 126 | Cursor rules | setupbuildtestlint-format+6 | 100/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/10-hermes-api.mdc · 45 | Cursor rules | testlint-formatstylearch+5 | 100/100 | 3 days ago | |
| markstev/mark-starter.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+6 | 99/100 | 3 days ago | |
| Allymahmoud/case-intake-platform.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| dodgecfr/combatfilms-webapp.cursor/rules/frontend.mdc · 0 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| deifos/clipmira-subtitles.cursor/rules/frontend.mdc · 1 | Cursor rules | setuptestlint-formatstyle+7 | 99/100 | 3 days ago | |
| langflow-ai/langflow.cursor/rules/docs_development.mdc · 153k | Cursor rules | setupbuildtestlint-format+7 | 97/100 | 3 days ago | |
| TechSquidTV/Hermes.cursor/rules/20-hermes-api-tests.mdc · 45 | Cursor rules | teststyletesting-strategysecurity+3 | 97/100 | 3 days ago |
