Skip to content

tanakrit-d/microPOS-API

Repository files navigation

MicroPOS Logo

microPOS: Middleware API Layer


Item API Routes

Provides an interface between the microPOS app and supabase.
Built with FastAPI, pydantic, supabase-py, and uvicorn.

Setup

Clone the repo and cd to the directory
Install the dependencies and enable the .venv with uv

uv sync

Configuration

Create a .env file as follows:

ENVIRONMENT = ""

Then, create any additional environments (such as .env.local or .env.development) as required:

API_URL = SUPABASE_URL
API_KEY = API_KEY
VERSION = 0.1.0
ENVIRONMENT = development
DEBUG = true

We'll then use .env to pass through the environment to FastAPI and Configuration.
This is because uvicorn spawns a new process, which results in the app being unable to access any Configuration object initialised at runtime.

Start

python start_app.py --env development

Docker (Not Ready)

docker build -t micropos-api
docker run --name micropos-api -d micropos-api

Local Development (Supabase CLI)

If you wish to develop locally, set up supabase-cli
You'll need to ensure you: login, link, and migration fetch.

Seeding the Database

Provided your .env files are setup, you can seed your database with start_seed.py.

Example

python start_seed.py --count 3 --env development
2024-11-11 16:57:23 - micropos-api - INFO - Config - Loading from: /Users/cool-guy/Repositories/microPOS-API/.env.development
2024-11-11 16:57:23 - micropos-api - INFO - Config - Successfully loaded environment: development
2024-11-11 16:57:23 - micropos-api - INFO - Seeder - Starting seeding process ...
2024-11-11 16:57:23 - micropos-api - INFO - Seeder - Connecting to supabase instance ...
2024-11-11 16:57:23 - micropos-api - INFO - Seeder - Initializing seeder for environment: development
2024-11-11 16:57:23 - micropos-api - INFO - Seeder - Seeding 3 item(s) ...
2024-11-11 16:57:23 - micropos-api - INFO - Seeder - Created item: title=Spicy Salad; id=ab8ca6bb-3135-4360-8fc4-ab21cc57a727;
2024-11-11 16:57:23 - micropos-api - INFO - Seeder - Created item: title=Homemade Seafood; id=49f2d0fd-c22e-4e03-8627-39c80589a53f;
2024-11-11 16:57:23 - micropos-api - INFO - Seeder - Created item: title=Homemade Rice Bowl; id=30f1ef8c-de62-424b-af5c-ed824fee7d0e;
2024-11-11 16:57:23 - micropos-api - INFO - Seeder - Successfully seeded 3 item(s) in environment: development

Task Implementation Status

Functionality

  • async client
  • environment configuration
  • database seeding
  • authentication
  • ... other things I haven't thought of

Endpoints (v1)

  • Items
    • Get by ID
    • Get All
    • Create
    • Update by ID
    • Delete
  • Categories
    • Get by ID
    • Get All
    • Create
    • Update by ID
    • Delete
  • Storage
  • Orders
  • Tables

Endpoints (v2)

  • Accounts (New/Sign-in/Reset/Delete)
  • Filtering
  • Joins

About

Middleware API with Python, FastAPI, and supabase

Resources

Stars

Watchers

Forks

Contributors