Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
72b03d4
refactor: restructure backend into layered app/ package
chetanr25 May 30, 2026
f4ee6fe
Updated the change of code structure layer in docker, makefile and wo…
chetanr25 May 30, 2026
f6f7180
Merge #520: restructure backend into layered app/ package
abhishek-8081 Jun 2, 2026
e260df9
fix: lint target src/ -> app/ and remove stale electron release workflow
chetanr25 Jun 2, 2026
fa7188f
fix: explicit re-export of templates and forms in routes __init__. Fi…
chetanr25 Jun 2, 2026
93a5b3a
chore: remove frontend directory, as it's migrated to fireform-fronte…
chetanr25 Jun 2, 2026
e26a0ff
chore: move scripts to scripts/ directory, fixes #517
chetanr25 Jun 2, 2026
ddd9aaf
Merge pull request #525 from chetanr25/script_migrate
abhishek-8081 Jun 3, 2026
b6527b7
chore: created docker file and compose for development envirnment
chetanr25 Jun 3, 2026
79a1ce0
chore: docker file and docker compose for prod envirnment
chetanr25 Jun 3, 2026
0bc991a
Updated Makefile: added make init command to run a project initilizat…
chetanr25 Jun 4, 2026
7c40e5f
Merge pull request #528 from chetanr25/mkFile_scripts
abhishek-8081 Jun 5, 2026
e2e0662
remove unwanted html files under docs/ which is already migrated to f…
chetanr25 Jun 5, 2026
6d9d088
Merge pull request #529 from chetanr25/delete_docs
marcvergees Jun 6, 2026
53cd5eb
Merge pull request #524 from chetanr25/rm_frontend
marcvergees Jun 6, 2026
63d176f
Merge pull request #526 from chetanr25/docker_dev
marcvergees Jun 6, 2026
8d9bbc8
Merge pull request #527 from chetanr25/docker_prod
marcvergees Jun 6, 2026
9323606
Merge pull request #523 from chetanr25/ci_cleanup
marcvergees Jun 6, 2026
a318ff9
added entrypoint, readme and updated docker file and compose
chetanr25 Jun 7, 2026
eb20a95
fixed tests, replaced api -> app.api following our current code struc…
chetanr25 Jun 7, 2026
d745498
Merge pull request #531 from chetanr25/docker_endpoint_docs
marcvergees Jun 8, 2026
21a5f08
Merge pull request #533 from chetanr25/test_fail_fix
marcvergees Jun 8, 2026
0529cfd
added setup docs, updated contributing.md
chetanr25 Jun 11, 2026
c131ee1
added project structure
chetanr25 Jun 11, 2026
6ea0039
Updated renamed file name
chetanr25 Jun 12, 2026
24e14d9
Merge pull request #536 from chetanr25/setup_docs
marcvergees Jun 14, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ jobs:

- name: Run linter
run: |
ruff check src/ --output-format=github
ruff check app/ --output-format=github
59 changes: 0 additions & 59 deletions .github/workflows/release.yml

This file was deleted.

5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,7 @@ src/inputs/*.pdf
frontend/release/

# Local Claude Code instructions
CLAUDE.md
CLAUDE.md

*temp/
*.env*
23 changes: 6 additions & 17 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,25 +39,14 @@ If you have a great idea for FireForm, we'd love to hear it! Please open an issu
4. Make sure your code lints.
5. Issue that pull request!

## 🛠️ Local Development Setup

FireForm uses Docker and Docker Compose for the backend to ensure a consistent environment.
**Issues are not formally assigned.** You are free to pick any open issue, work on it, and raise a PR directly. If multiple PRs address the same issue, the first one that actually fixes it generally gets preference. To avoid duplicating someone else's work, coordinate with other contributors on our [Discord](https://discord.gg/nBv5b6kF68) before starting.

### Prerequisites
## 💬 Community

- [Docker](https://docs.docker.com/get-docker/)
- [Docker Compose](https://docs.docker.com/compose/install/)
- `make` (optional, but recommended)
- [Node.js](https://nodejs.org/) 20+ (only needed for the desktop app)
Join our Discord server to ask questions, discuss issues, and coordinate work with other contributors: https://discord.gg/nBv5b6kF68

### Desktop App Development

The frontend is a vanilla HTML/CSS/JS app wrapped in Electron. To run it locally:
## 🛠️ Local Development Setup

```bash
cd frontend
npm install # one-time setup
npm start # launches the Electron desktop window
```
See the [Setup Guide](docs/1.%20SETUP.md) for the full walkthrough: prerequisites, running the backend with Docker, testing endpoints via Swagger UI, day-to-day commands, and troubleshooting.

The backend (API + Ollama) must be running separately via Docker — see `make fireform`.
Before writing code, read the [Project Structure](docs/2.%20PROJECT_STRUCTURE.md) guide — it explains how the codebase is organized and where new code should go.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ RUN pip install --no-cache-dir -r requirements.txt
# Copy application code
COPY . .

# All imports use api.*, src.* which require the root to be on the path
# All imports use the app.* package, which requires the root on the path
ENV PYTHONPATH=/app

# Expose FastAPI port
EXPOSE 8000

# Start the FastAPI server (not tail -f /dev/null which does nothing)
CMD ["uvicorn", "api.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
CMD ["uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000", "--reload"]
104 changes: 58 additions & 46 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
.PHONY: help build up down logs shell exec pull-model test clean fireform logs-app logs-ollama logs-frontend super-clean
.PHONY: help init fireform build up down logs logs-app logs-ollama shell pull-model test clean super-clean

# The extraction model pulled into Ollama and used by src/llm.py. Override with
# `make pull-model OLLAMA_MODEL=...`. A 1.5B model keeps per-field fills fast.
OLLAMA_MODEL ?= qwen2.5:1.5b
COMPOSE = docker compose -f docker/dev/compose.yml --env-file docker/.env.dev
ENV_DEV = docker/.env.dev

# Read OLLAMA_MODEL from .env.dev at runtime; fall back to default if file absent.
OLLAMA_MODEL = $(shell grep -E '^OLLAMA_MODEL=' $(ENV_DEV) 2>/dev/null | cut -d= -f2 | tr -d '[:space:]' || echo qwen2.5:1.5b)

help:
@printf '%s\n' \
Expand All @@ -13,74 +15,84 @@ help:
'/_/ /_//_/ \___/ /_/ \____/_/ /_/ /_/ /_/ ' \
''
@echo ""
@echo "Fireform Development Commands"
@echo "FireForm Development Commands"
@echo "=============================="
@echo "make fireform - Build and start containers, then open a shell"
@echo "make init - First-time setup: check deps, create .env.dev, pick model"
@echo "make fireform - Build images, start containers, pull Ollama model"
@echo "make build - Build Docker images"
@echo "make up - Start all containers"
@echo "make up - Start all containers (detached)"
@echo "make down - Stop all containers"
@echo "make logs - View container logs"
@echo "make logs-app - View API container logs"
@echo "make logs-frontend - View frontend container logs"
@echo "make logs-ollama - View Ollama container logs"
@echo "make shell - Open Python shell in app container"
@echo "make exec - Execute Python script in container"
@echo "make pull-model - Pull the extraction model ($(OLLAMA_MODEL)) into Ollama"
@echo "make test - Run tests"
@echo "make clean - Remove containers"
@echo "make super-clean - [CAUTION] Use carefully. Cleans up ALL stopped containers, networks, build cache..."

# Fix #382 — pull-model is now part of the main setup flow
# The extraction model is pulled automatically before you need it
fireform: build up pull-model
@echo "make logs - Stream all container logs"
@echo "make logs-app - Stream app container logs"
@echo "make logs-ollama - Stream Ollama container logs"
@echo "make shell - Open shell in running app container"
@echo "make pull-model - Pull Ollama model from .env.dev ($(OLLAMA_MODEL))"
@echo "make test - Run test suite"
@echo "make clean - Stop containers (preserves volumes)"
@echo "make super-clean - [CAUTION] Stop containers, delete volumes, prune Docker"

init:
@chmod +x scripts/check-deps.sh scripts/init-env.sh scripts/select-model.sh
@sh scripts/check-deps.sh
@sh scripts/init-env.sh
@sh scripts/select-model.sh
@printf "Build containers and pull model now? [y/N] "; \
read answer; \
case "$$answer" in \
[yY]*) $(MAKE) fireform ;; \
*) echo "Run 'make fireform' when ready." ;; \
esac

fireform: build up
@printf "Waiting for Ollama to be ready..."
@until $(COMPOSE) exec -T ollama ollama list > /dev/null 2>&1; do \
printf '.'; sleep 2; \
done
@echo " ready."
@if $(COMPOSE) exec -T ollama ollama list 2>/dev/null | grep -q "^$(OLLAMA_MODEL)"; then \
echo " Model $(OLLAMA_MODEL) already pulled."; \
else \
echo " Pulling $(OLLAMA_MODEL)..."; \
$(COMPOSE) exec -T ollama ollama pull $(OLLAMA_MODEL); \
fi
@echo ""
@echo "✅ FireForm is ready!"
@echo " Frontend: http://localhost:5173"
@echo "FireForm is ready!"
@echo " API: http://localhost:8000"
@echo " API Docs: http://localhost:8000/docs"
@echo ""
@echo "Run 'make logs' to view live logs, 'make down' to stop."

build:
docker compose build
@$(COMPOSE) build --progress=quiet

up:
docker compose up -d
@$(COMPOSE) up -d

down:
docker compose down
@$(COMPOSE) down --remove-orphans

logs:
docker compose logs -f
@$(COMPOSE) logs -f

logs-app:
docker compose logs -f app
@$(COMPOSE) logs -f app

logs-ollama:
docker compose logs -f ollama

logs-frontend:
docker compose logs -f frontend
@$(COMPOSE) logs -f ollama

shell:
docker compose exec app /bin/bash

# Start the FastAPI server inside the running container
run:
docker compose exec app uvicorn api.main:app --host 0.0.0.0 --port 8000 --reload

exec:
docker compose exec app python3 src/main.py
@$(COMPOSE) exec app /bin/sh

pull-model:
docker compose exec ollama ollama pull $(OLLAMA_MODEL)
@$(COMPOSE) exec -T ollama ollama pull $(OLLAMA_MODEL)

# Fix — correct test directory (was src/test/ which doesn't exist)
test:
docker compose exec app python3 -m pytest tests/ -v
@$(COMPOSE) exec -T app python3 -m pytest tests/ -v

clean:
docker compose down -v
@$(COMPOSE) down

super-clean:
docker compose down -v
docker system prune
@echo "WARNING: this will delete all volumes (database, uploads, model weights)."
@$(COMPOSE) down -v
@docker system prune -f
20 changes: 0 additions & 20 deletions api/db/database.py

This file was deleted.

42 changes: 0 additions & 42 deletions api/main.py

This file was deleted.

1 change: 0 additions & 1 deletion api/routes/__init__.py

This file was deleted.

8 changes: 8 additions & 0 deletions app/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"""FireForm backend application package."""

import os

# Force CPU before any service module imports torch / rfdetr. Prevents PyTorch
# from probing for NVIDIA drivers on Mac Silicon and inside Docker. Runs here so
# it is guaranteed to execute before `app.main` imports the service layer.
os.environ["CUDA_VISIBLE_DEVICES"] = ""
File renamed without changes.
2 changes: 1 addition & 1 deletion api/deps.py → app/api/deps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from api.db.database import get_session
from app.db.database import get_session

def get_db():
yield from get_session()
12 changes: 12 additions & 0 deletions app/api/router.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""Aggregates every route module into a single API router.

Add new feature routers here; main.py only mounts this one router.
"""

from fastapi import APIRouter

from app.api.routes import forms, templates

api_router = APIRouter()
api_router.include_router(templates.router)
api_router.include_router(forms.router)
3 changes: 3 additions & 0 deletions app/api/routes/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
from . import templates, forms

__all__ = ["templates", "forms"]
Loading
Loading