Ending furniture poverty for good — one delivery at a time.
- Tech Stack
- Project Structure
- Key Features
- Database security and Postgres tests
- Core Domains
- Design System Variables
- Documentation
- Getting Help
| Layer | Technology | Purpose |
|---|---|---|
| Frontend | Next.js 15 + TypeScript + Zustand + TanStack Query | Modern React UI with file-based routing, state management, and automatic API caching |
| Backend | FastAPI + Python + Pydantic | Async REST API with automatic OpenAPI documentation |
| Database | PostgreSQL / Supabase | Relational database |
| Build | Turbopack + Tailwind CSS | Fast builds with utility-first styling |
home-again/
├── frontend/ # Next.js React application
│ ├── app/ # App Router (file-based routing)
│ │ ├── layout.tsx # Root layout with Providers
│ │ ├── page.tsx # Home page
│ │ ├── loading.tsx # Global loading state
│ │ ├── providers.tsx # TanStack Query provider
│ │ ├── agencies/ # Agencies resource page
│ │ ├── agent-intake/ # Agent intake page
│ │ ├── component-gallery/ # Component gallery page
│ │ ├── donate/ # Donation page
│ │ └── referral-form/ # Referral form page
│ ├── common/ # Shared frontend code
│ │ ├── components/ # Reusable React components
│ │ ├── hooks/ # TanStack Query hooks (useApi.ts)
│ │ ├── stores/ # Zustand stores (auth, UI)
│ │ ├── lib/ # apiClient.ts, utils.ts
│ │ ├── types/ # TypeScript types matching backend
│ │ ├── constants/ # Config, Routes, AuthConstants
│ │ └── utils/ # CSVUtils, LocalStorageUtils
│ └── styles/ # CSS token files (colors, typography, spacing, border-radii)
│
├── backend/ # FastAPI application
│ ├── app/
│ │ ├── main.py # FastAPI app factory
│ │ ├── config.py # Environment configuration
│ │ ├── database.py # SQLAlchemy setup
│ │ ├── enums.py # StrEnum constants for all categorical fields
│ │ ├── schemas.py # Pydantic models for validation
│ │ ├── models/ # SQLAlchemy ORM models
│ │ ├── api/ # REST endpoints by resource
│ │ ├── services/ # Business logic by resource
│ │ └── utilities/ # Shared utilities (csv_utils, etc.)
│ ├── migrations/ # Alembic migrations
│ ├── tests/ # Integration tests
│ └── server.py # Uvicorn entry point
│
├── scripts/
│ └── seed_first_staff.py # First staff account seeding script
│
├── db-init/ # Database initialization scripts
├── hooks/ # Git hooks (post-merge)
├── docs/ # Documentation
│ ├── ARCHITECTURE.md # System design and data model
│ ├── BACKEND_GUIDE.md # Backend patterns, adding resources, testing
│ ├── DESIGN_SYSTEM_GUIDE.md # Design system usage and token architecture
│ ├── DOCKER.md # Docker setup guide
│ ├── FRONTEND_GUIDE.md # Frontend patterns and directory structure
│ ├── GIT.md # Git workflow and Jira integration
│ ├── ONBOARDING.md # Developer onboarding
│ ├── SCHEMA.md # Entity reference (fields, types, relationships)
│ ├── AUTH.md # Authentication reference and related scripts
│ └── TECH_DEBT.md # Technical debt inventory and remediation
├── docker-compose.yml # Multi-container setup
└── setup.sh # Project setup script
- Fully implemented backend: All 11 resources have complete CRUD — Admin, Agency, Agent, Donor, Donation, Client, Furniture, Referral, Route, Pickup, Dropoff.
- Four-layer architecture: models → schemas → services → routers. Services own all business logic; routers only translate HTTP. See docs/BACKEND_GUIDE.md.
- Type-safe: TypeScript types in
frontend/common/types/match Pydantic schemas; usecommon/lib/apiClient.tsandcommon/hooks/useApi.tsfor all API calls. - Tested: Backend integration tests use in-memory SQLite. Postgres security tests run separately when
TEST_DATABASE_URLis configured. - Documented: docs/SCHEMA.md for the full entity reference; docs/BACKEND_GUIDE.md for implementation patterns.
Every new table in the public schema must enable Row Level Security (RLS) in
the Alembic migration that creates it:
op.execute('ALTER TABLE public."new_table" ENABLE ROW LEVEL SECURITY')Public tables have no RLS policies, so ordinary Supabase API roles cannot read
or modify their rows through the REST API. Do not use FORCE ROW LEVEL SECURITY:
the backend and Alembic connect as the table owner (postgres in Supabase),
which retains access without policies. FastAPI remains responsible for checking
application permissions.
Run the usual SQLite suite from backend/ with python -m pytest -m "not postgres".
To also run the Postgres checks, configure a local test server connection:
cd backend
TEST_DATABASE_URL=postgresql://hafb_user:hafb_password@localhost:5432/postgres python -m pytestThe test role must have CREATEDB. The fixtures create a uniquely named database,
apply all Alembic migrations, and remove that database afterward; the database
named in the connection URL is only used to create and remove the test database.
Without TEST_DATABASE_URL, Postgres tests are skipped. Use python -m pytest -m postgres
with the variable set to run only these checks. They check every public
table for RLS, prove that unsecured tables are detected, verify migration rollback,
and exercise backend reads and writes against Postgres.
- Admin, Agency, Agent — staff and partner organisation management
- Donor, Donation — donor and donation lifecycle
- Client, Referral — client intake and furniture requests
- Furniture — individual item tracking from donation through delivery
- Route, Pickup, Dropoff — dispatch routing; Pickup = collection stop from donor, Dropoff = delivery stop to client
Theme variables are split into token files and wired through frontend/app/globals.css.
- Token files
frontend/styles/colors.css(semantic/brand/raw colors + dark overrides)frontend/styles/typography.css(font/typography tokens)frontend/styles/spacing.css(spacing tokens)frontend/styles/border-radii.css(border radius tokens)
- Wiring entrypoint
frontend/app/globals.cssimports token files and maps variables in@theme inline
When adding a new variable:
- Add the variable in the correct token file (for example
--status-successincolors.css). - If it needs dark mode behavior, add/override it in the
.darkblock incolors.css. - If Tailwind utility classes should expose it (for example
bg-status-success), map it infrontend/app/globals.cssinside@theme inline:--color-status-success: var(--status-success);
- Use it in UI via Tailwind utility classes or CSS variables in components.
- Run frontend checks:
cd frontend && npm run type-check && npm run lint && npm run test && npm run build
- docs/ARCHITECTURE.md — System design, data flow, and development patterns
- docs/BACKEND_GUIDE.md — Backend patterns, adding resources, testing
- docs/DESIGN_SYSTEM_GUIDE.md — Design system usage, token architecture, and component workflow
- docs/DOCKER.md — Running with Docker Compose
- docs/FRONTEND_GUIDE.md — Frontend patterns and directory structure
- docs/GIT.md — Git workflow and Jira integration
- docs/ONBOARDING.md — Developer onboarding and first tasks
- docs/SCHEMA.md — Entity reference (fields, types, relationships)
- docs/TECH_DEBT.md — Technical debt inventory and remediation tracking
New to the repo? See Developer onboarding to get the local environment running and for development workflows, tests, linting, environment variables, and troubleshooting.
- Architecture: docs/ARCHITECTURE.md
- Backend patterns: docs/BACKEND_GUIDE.md
- Entity reference: docs/SCHEMA.md
- FastAPI docs: https://fastapi.tiangolo.com/
- Next.js docs: https://nextjs.org/docs
- TanStack Query: https://tanstack.com/query/latest
- Zustand: https://zustand.docs.pmnd.rs/