Tech Stack
SnapCart is a full-stack B2C e-commerce platform. This page documents the technologies used across the backend, frontend, and infrastructure layers.
Backend
| Technology | Version | Role |
|---|---|---|
| Java | 17+ | Primary language |
| Spring Boot | 3.2.5 | Application framework |
| Spring Security | 6.x | Authentication and authorisation |
| Spring Data JPA | 3.x | ORM and database access layer |
| Hibernate | 6.x | JPA implementation |
| MySQL | 8.0+ | Relational database |
| Flyway | 10.x | Database migration and versioning |
| JWT (jjwt) | 0.12.x | Stateless authentication tokens |
| Maven | 3.9+ | Build tool and dependency management |
| Lombok | 1.18.x | Boilerplate reduction (getters, builders) |
| MapStruct | 1.5.x | DTO ↔ Entity mapping |
| ModelMapper | 3.x | Object mapping |
| ICU4J | 73.x | Internationalisation and message formatting |
| Razorpay SDK | Latest | Razorpay payment integration |
| PayPal SDK | Latest | PayPal payment integration |
| Braintree SDK | Latest | Braintree/PayTM integration |
| JavaMail | 1.6.x | SMTP email delivery |
Key Backend Packages
com.snapcart.backend— root packagecontroller— REST API controllers (202 endpoints)service— Business logic layerrepository— Spring Data JPA repositoriesentity— JPA entity classes (80+ tables)dto— Request and response DTOssecurity— JWT filter, RBAC permission evaluatorconfig— Spring configuration beansmigration— Flyway SQL migration files (305+ migrations)
Frontend
| Technology | Version | Role |
|---|---|---|
| React | 18.x | UI component library |
| TypeScript | 5.x | Type-safe JavaScript |
| Vite | 5.x | Build tool and dev server |
| React Router | 6.x | Client-side routing |
| Axios | 1.x | HTTP client for API requests |
| i18next | 23.x | Internationalisation framework |
| React i18next | 14.x | React bindings for i18next |
| Zustand | 4.x | Lightweight global state management |
| React Hook Form | 7.x | Form state and validation |
| Zod | 3.x | Schema validation |
| TailwindCSS | 3.x | Utility-first CSS framework |
| Shadcn/ui | Latest | Accessible component library |
| Radix UI | Latest | Headless accessible primitives |
| Recharts | 2.x | Admin dashboard charts |
| TipTap | 2.x | Rich-text editor (blog, pages) |
| React Query | 5.x | Server state, caching, and background sync |
Frontend Architecture
The frontend is a Single-Page Application (SPA) split into two logical portals:
- Customer Storefront (
/) — Shopping, browsing, cart, checkout, account management (47+ pages) - Admin Panel (
/admin) — Store management, RBAC-protected, 17 sections
Database
SnapCart uses MySQL 8.0 with Flyway for versioned schema management.
| Metric | Value |
|---|---|
| Total tables | 80+ |
| Flyway migrations | 305+ |
| Schema versioning | Sequential (V1__, V2__, …) |
Key tables include: users, roles, permissions, role_permissions, products, product_variants, categories, brands, attributes, orders, order_items, customers, coupons, shipping_zones, tax_rates, payments, languages, currencies.
Infrastructure
| Component | Option |
|---|---|
| Server | Any Linux server (Ubuntu 22.04 recommended) |
| File Storage | Local filesystem or AWS S3 |
| Any SMTP provider (Gmail, SendGrid, Mailgun, AWS SES) | |
| Containerisation | Docker + Docker Compose (optional) |
| Reverse Proxy | Nginx or Apache (for production) |
REST API
- Base URL:
/api/v1 - Auth: JWT Bearer token in
Authorizationheader - Format: JSON request/response bodies
- Total endpoints: 202
- Documentation: SnapCart API Reference
Authentication Flow
POST /api/v1/admin/auth/loginwith{ email, password }→ returns{ token, user }- Include
Authorization: Bearer <token>in all subsequent requests. - Tokens expire after the configured duration (default 24 hours). Re-authenticate to get a fresh token.
Customer authentication uses /api/v1/auth/login (public endpoint, no admin prefix).
Frontend State Management
The frontend uses a hybrid state approach:
| Layer | Tool | Used For |
|---|---|---|
| Server state | React Query (TanStack Query) | API data fetching, caching, background refetching, mutations |
| Global UI state | Zustand | Auth session, cart, language preference, currency, UI toggles |
| Local component state | React useState / useReducer | Form state, modal open/close, pagination |
| Form state | React Hook Form + Zod | Form validation, field errors, submit handling |
React Query patterns used
useQuery— for read-only data (product list, order detail)useMutation— for create/update/delete operations, withonSuccesscache invalidation- Query keys follow the pattern
['resource', id, filters]for granular cache control
Backend Package Structure
com.snapcart.backend
├── controller/ # REST controllers — request mapping and response shaping
├── service/ # Business logic — all application rules live here
│ └── impl/ # Service implementations
├── repository/ # Spring Data JPA repositories (one per entity)
├── entity/ # JPA @Entity classes mapped to MySQL tables
├── dto/ # Request DTOs (input) and Response DTOs (output)
│ ├── request/
│ └── response/
├── security/ # JWT filter, Spring Security config, RBAC evaluator
├── config/ # Beans: CORS, storage, mail, payment gateway clients
├── exception/ # Custom exceptions and global @ControllerAdvice handler
├── mapper/ # MapStruct interfaces for entity ↔ DTO conversion
├── enums/ # Shared enums: OrderStatus, PaymentStatus, StorageType
└── migration/ # Flyway SQL files (V1__init.sql through V305__...)
Database Schema Highlights
Key relationships in the SnapCart data model:
users ──── roles ──── role_permissions ──── permissions
products ──── product_variants ──── order_items ──── orders ──── customers
│
├── categories
├── brands
└── product_attributes ──── attributes ──── attribute_values
shipping_zones ──── shipping_rates ──── countries ──── states ──── cities
coupons ──── orders
flash_deals ──── products
Flyway manages all schema changes. Never modify tables directly — always create a new migration file (V{n+1}__description.sql) and let Flyway apply it on application startup.
Development Tooling
| Tool | Purpose |
|---|---|
| IntelliJ IDEA | Recommended IDE for backend (Spring Boot) development |
| VS Code | Recommended editor for frontend (React/TypeScript) development |
| Postman / Insomnia | API testing and exploration |
| MySQL Workbench | Database browsing and query execution |
| Docker Desktop | Local containerised environment |
| ESLint + Prettier | Frontend code linting and formatting |
| Checkstyle | Backend Java code style enforcement |
See Architecture for a system-level view and Deployment for production setup.