Skip to main content

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

TechnologyVersionRole
Java17+Primary language
Spring Boot3.2.5Application framework
Spring Security6.xAuthentication and authorisation
Spring Data JPA3.xORM and database access layer
Hibernate6.xJPA implementation
MySQL8.0+Relational database
Flyway10.xDatabase migration and versioning
JWT (jjwt)0.12.xStateless authentication tokens
Maven3.9+Build tool and dependency management
Lombok1.18.xBoilerplate reduction (getters, builders)
MapStruct1.5.xDTO ↔ Entity mapping
ModelMapper3.xObject mapping
ICU4J73.xInternationalisation and message formatting
Razorpay SDKLatestRazorpay payment integration
PayPal SDKLatestPayPal payment integration
Braintree SDKLatestBraintree/PayTM integration
JavaMail1.6.xSMTP email delivery

Key Backend Packages

  • com.snapcart.backend — root package
  • controller — REST API controllers (202 endpoints)
  • service — Business logic layer
  • repository — Spring Data JPA repositories
  • entity — JPA entity classes (80+ tables)
  • dto — Request and response DTOs
  • security — JWT filter, RBAC permission evaluator
  • config — Spring configuration beans
  • migration — Flyway SQL migration files (305+ migrations)

Frontend

TechnologyVersionRole
React18.xUI component library
TypeScript5.xType-safe JavaScript
Vite5.xBuild tool and dev server
React Router6.xClient-side routing
Axios1.xHTTP client for API requests
i18next23.xInternationalisation framework
React i18next14.xReact bindings for i18next
Zustand4.xLightweight global state management
React Hook Form7.xForm state and validation
Zod3.xSchema validation
TailwindCSS3.xUtility-first CSS framework
Shadcn/uiLatestAccessible component library
Radix UILatestHeadless accessible primitives
Recharts2.xAdmin dashboard charts
TipTap2.xRich-text editor (blog, pages)
React Query5.xServer 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.

MetricValue
Total tables80+
Flyway migrations305+
Schema versioningSequential (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

ComponentOption
ServerAny Linux server (Ubuntu 22.04 recommended)
File StorageLocal filesystem or AWS S3
EmailAny SMTP provider (Gmail, SendGrid, Mailgun, AWS SES)
ContainerisationDocker + Docker Compose (optional)
Reverse ProxyNginx or Apache (for production)

REST API

  • Base URL: /api/v1
  • Auth: JWT Bearer token in Authorization header
  • Format: JSON request/response bodies
  • Total endpoints: 202
  • Documentation: SnapCart API Reference

Authentication Flow

  1. POST /api/v1/admin/auth/login with { email, password } → returns { token, user }
  2. Include Authorization: Bearer <token> in all subsequent requests.
  3. 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:

LayerToolUsed For
Server stateReact Query (TanStack Query)API data fetching, caching, background refetching, mutations
Global UI stateZustandAuth session, cart, language preference, currency, UI toggles
Local component stateReact useState / useReducerForm state, modal open/close, pagination
Form stateReact Hook Form + ZodForm validation, field errors, submit handling

React Query patterns used

  • useQuery — for read-only data (product list, order detail)
  • useMutation — for create/update/delete operations, with onSuccess cache 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

ToolPurpose
IntelliJ IDEARecommended IDE for backend (Spring Boot) development
VS CodeRecommended editor for frontend (React/TypeScript) development
Postman / InsomniaAPI testing and exploration
MySQL WorkbenchDatabase browsing and query execution
Docker DesktopLocal containerised environment
ESLint + PrettierFrontend code linting and formatting
CheckstyleBackend Java code style enforcement

See Architecture for a system-level view and Deployment for production setup.