Skip to content

Commit 24e14d9

Browse files
authored
Merge pull request #536 from chetanr25/setup_docs
Setup docs
2 parents 21a5f08 + 6ea0039 commit 24e14d9

3 files changed

Lines changed: 192 additions & 17 deletions

File tree

CONTRIBUTING.md

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,25 +39,14 @@ If you have a great idea for FireForm, we'd love to hear it! Please open an issu
3939
4. Make sure your code lints.
4040
5. Issue that pull request!
4141

42-
## 🛠️ Local Development Setup
43-
44-
FireForm uses Docker and Docker Compose for the backend to ensure a consistent environment.
42+
**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.
4543

46-
### Prerequisites
44+
## 💬 Community
4745

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

53-
### Desktop App Development
54-
55-
The frontend is a vanilla HTML/CSS/JS app wrapped in Electron. To run it locally:
48+
## 🛠️ Local Development Setup
5649

57-
```bash
58-
cd frontend
59-
npm install # one-time setup
60-
npm start # launches the Electron desktop window
61-
```
50+
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.
6251

63-
The backend (API + Ollama) must be running separately via Docker — see `make fireform`.
52+
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.

docs/1. SETUP.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# Setup Guide
2+
3+
This guide gets the FireForm backend running locally with Docker. It assumes you are comfortable with git and a terminal, but new to this project.
4+
5+
## Prerequisites
6+
7+
- [Docker](https://docs.docker.com/get-docker/) **24 or newer**, with the Docker daemon running
8+
- Docker Compose v2 (bundled with Docker Desktop; verify with `docker compose version`)
9+
- `make`
10+
- ~3 GB of free disk space (Docker images + LLM model weights)
11+
12+
## Setup
13+
14+
### 1. Clone the repository
15+
16+
```bash
17+
git clone https://github.com/fireform-core/FireForm.git
18+
cd FireForm
19+
```
20+
21+
### 2. Run first-time setup
22+
23+
```bash
24+
make init
25+
```
26+
27+
This will:
28+
29+
1. Check that Docker meets the requirements above
30+
2. Create `docker/.env.dev` from `docker/.env.example` (gitignored; defaults work out of the box)
31+
3. Prompt you to pick an Ollama model (the default, `qwen2.5:1.5b`, is the smallest and fine for development)
32+
4. Offer to build and start everything answer `y`, or run `make fireform` later
33+
34+
### 3. Build and start (if you skipped it in step 2)
35+
36+
```bash
37+
make fireform
38+
```
39+
40+
This builds the Docker images, starts the containers, waits for Ollama, and pulls the LLM model. The first run takes several minutes (image build + model download); later runs are fast.
41+
42+
When it finishes you'll see:
43+
44+
```
45+
FireForm is ready!
46+
API: http://localhost:8000
47+
API Docs: http://localhost:8000/docs
48+
```
49+
50+
### 4. Verify it works
51+
52+
Open **http://localhost:8000/docs** in your browser. This is the interactive Swagger UI you can explore and test every API endpoint directly from there (expand an endpoint, click _Try it out_, then _Execute_).
53+
54+
## Day-to-day commands
55+
56+
| Command | What it does |
57+
| ------------ | ------------------------------------------------------------------------ |
58+
| `make up` | Start containers |
59+
| `make down` | Stop containers (data is preserved) |
60+
| `make logs` | Stream all container logs (`make logs-app` / `make logs-ollama` for one) |
61+
| `make shell` | Open a shell inside the app container |
62+
| `make test` | Run the test suite |
63+
| `make help` | List all commands |
64+
65+
The dev container mounts the source code, so code changes reload automatically — no rebuild needed. Rebuild (`make build`) only when dependencies in `requirements.txt` or the Dockerfile change.
66+
67+
## Frontend (optional)
68+
69+
The desktop/web frontend lives in a separate repository:
70+
71+
```bash
72+
git clone https://github.com/fireform-core/fireform-frontend.git
73+
```
74+
75+
Follow the README in that repository to run it. The backend from this guide must be running for the frontend to work.
76+
77+
## Troubleshooting
78+
79+
**`make init` fails dependency checks**
80+
Docker isn't running or is too old. Start Docker Desktop (or the Docker daemon) and confirm `docker version` reports 24+.
81+
82+
**Port 8000 already in use**
83+
Another process is bound to the port. Either stop it, or change `APP_PORT` in `docker/.env.dev` and run `make down && make up`.
84+
85+
**Model pull is slow or times out**
86+
The first `make fireform` downloads the LLM weights (~1 GB for the default model). On a slow connection just wait, or re-run `make pull-model` it resumes safely.
87+
88+
**Containers start but the API doesn't respond**
89+
Check `make logs-app` for the actual error. The entrypoint runs database migrations on startup, so the API takes a few seconds after the container starts.
90+
91+
**Want a clean slate**
92+
`make super-clean` stops everything and **deletes all volumes** database, uploads, and downloaded model weights. Only use it when you intend to wipe all local data.
93+
94+
## Where to go next
95+
96+
- **Join our [Discord](https://discord.gg/nBv5b6kF68)** — ask questions and coordinate with other contributors
97+
- [CONTRIBUTING.md](../CONTRIBUTING.md) - how to contribute
98+
- [PROJECT_STRUCTURE.md](2.%20PROJECT_STRUCTURE.md) - how the codebase is organized and where new code goes
99+
- [docker/README.md](../docker/README.md) - Docker layout, env vars, and volumes in detail

docs/2. PROJECT_STRUCTURE.md

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Project Structure
2+
3+
This document explains how the FireForm repository is organized and, when you add new code, where it should go.
4+
5+
## Top-level layout
6+
7+
```
8+
FireForm/
9+
├── app/ # Backend source code (FastAPI application)
10+
├── tests/ # Test suite (pytest)
11+
├── docker/ # Dockerfiles, compose files, env templates
12+
├── scripts/ # Shell scripts
13+
├── docs/ # Project documentation
14+
├── examples/ # Standalone demo scripts
15+
├── data/ # Local runtime data (gitignored contents)
16+
├── Makefile # Entry point for all dev commands (`make help`)
17+
└── requirements.txt # Python dependencies
18+
```
19+
20+
| You want to… | Go to |
21+
| -------------------------------- | ------------------------------------------------------- |
22+
| Change backend behavior | `app/` |
23+
| Add or fix tests | `tests/` |
24+
| Change container setup, env vars | `docker/` (see [docker/README.md](../docker/README.md)) |
25+
| Change setup/bootstrap scripts | `scripts/` |
26+
| Add documentation | `docs/` |
27+
| Add dev commands | `Makefile` |
28+
29+
## Inside `app/`
30+
31+
The backend follows a layered structure: **routes → services → repositories → database**. Requests enter through the API layer, business logic lives in services, and all database access goes through repositories.
32+
33+
```
34+
app/
35+
├── main.py # App factory: creates FastAPI app, wires middleware and routers
36+
├── api/ # HTTP layer - request/response handling only, no business logic
37+
│ ├── router.py # Aggregates all route modules into one router; main.py mounts this
38+
│ ├── deps.py # Shared FastAPI dependencies (e.g. DB session injection)
39+
│ ├── routes/ # One module per feature (forms.py, templates.py, …)
40+
│ └── schemas/ # Pydantic request/response models, one module per feature
41+
├── core/ # App-wide infrastructure
42+
│ ├── config.py # All settings and env var reading nothing else reads os.environ
43+
│ ├── lifespan.py # Startup/shutdown logic (DB init, etc.)
44+
│ ├── logging.py # Logging configuration
45+
│ └── errors/ # Custom exception classes (base.py) and handlers (handlers.py)
46+
├── services/ # Business logic — LLM extraction, PDF filling, orchestration
47+
├── db/ # Database engine/session (database.py) and repositories.py
48+
├── models/ # SQLAlchemy ORM models
49+
└── utils/ # Small generic helpers with no business logic
50+
```
51+
52+
### Where does my new code go?
53+
54+
**Adding a new API endpoint:**
55+
56+
1. `app/api/schemas/<...>.py` - Pydantic models for the request and response bodies
57+
2. `app/api/routes/<...>.py` - the route handlers; keep them thin, delegate to a service
58+
3. `app/api/router.py` - register the new router (one `include_router` line)
59+
4. Business logic goes in `app/services/`, not in the route handler
60+
61+
**Adding business logic:** `app/services/`. A service should not know about HTTP (no FastAPI imports) it takes plain data in and returns plain data, so it can be tested and reused independently.
62+
63+
**Adding a database table:** define the ORM model in `app/models/models.py`, and add its query/persistence functions to `app/db/repositories.py`. Services call repositories; routes never touch the database directly.
64+
65+
**Adding a setting or env var:** declare it in `app/core/config.py` and document it in `docker/.env.example`. Code elsewhere imports from `config`, never reads `os.environ` itself.
66+
67+
**Adding a custom error:** subclass in `app/core/errors/base.py`; map it to an HTTP response in `app/core/errors/handlers.py`.
68+
69+
## Tests
70+
71+
Tests live in `tests/`, run with `make test` (pytest inside the app container). `conftest.py` holds shared fixtures. Name files `test_<area>.py` and mirror what you're testing: API endpoint tests alongside `test_api.py`, model/DB tests alongside `test_model.py`.
72+
Note: Tests will be undergoing many changes hence the docs can be outdated, Please raise issue if tests or docs are outdated.
73+
74+
## Docker & scripts
75+
76+
- `docker/dev/` - development image (hot reload, source mounted) and its compose file. This is what `make up` runs.
77+
- `docker/prod/` - production image (multi-stage build, gunicorn, no source mount).
78+
- `docker/.env.example` - template for env vars; copied to `.env.dev` by `make init`.
79+
- `scripts/` - shell scripts invoked by `make init` (dependency checks, env file creation, model selection) and by container startup. Not meant to be run directly.
80+
81+
Full details: [docker/README.md](../docker/README.md).
82+
83+
## Everything else
84+
85+
- `examples/` - runnable demo scripts showing the pipeline end to end; not imported by the app.
86+
- `data/` - runtime working data on your machine; contents are not part of the codebase.
87+
- `src/`, `temp/` - scratch/legacy directories slated for cleanup; don't add new code here.

0 commit comments

Comments
 (0)