• Python 62.1%
  • TypeScript 37%
  • JavaScript 0.4%
  • Shell 0.3%
  • Dockerfile 0.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
yashvai14 f88915ddcb feat: catalog caching (backend Redis, mobile offline, admin warehouses)
- Backend: version-keyed read-through cache for public catalog endpoints
  (categories, products, detail, ads, home slides, offers). SQLAlchemy
  listeners bump the version after committed writes to catalog/price/stock/
  promotion tables, so changes show immediately; TTL is a backstop
  (CATALOG_CACHE_TTL_SECONDS, default 60, 0 = off). Redis errors bypass
  the cache and never serve data older than the last write.
- Mobile: persist product and category detail queries, cap stored entries,
  save when the app goes to the background.
- Admin: memoize the warehouse list, cleared on location changes.
- Tests for the cache and invalidation; docs and env examples updated.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-31 15:27:52 +05:30
.agents/skills mobile aap 2026-09-13 23:22:08 +05:30
.claude Name the clashing field on duplicate registration; allow LAN test APKs 2026-09-30 15:57:56 +05:30
.forgejo/workflows feat: referrals, delivery partners, ceil-km pricing snapshot; image validation; locked deps; base fee Rs 20 2026-10-27 15:04:10 +05:30
Admin feat: catalog caching (backend Redis, mobile offline, admin warehouses) 2026-10-31 15:27:52 +05:30
backend feat: catalog caching (backend Redis, mobile offline, admin warehouses) 2026-10-31 15:27:52 +05:30
deploy chore: move backend to api.gawachabazaar.in, remove Render references; add legal pages and inventory updates 2026-10-28 23:50:11 +05:30
docs feat: catalog caching (backend Redis, mobile offline, admin warehouses) 2026-10-31 15:27:52 +05:30
k8s Prepare AWS EKS deployment for website backend and admin 2026-10-11 13:34:40 +00:00
mobile feat: catalog caching (backend Redis, mobile offline, admin warehouses) 2026-10-31 15:27:52 +05:30
website chore: move backend to api.gawachabazaar.in, remove Render references; add legal pages and inventory updates 2026-10-28 23:50:11 +05:30
.env.aws.example feat: require delivery OTP for every delivery, auto-issue at out-for-delivery, add Admin code entry 2026-10-27 18:39:32 +05:30
.env.production.example feat: catalog caching (backend Redis, mobile offline, admin warehouses) 2026-10-31 15:27:52 +05:30
.gitattributes payment integration 2026-09-28 14:57:40 +05:30
.gitignore push notification fix 2026-10-18 19:08:46 +05:30
AGENTS.md feat: referrals, delivery partners, ceil-km pricing snapshot; image validation; locked deps; base fee Rs 20 2026-10-27 15:04:10 +05:30
docker-compose.aws.yml feat: free delivery at 10 products, product screen redesign, header cart and wishlist 2026-10-31 14:58:59 +05:30
docker-compose.prod.yml Merge forgejo/main into feat/delivery-routing-aws-prep 2026-10-31 15:01:11 +05:30
docker-compose.prod.yml.backup add 2026-10-31 09:22:23 +00:00
docker-compose.prod.yml.external-db-backup add 2026-10-31 09:22:23 +00:00
docker-compose.yml docs and inventory changes 2026-10-18 02:40:18 +05:30
linkedin-post.md admin fixes 2026-10-20 15:03:32 +05:30
package-lock.json mobile aap 2026-09-13 23:22:08 +05:30
package.json mobile aap 2026-09-13 23:22:08 +05:30
README.md feat(delivery): OSRM road-distance pricing, Redis route cache, server-authoritative checkout 2026-10-27 00:26:12 +05:30
skills-lock.json mobile aap 2026-09-13 23:22:08 +05:30

Gawacha Bazaar

Gawacha Bazaar is a farm-to-home fresh food marketplace for Nagpur: customers order vegetables, fruit and groceries on a mobile app; staff run the business from an Admin panel; one FastAPI backend owns every rule, price and state change.

Part What it is Tech Folder
Backend API The only place business logic lives. REST + one WebSocket. Python 3.11, FastAPI, SQLAlchemy 2, PostgreSQL 16, Alembic backend/
Customer app Browse, wishlist, cart, checkout, orders, bulk requests. React Native 0.86, Expo 57 + Expo Router, TanStack Query, Zustand mobile/
Admin panel Orders, products, inventory, delivery, payments, promotions, ads, staff, settings. Next.js (App Router), Tailwind Admin/
Promo website Public marketing site. Next.js website/
Deployment Docker Compose + Caddy on one VPS; Kubernetes manifests; CI workflow. Docker, Caddy, k8s deploy/, k8s/, docker-compose*.yml

Documentation map

Read this For
docs/ARCHITECTURE.md How the whole system fits together: components, auth, data flow, state machines, realtime, pricing, deployment, scaling limits.
docs/FEATURES.md Everything the product does, by audience (customer, staff/admin, system), with the rules behind each feature.
backend/README.md Backend developer guide: layout, setup, tests, migrations, configuration reference.
backend/docs/ Deep dives written phase by phase: database schemas V1-V7, per-domain API notes, RBAC, auth.
mobile/README.md Customer app guide: structure, running, API layer, design system.
Admin/README.md Admin panel guide: structure, permissions, running.
deploy/README.md Production runbook (Contabo VPS): first deploy, updates, backups, go-live checklist.
deploy/FIREBASE_AUTH.md Firebase Authentication setup.
docs/manual_testing/ Manual test scenarios.

System at a glance

 Customer app (Expo)        Admin panel (Next.js)        Promo site (Next.js)
        │  Firebase ID token       │  Firebase ID token            │
        └──────────────┬───────────┘                               │ static
                       ▼
              FastAPI backend  ── /api/v1/*  (REST)
                       │        ── /api/v1/ws/events  (live order events, staff)
                       │
   ┌───────────────────┼─────────────────────────────┐
   ▼                   ▼                             ▼
PostgreSQL 16     Firebase Admin SDK         Third parties
(all state)       (verify tokens, staff      Razorpay (payments) · Cloudinary (images)
                   accounts, resets)         Google Distance Matrix / OSRM (road distance)

Key ideas:

  • Modular monolith. One deployable backend, organised by domain (catalog, inventory, cart/orders, payments, fulfillment, promotions, ...), each as route -> service -> model.
  • The backend is the authority. Clients never compute totals, fees, discounts or status transitions; they render what the API returns. Every state machine (order, payment, fulfillment, refund, reservation, quote, promotion) is enforced server-side.
  • Firebase owns identity, the backend owns authorisation. Firebase handles passwords, Google sign-in and phone OTP. The backend verifies the Firebase ID token and maps it to a users row; roles and permissions are read live from the database on every request.
  • Everything is auditable. Admin actions write to an audit log; order/payment/refund changes keep history rows.

Repository structure

GawachaBazaar/
├── backend/                 FastAPI service
│   ├── app/
│   │   ├── api/v1/          Routers: auth, addresses, wishlist, catalog, inventory, packaging,
│   │   │                    cart, orders, payments, fulfillments, suppliers, bulk_orders,
│   │   │                    promotions, customers, staff, dashboard, ads, home_slides, bazaar, realtime
│   │   ├── core/            config, Firebase, permissions/roles, rate limiting, realtime hub, security headers
│   │   ├── db/              declarative base + session
│   │   ├── dependencies/    auth + DB FastAPI dependencies
│   │   ├── exceptions/      uniform error types and handlers
│   │   ├── models/          ~50 SQLAlchemy models
│   │   ├── schemas/         Pydantic request/response models
│   │   ├── services/        business logic + state machines
│   │   └── main.py          application factory
│   ├── alembic/versions/    35+ migrations
│   ├── tests/               pytest suite
│   └── docs/                phase documentation (api / architecture / database)
├── mobile/                  Expo customer app (app/ routes, src/ api · features · components · theme)
├── Admin/                   Next.js admin panel (app/(admin)/* pages, components, lib)
├── website/                 Next.js marketing site
├── deploy/                  Production runbook, Caddyfile, server scripts
├── k8s/                     Kubernetes manifests (backend, website, ingress, HPA)
├── docs/                    This documentation set + manual test scenarios
├── docker-compose.yml       Local stack (Postgres, backend, website)
├── docker-compose.prod.yml  Production stack (adds Caddy, admin, migrate, db-backup)
└── .forgejo/workflows/      CI/CD deploy workflow

Quick start (local)

Backend

cd backend
python -m venv venv && .\venv\Scripts\Activate.ps1      # Windows (Linux/macOS: source venv/bin/activate)
pip install -r requirements.txt -r requirements-dev.txt
cp .env.example .env                                     # set DATABASE_URL, FIREBASE_PROJECT_ID, ...
alembic upgrade head
uvicorn app.main:app --reload --host 127.0.0.1 --port 8000

Swagger UI at http://127.0.0.1:8000/docs, health at /health and /health/db. Create the first admin with python scripts/create_admin.py (see the deploy runbook).

Or run Postgres + backend in Docker: docker compose up --build -d (Postgres is published on host port 5433 to avoid clashing with a local install).

Admin panel

cd Admin && npm install && npm run dev      # http://localhost:3001

Set NEXT_PUBLIC_API_BASE_URL (default http://localhost:8000/api/v1) and the Firebase web config in .env.local.

Customer app

cd mobile && npm install && npx expo start -c     # or: npm run android

The app derives the backend URL from the Metro host automatically in development; EXPO_PUBLIC_API_BASE_URL overrides it for standalone builds. Native Firebase needs the dev client (expo run:android), not Expo Go.

Tests and checks

cd backend && python -m ruff check . && python -m pytest -v
cd mobile  && npx tsc --noEmit
cd Admin   && npx tsc --noEmit

DB-backed backend tests need a reachable test database (DATABASE_URL).

Configuration highlights

All backend settings are environment variables (backend/.env.example, .env.production.example); the full table is in backend/README.md.

Area Variables
Database DATABASE_URL
Auth FIREBASE_PROJECT_ID, FIREBASE_SERVICE_ACCOUNT_JSON
Payments RAZORPAY_KEY_ID, RAZORPAY_KEY_SECRET, RAZORPAY_WEBHOOK_SECRET
Images CLOUDINARY_*
Delivery pricing FREE_DELIVERY_MIN_ITEMS, DELIVERY_BASE_FEE, DELIVERY_PER_KM, DELIVERY_MAX_CHARGED_KM, ROUTING_PROVIDER, OSRM_BASE_URL, DELIVERY_MAX_DISTANCE_KM, DELIVERY_MIN_ORDER_VALUE, REDIS_URL, NOMINATIM_*, PACKING_POINT_* (fallback)
Bazaar+ BAZAAR_PLUS_ORDERS_REQUIRED, BAZAAR_TIMEZONE

Production

Production runs as one Docker Compose stack behind Caddy (automatic HTTPS) on a single VPS: website, admin, backend, Postgres, a migration job (must succeed before the backend starts) and a nightly pg_dump backup. See deploy/README.md. Kubernetes manifests in k8s/ and a CI workflow in .forgejo/workflows/deploy.yml are also provided.

The backend deliberately runs one worker process: the rate limiter, the WebSocket registry and the reservation sweep are in-process. Running several replicas needs a shared store (e.g. Redis) first - see docs/ARCHITECTURE.md.