# ๐ŸŽจ SkyArtShop - Production-Ready Architecture **Modern, scalable full-stack web application with proper separation of concerns.** --- ## ๐Ÿ—๏ธ Architecture Overview ``` SkyArtShop/ โ”œโ”€โ”€ frontend/ # React + TypeScript + Vite โ”œโ”€โ”€ backend/ # Node.js + Express + Prisma โ”œโ”€โ”€ docs/ # Architecture documentation โ””โ”€โ”€ setup.sh # Quick start script ``` ### Frontend Stack - **React 18** - Modern UI library - **TypeScript** - Type safety - **Vite** - Lightning-fast build tool - **React Router** - Client-side routing - **Axios** - HTTP client with interceptors - **Tailwind CSS** - Utility-first styling ### Backend Stack - **Node.js + Express** - Web server - **TypeScript** - Type safety - **Prisma ORM** - Type-safe database access - **PostgreSQL** - Production database - **JWT** - Authentication - **Zod** - Request validation --- ## ๐Ÿš€ Quick Start ### Automated Setup (Recommended) ```bash ./setup.sh ``` ### Manual Setup #### 1. Install Dependencies **Frontend:** ```bash cd frontend npm install ``` **Backend:** ```bash cd backend npm install ``` #### 2. Configure Environment **Backend:** Update `backend/.env`: ```env PORT=3000 DATABASE_URL="postgresql://user:password@localhost:5432/skyartshop" JWT_SECRET=your-secret-key CORS_ORIGIN=http://localhost:5173 ``` **Frontend:** Update `frontend/.env`: ```env VITE_API_URL=http://localhost:3000/api ``` #### 3. Set Up Database ```bash cd backend npx prisma generate npx prisma migrate dev ``` #### 4. Start Development Servers **Terminal 1 - Backend:** ```bash cd backend npm run dev # Runs on http://localhost:3000 ``` **Terminal 2 - Frontend:** ```bash cd frontend npm run dev # Runs on http://localhost:5173 ``` --- ## ๐Ÿ“ Project Structure ### Frontend Structure ``` frontend/ โ”œโ”€โ”€ src/ โ”‚ โ”œโ”€โ”€ @types/ # TypeScript definitions โ”‚ โ”œโ”€โ”€ api/ # API client & endpoints โ”‚ โ”œโ”€โ”€ assets/ # Images, fonts, icons โ”‚ โ”œโ”€โ”€ components/ # Reusable UI components โ”‚ โ”œโ”€โ”€ hooks/ # Custom React hooks โ”‚ โ”œโ”€โ”€ pages/ # Page components (routes) โ”‚ โ”œโ”€โ”€ routes/ # Router configuration โ”‚ โ”œโ”€โ”€ templates/ # Page layouts โ”‚ โ”œโ”€โ”€ themes/ # Design system โ”‚ โ”œโ”€โ”€ utils/ # Helper functions โ”‚ โ”œโ”€โ”€ validators/ # Form validation โ”‚ โ”œโ”€โ”€ app.tsx # Root component โ”‚ โ””โ”€โ”€ main.tsx # Entry point โ”œโ”€โ”€ index.html โ”œโ”€โ”€ vite.config.ts โ”œโ”€โ”€ tailwind.config.ts โ””โ”€โ”€ package.json ``` ### Backend Structure ``` backend/ โ”œโ”€โ”€ prisma/ โ”‚ โ””โ”€โ”€ schema.prisma # Database schema โ”œโ”€โ”€ src/ โ”‚ โ”œโ”€โ”€ @types/ # TypeScript definitions โ”‚ โ”œโ”€โ”€ config/ # App configuration โ”‚ โ”œโ”€โ”€ controllers/ # Request handlers โ”‚ โ”œโ”€โ”€ services/ # Business logic โ”‚ โ”œโ”€โ”€ models/ # Data access layer โ”‚ โ”œโ”€โ”€ routes/ # API endpoints โ”‚ โ”œโ”€โ”€ middlewares/ # Express middleware โ”‚ โ”œโ”€โ”€ validators/ # Request validation โ”‚ โ”œโ”€โ”€ helpers/ # Utility functions โ”‚ โ””โ”€โ”€ server.ts # Entry point โ”œโ”€โ”€ tsconfig.json โ””โ”€โ”€ package.json ``` --- ## ๐Ÿ“š Documentation - **[ARCHITECTURE.md](docs/ARCHITECTURE.md)** - Complete architecture guide with examples - **[STRUCTURE_COMPLETE.md](docs/STRUCTURE_COMPLETE.md)** - Structure comparison & overview - **[frontend/readme.md](frontend/readme.md)** - Frontend documentation - **[backend/readme.md](backend/readme.md)** - Backend documentation --- ## ๐ŸŽฏ Key Features ### โœ… Frontend Features - Type-safe API client with automatic auth token injection - Custom hooks for authentication and data fetching - Protected routes with automatic redirect - Centralized theming and design system - Form validation matching backend schemas - Utility functions for formatting and validation ### โœ… Backend Features - Layered architecture (Controllers โ†’ Services โ†’ Models) - JWT authentication with middleware - Global error handling with consistent responses - Request validation with Zod schemas - Prisma ORM with type-safe queries - Security middleware (Helmet, CORS, Compression) - Request logging for debugging --- ## ๐Ÿ“ How to Add a New Feature See [docs/ARCHITECTURE.md](docs/ARCHITECTURE.md) for a complete step-by-step guide on adding the "Wishlist" feature. ### Quick Overview **Backend:** 1. Update Prisma schema 2. Create service (business logic) 3. Create controller (request handler) 4. Add routes 5. Add validation **Frontend:** 1. Add TypeScript types 2. Create API client methods 3. Create custom hook (optional) 4. Use in components --- ## ๐Ÿ” Security - JWT authentication on protected endpoints - Password hashing with bcrypt - Input validation with Zod - Security headers with Helmet - CORS configured for specific origins - SQL injection prevention via Prisma - Client-side route protection --- ## ๐Ÿงช Testing ### Frontend ```bash cd frontend npm run test:unit # Component tests npm run test:integration # Hook tests npm run test:e2e # End-to-end tests ``` ### Backend ```bash cd backend npm run test:unit # Service tests npm run test:integration # Route tests npm run test:api # API tests ``` --- ## ๐Ÿšข Deployment ### Frontend (Vercel/Netlify) ```bash cd frontend npm run build # Deploy dist/ folder ``` ### Backend (Railway/Heroku/AWS) ```bash cd backend npm run build # Set environment variables # Run: npm start ``` --- ## ๐Ÿ› ๏ธ Development Scripts ### Frontend ```bash npm run dev # Start dev server npm run build # Production build npm run preview # Preview production build npm run lint # Run linter ``` ### Backend ```bash npm run dev # Start dev server (hot reload) npm run build # Compile TypeScript npm start # Run production server npm run prisma:generate # Generate Prisma client npm run prisma:migrate # Run migrations npm run prisma:studio # Open Prisma Studio ``` --- ## ๐Ÿ“Š Tech Stack Summary | Layer | Technology | Purpose | |-------|-----------|---------| | **Frontend** | React 18 | UI framework | | | TypeScript | Type safety | | | Vite | Build tool | | | React Router | Routing | | | Axios | HTTP client | | | Tailwind CSS | Styling | | **Backend** | Node.js + Express | Server | | | TypeScript | Type safety | | | Prisma | ORM | | | PostgreSQL | Database | | | JWT | Authentication | | | Zod | Validation | | **DevOps** | Git | Version control | | | npm | Package management | | | ESLint/Biome | Code quality | --- ## ๐Ÿ’ก Why This Architecture? โœ… **Scalable**: Clear separation enables independent scaling โœ… **Maintainable**: Each file has a single, clear responsibility โœ… **Testable**: Layers can be tested in isolation โœ… **Team-Friendly**: Multiple developers work without conflicts โœ… **Production-Ready**: Security, error handling, logging built-in โœ… **Type-Safe**: TypeScript catches bugs before runtime โœ… **Industry Standard**: Follows best practices from top companies --- ## ๐Ÿค Contributing 1. Create feature branch: `git checkout -b feature/name` 2. Follow folder structure conventions 3. Add tests for new features 4. Update documentation 5. Submit pull request --- ## ๐Ÿ“ž Support - **Documentation**: See `docs/` folder - **Issues**: Check existing issues or create new one - **Questions**: Review architecture docs first --- ## ๐Ÿ“„ License [Your License Here] --- **Built with โค๏ธ using modern web technologies** ๐ŸŽ‰ **Happy coding!**