This project is a modular, storage-agnostic GraphQL API gateway built with:
- FastAPI for HTTP runtime
- Strawberry GraphQL for a type-safe schema
- Pydantic v2 for model validation
- Supabase, Redis, and Firestore as interchangeable storage adapters
All data operations flow through a common interface:
class AbstractStorageAdapter:
async def get_user(self, id: str) -> UserModel: ...
async def store_user(self, user: UserModel): ...
Adapters implemented:
SupabaseAdapter
RedisAdapter
FirestoreAdapter
CachingAdapter (wraps Redis + Supabase/Firestore)
Switchable via .env config:
ini
Always show details
Copy
STORAGE_ENGINE=SUPABASE | FIRESTORE | REDIS
π§± Schema + Models
All data is modeled in app/models/ using Pydantic v2. GraphQL types are defined in app/schema/types/.
Domain Models
user User, Wallet, Profile, Reputation
snft SNFT, Transaction
auction BidHistory, Seller, PropertyDetails
trade PropertyListing, OrderFormState
index MarketplaceItem, CollectionItem
Each has a corresponding GraphQL type (UserType, WalletType, etc).
π‘ GraphQL Schema
Schema is composed from resolvers in app/schema/resolvers/, grouped by domain. You can access the interactive GraphQL playground at:
bash
Always show details
Copy
http://localhost:3000/graphql
Example query:
graphql
Always show details
Copy
query {
user(id: "abc123") {
id
firstName
wallets {
balance
}
}
}
π Auth
JWT auth middleware checks for Authorization: Bearer <token> header.
In development, unauthenticated access is allowed for:
/
/graphql (GET only)
/health
π³ Dev Setup
Install Python 3.11+
Install Poetry:
bash
Always show details
Copy
curl -sSL https://install.python-poetry.org | python3 -
Install deps:
bash
Always show details
Copy
poetry install
Run dev server:
bash
Always show details
Copy
poetry run python app/main.py
π§ͺ Tests
Tests are located under tests/ and use pytest. To run:
bash
Always show details
Copy
poetry run pytest
Adapters are mocked to test GraphQL and async flows.
π Project Structure
graphql
Always show details
Copy
app/
βββ adapters/ # Storage engines
βββ auth/ # Supabase JWT middleware
βββ models/ # Pydantic v2 schemas
βββ schema/
β βββ types/ # GraphQL types (Strawberry + Pydantic)
β βββ resolvers/ # Per-domain resolvers
β βββ schema.py # Root export
βββ main.py # FastAPI + GraphQL app
π License
MIT Β© Bridges Market Team