E-Commerce API for Android App

This is a RESTful API backend service built on Val Town to support an Android e-commerce application. The API provides endpoints for product browsing, user authentication, cart management, payment processing, and order tracking.

API Endpoints

Authentication

  • POST /api/auth/register - Register a new user
  • POST /api/auth/login - Login and get authentication token

Products

  • GET /api/products - Get all products
  • GET /api/products/:id - Get product details
  • GET /api/products/categories - Get product categories

Cart

  • GET /api/cart - Get user's cart
  • POST /api/cart - Add item to cart
  • PUT /api/cart/:itemId - Update cart item quantity
  • DELETE /api/cart/:itemId - Remove item from cart

Orders

  • POST /api/orders - Create a new order
  • GET /api/orders - Get user's order history
  • GET /api/orders/:id - Get order details

Payment

  • POST /api/payment/process - Process payment
  • GET /api/payment/methods - Get available payment methods

Technology Stack

  • Framework: Hono (TypeScript)
  • Database: SQLite
  • Authentication: JWT
  • Payment Processing: Stripe API integration

Project Structure

├── backend/
│   ├── database/
│   │   ├── migrations.ts    # Schema definitions
│   │   └── queries.ts       # DB query functions
│   ├── routes/              # Route modules
│   │   ├── auth.ts
│   │   ├── products.ts
│   │   ├── cart.ts
│   │   ├── orders.ts
│   │   └── payment.ts
│   ├── middleware/
│   │   └── auth.ts          # Authentication middleware
│   ├── services/
│   │   └── payment.ts       # Payment processing service
│   └── index.ts             # Main entry point
└── shared/
    └── types.ts             # Shared type definitions

Getting Started

To use this API with your Android app:

  1. Set up your Android app to make HTTP requests to the API endpoints
  2. Use the authentication endpoints to manage user sessions
  3. Implement the product browsing, cart management, and checkout flows
  4. Handle payment processing through the payment endpoints

Environment Variables

The following environment variables need to be set in Val Town:

  • JWT_SECRET - Secret key for JWT token generation
  • STRIPE_SECRET_KEY - Stripe API secret key for payment processing