Expert guidance for LexFlow micro-SaaS platform - FastAPI backend, Next.js frontend, multi-tenant legal intake and e-signing
Expert guidance for working with LexFlow, a micro-SaaS platform for legal client intake and e-signing with multi-tenant architecture.
LexFlow is a **monorepo** with FastAPI backend and Next.js frontend designed for law firm client intake forms, e-signature workflows (DocuSign/HelloSign), payment processing (Stripe), and multi-tenant data isolation.
**Backend Structure (`backend/app/`):**
**Frontend Structure (`frontend/`):**
**Multi-Tenancy Model:**
**Starting the Development Environment:**
Use Docker (recommended):
```bash
docker-compose up -d
docker-compose logs -f [service] # View logs
```
Or run services individually:
```bash
cd backend
uvicorn app.main:app --reload --port 8000
cd frontend
npm run dev
```
**Step-by-step:**
1. Create route in `backend/app/api/v1/endpoints/[resource].py`
2. Define Pydantic schemas in `backend/app/schemas/` (request/response models)
3. Implement business logic in `backend/app/services/`
4. Include router in `backend/app/api/v1/router.py`
5. **Always filter queries by `firm_id`** to enforce multi-tenancy
**Example pattern:**
**Creating and applying migrations:**
```bash
alembic revision --autogenerate -m "description"
alembic upgrade head
alembic downgrade -1
```
**When adding new models:**
1. Create model in `backend/app/models/`
2. Import in `backend/app/models/__init__.py`
3. Run autogenerate migration
4. Apply migration
**Adding a new page:**
1. Create route in `frontend/app/[route]/page.tsx`
2. Add components in `frontend/components/`
3. Use `fetch` or HTTP client to call backend API at `NEXT_PUBLIC_API_URL`
**Patterns:**
**Backend tests:**
```bash
pytest
pytest --cov=app tests/ # With coverage
```
**Code quality checks:**
```bash
black app/ # Format
ruff check app/ # Lint
mypy app/ # Type check
```
**Backend (`.env`):**
**Frontend (`.env.local`):**
1. **Multi-tenancy enforcement:** ALWAYS filter queries by `firm_id` to prevent data leaks between firms
2. **Secret management:** Never expose Stripe secret keys or DocuSign credentials to frontend
3. **API versioning:** All endpoints under `/api/v1/` prefix
4. **Type safety:** Use Python type hints + mypy (backend), TypeScript (frontend)
**Docker:**
**Backend:**
**Frontend:**
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/lexflow-development-assistant/raw