Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
ecef12c
first draft
duxbuse Jun 30, 2025
b382174
adding front end
duxbuse Jun 30, 2025
5498f79
Added backend
duxbuse Jun 30, 2025
064d0d9
its not erroring
duxbuse Jun 30, 2025
d2e815b
new and edit forms
duxbuse Jun 30, 2025
8d4ebdb
edit is working
duxbuse Jun 30, 2025
ac59f06
git ignore
duxbuse Jun 30, 2025
6ad6a58
git ignore
duxbuse Jun 30, 2025
cad5949
git ignore
duxbuse Jun 30, 2025
c7bfc89
removing cache files
duxbuse Jun 30, 2025
cccf7ba
showing input fields
duxbuse Jun 30, 2025
f481fd3
show conditionals
duxbuse Jun 30, 2025
7a378b6
readme updates
duxbuse Jun 30, 2025
bd5fd42
gitignore
duxbuse Jun 30, 2025
2398818
validation errors
duxbuse Jun 30, 2025
bae93e8
logging and only showing the other questions
duxbuse Jun 30, 2025
90d52d7
working
duxbuse Jun 30, 2025
62f50a9
smother editor
duxbuse Jun 30, 2025
88b4189
css and styling
duxbuse Jun 30, 2025
e867a00
mostly
duxbuse Jul 1, 2025
44f109b
clean
duxbuse Jul 1, 2025
8b738f4
front end updates
duxbuse Jul 1, 2025
a6ce1d2
saving word docs
duxbuse Jul 1, 2025
b699e6e
gitignore
duxbuse Jul 1, 2025
385d6ac
name and date
duxbuse Jul 1, 2025
9f31711
auto downloads
duxbuse Jul 1, 2025
ca462ca
historical search
duxbuse Jul 1, 2025
1ce1ba5
scrollable column
duxbuse Jul 1, 2025
0d7b1c7
delete submissions
duxbuse Jul 1, 2025
6060e2e
search doesnt show other clients now
duxbuse Jul 1, 2025
79f8cc4
form validation
duxbuse Jul 1, 2025
507d525
only update submission if the client name and date are the same rathe…
duxbuse Jul 1, 2025
0f96f19
titles
duxbuse Jul 1, 2025
33aa00e
Sections to the form
duxbuse Jul 2, 2025
dffb3dc
multiple sections now render properly
duxbuse Jul 2, 2025
affcc63
can now delete questions
duxbuse Jul 2, 2025
78ee86e
fixes
duxbuse Jul 2, 2025
689a1e4
collapseable
duxbuse Jul 2, 2025
7f8e229
refactored
duxbuse Jul 2, 2025
949f0d4
design doc updates
duxbuse Jul 3, 2025
64ecf56
dev container now working
duxbuse Jul 3, 2025
4703aab
dockerfile prod is building but not running
duxbuse Jul 3, 2025
7d4f14f
compose is working
duxbuse Jul 3, 2025
3fb86e9
running but not saving
duxbuse Jul 3, 2025
0d95adc
git ignore
duxbuse Jul 4, 2025
bb63a2b
local and prod settings
duxbuse Jul 4, 2025
ff6b946
save now working
duxbuse Jul 4, 2025
d59e1b6
looking great
duxbuse Jul 4, 2025
39e4eb1
sort of working
duxbuse Jul 5, 2025
29efd0a
working
duxbuse Jul 5, 2025
d6a334e
triggers question
duxbuse Jul 5, 2025
a8aa0aa
hidden triggers
duxbuse Jul 5, 2025
9f43670
can save
duxbuse Jul 5, 2025
dc56c24
can now delete
duxbuse Jul 5, 2025
87935cb
hidden questions displaying corretly
duxbuse Jul 6, 2025
b754989
no longer deleting all the questions
duxbuse Jul 6, 2025
5de73aa
no more warnings
duxbuse Jul 6, 2025
4192291
no more warnigns
duxbuse Jul 6, 2025
fddf237
better ui for triggers
duxbuse Jul 6, 2025
d7ed460
ui about which section to open
duxbuse Jul 6, 2025
5717182
adding in bail app
duxbuse Jul 6, 2025
b4ecff8
numbering the outputs in word
duxbuse Jul 14, 2025
1181c19
generating docs with names
duxbuse Jul 15, 2025
bb2c6a8
generating with names
duxbuse Jul 15, 2025
c197fd2
much closer formatting
duxbuse Jul 15, 2025
92b428e
okay
duxbuse Jul 15, 2025
37e0803
fixed myself
duxbuse Jul 16, 2025
2778dd8
added readme for the backend
duxbuse Aug 12, 2025
3877cca
added in additional sections
duxbuse Aug 13, 2025
273c44f
sas
duxbuse Aug 13, 2025
858fc90
signature added
duxbuse Aug 13, 2025
623143b
db updates
duxbuse Aug 13, 2025
ede8a4d
reorderable sections
duxbuse Aug 13, 2025
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
6 changes: 6 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
**/node_modules
**/.venv
backend/db.sqlite3
backend/submission_json
backend/form_json
*.md
39 changes: 39 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

# Python
__pycache__/
*.py[cod]
*$py.class

# Data files
backend/form_json/
backend/db.sqlite3
backend/submission_json/

backend/form_generator/static/
backend/static/
example-plea-of-guilty.docx
~$ample-plea-of-guilty.docx
50 changes: 50 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Dockerfile for the Django + Vue.js application

# --- Stage 1: Build Vue.js Frontend ---
FROM node:18-alpine AS frontend-builder

# Set working directory for the frontend
WORKDIR /app/frontend

# Copy package files and install dependencies
# Using `package-lock.json` ensures reproducible builds
COPY frontend/package.json frontend/package-lock.json* ./
RUN npm install --include=dev

# Copy the rest of the frontend source code
COPY frontend/ ./

# Build the static assets for the frontend
RUN npm run build

# --- Stage 2: Build Python Backend ---
FROM python:3.13-slim

# Set environment variables to prevent Python from writing .pyc files
ENV PYTHONDONTWRITEBYTECODE 1
# Ensure Python output is sent straight to the terminal
ENV PYTHONUNBUFFERED 1

# Set the working directory in the container
WORKDIR /app

# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

# Install Python dependencies from pyproject.toml
COPY backend/pyproject.toml backend/uv.lock ./
RUN uv add gunicorn && uv sync

# Copy the backend application code into the container
COPY backend/ .

# Copy the built frontend assets from the frontend-builder stage
# Your Django `STATICFILES_DIRS` setting should be configured to include this `/app/static` directory.
COPY --from=frontend-builder /app/frontend/dist /app/static

# Expose port 8000 to allow communication to the Gunicorn server
EXPOSE 8000

# Run the application using Gunicorn
# This command assumes your Django project's WSGI file is located at `form_generator.wsgi`.
CMD uv run ./manage.py migrate --noinput && uv run gunicorn --bind 0.0.0.0:8000 form_generator.wsgi:application
35 changes: 35 additions & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

# Development Dockerfile for Django + Vue.js with hot reloading
FROM node:24-slim

ENV PYTHONDONTWRITEBYTECODE 1
ENV PYTHONUNBUFFERED 1

WORKDIR /app

# Install uv
COPY --from=ghcr.io/astral-sh/uv:latest /uv /uvx /bin/

# Backend deps
WORKDIR /app/backend
COPY backend/.python-version ./
RUN uv python install
COPY backend/pyproject.toml backend/uv.lock ./
RUN uv sync


# Frontend deps
WORKDIR /app/frontend
COPY frontend/package.json frontend/package-lock.json* ./
RUN npm install --include=dev

WORKDIR /app

# Expose ports for Django and Vite
EXPOSE 8000 5173

# Entrypoint script for dev: runs both servers with hot reload
COPY ./dev-entrypoint.sh /app/dev-entrypoint.sh
RUN chmod +x /app/dev-entrypoint.sh

CMD ["/app/dev-entrypoint.sh"]
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,23 @@
# autosubmissions

way to easily generate submissions

run local dev

```sh
docker build -f Dockerfile.dev -t dev .
docker run -it --rm -p 8000:8000 -p 5173:5173 -v backend:/app/backend -v /app/backend/.venv -v frontend:/app/frontend -v /app/frontend/node_modules dev
```


build prod container

```sh
docker build -t prod .
```

run prod container

```sh
docker run --rm -it -p 8080:8000 prod
```
1 change: 1 addition & 0 deletions backend/.python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.13
149 changes: 149 additions & 0 deletions backend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
## How to run locally

```shell
uv run ./manage.py runserver
```

## System Architecture

This document provides a high-level overview of the system architecture, designed to help new engineers understand the codebase and contribute effectively.

### High-Level Architecture

The application is a full-stack solution composed of a Vue.js frontend and a Django backend. The backend serves a REST API for managing forms and submissions, and it also handles the generation of `.docx` documents based on submitted data.

```mermaid
graph TD
subgraph Frontend
A[Vue.js SPA]
end

subgraph Backend
B[Django REST Framework]
C[PostgreSQL Database]
D[Docx Generator]
end

A -->|API Requests| B
B -->|CRUD Operations| C
B -->|Generates| D
```

### API Endpoints

The backend exposes a REST API for managing forms and submissions. The following endpoints are available:

| Method | Endpoint | ViewSet | Description |
|--------|---------------------------|---------------------|-----------------------------------------------------|
| GET | `/api/forms/` | `FormViewSet` | Retrieve a list of all forms. |
| GET | `/api/forms/{id}/` | `FormViewSet` | Retrieve a specific form by its ID. |
| POST | `/api/forms/` | `FormViewSet` | Create a new form. |
| PUT | `/api/forms/{id}/` | `FormViewSet` | Update an existing form. |
| DELETE | `/api/forms/{id}/` | `FormViewSet` | Delete a form. |
| GET | `/api/submissions/` | `SubmissionViewSet` | Retrieve a list of all submissions. |
| GET | `/api/submissions/{id}/` | `SubmissionViewSet` | Retrieve a specific submission by its ID. |
| POST | `/api/submissions/` | `SubmissionViewSet` | Create a new submission. |
| PUT | `/api/submissions/{id}/` | `SubmissionViewSet` | Update an existing submission. |
| DELETE | `/api/submissions/{id}/` | `SubmissionViewSet` | Delete a submission. |
| GET | `/api/submissions/{id}/generate_doc/` | `SubmissionViewSet` | Generate a `.docx` document for a submission. |

### Database Schema

The database schema is designed to store forms, questions, submissions, and answers in a structured manner. The following diagram illustrates the relationships between the different models:

```mermaid
erDiagram
Form {
int id PK
string name
string description
string template_type
json template_config
json sections
}

Question {
int id PK
int form_id FK
string text
string question_type
int order
string output_template
bool hidden
int section_id
}

Option {
int id PK
int question_id FK
string text
}

Submission {
int id PK
int form_id FK
string client_honorific
string client_first_name
string client_surname
date submission_date
}

Answer {
int id PK
int submission_id FK
int question_id FK
string value
}

Form ||--o{ Question : "has"
Question ||--o{ Option : "has"
Form ||--o{ Submission : "has"
Submission ||--o{ Answer : "has"
Question ||--o{ Answer : "is for"

Question }o--o{ Question : "triggers"
Option }o--o{ Question : "triggers"
```

### Form Submission Workflow

The following sequence diagram illustrates the process of a user submitting a form, from interacting with the frontend to the data being saved in the backend.

```mermaid
sequenceDiagram
participant User
participant Frontend (Vue.js)
participant Backend (Django)
participant Database
User->>Frontend: Fills out form
Frontend->>Backend: POST /api/submissions/
Backend->>Backend: Validates submission data
alt Validation Successful
Backend->>Database: Creates Submission and Answer records
Database-->>Backend: Returns created records
Backend-->>Frontend: 201 Created
else Validation Failed
Backend-->>Frontend: 400 Bad Request with error details
end
```

### Document Generation Process

The system can generate `.docx` documents from form submissions. This process is initiated by a GET request to a specific API endpoint. The following diagram shows the workflow:

```mermaid
sequenceDiagram
participant User
participant Frontend (Vue.js)
participant Backend (Django)
participant DocGenerator
participant Database
User->>Frontend: Clicks "Generate Document"
Frontend->>Backend: GET /api/submissions/{id}/generate_doc/
Backend->>Database: Fetches Submission, Answers, and Form data
Database-->>Backend: Returns data
Backend->>DocGenerator: Initializes with submission data
DocGenerator->>DocGenerator: Builds .docx file in memory
DocGenerator-->>Backend: Returns .docx file stream
Backend-->>Frontend: Responds with the .docx file
Frontend-->>User: Prompts to download file
Binary file added backend/db.sqlite3.backup
Binary file not shown.
16 changes: 16 additions & 0 deletions backend/form_generator/asgi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
ASGI config for form_generator project.

It exposes the ASGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/5.2/howto/deployment/asgi/
"""

import os

from django.core.asgi import get_asgi_application

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "form_generator.settings")

application = get_asgi_application()
Binary file added backend/form_generator/db.sqlite3
Binary file not shown.
Loading