A full-stack, open-source form builder and management system designed for online campaigns and registrations. Built with modern technologies including FastAPI, Next.js, PostgreSQL, and Docker.
- Dynamic Form Builder: Create forms with multiple field types
- Field Types Support: Text, Number, Boolean, Single/Multiple Select
- Form Management: Create, edit, delete, open/close forms
- Response Analytics: View and export form submissions
- User Authentication: Secure login and registration system
- Permission System: Role-based access control
- Anonymous Access: Fill forms without registration
- Session Management: Resume form filling sessions
- Real-time Validation: Client and server-side validation
- Mobile Responsive: Works on all devices
- Accessibility: Screen reader and keyboard navigation support
- Backend: FastAPI (Python 3.13+) with SQLModel
- Frontend: Next.js 15 with TypeScript and Tailwind CSS
- Database: PostgreSQL 17
- State Management: TanStack React Query
- UI Components: Shadcn/ui with Radix UI
- Authentication: Cookie-based sessions
- Containerization: Docker & Docker Compose
loslc-forms/
βββ backend/ # FastAPI backend
β βββ app/
β β βββ api/ # API routes and controllers
β β β βββ routes/v1/ # Version 1 API endpoints
β β β βββ controllers/ # Request handlers
β β β βββ dto/ # Data transfer objects
β β β βββ providers/ # Business logic
β β β βββ router.py # Route registration
β β βββ core/ # Core application modules
β β β βββ config/ # Environment configuration
β β β βββ db/ # Database models and setup
β β β βββ logging/ # Logging configuration
β β β βββ security/ # Security and permissions
β β β βββ services/ # External services
β β βββ utils/ # Utility functions
β βββ migrations/ # Alembic database migrations
β βββ main.py # Application entry point
β βββ pyproject.toml # Dependencies and configuration
βββ frontend/ # Next.js frontend
β βββ src/
β β βββ app/ # App router pages
β β β βββ admin/ # Admin dashboard
β β β βββ auth/ # Authentication pages
β β β βββ [formId]/ # Public form filling
β β βββ components/ # Reusable UI components
β β βββ lib/ # Utilities and services
β β βββ hooks/ # React Query hooks
β β βββ services/ # API service layer
β βββ package.json # Dependencies
βββ docker-compose.yml # Multi-container orchestration
- Docker and Docker Compose
- Git
git clone https://github.com/yourusername/loslc-forms.git
cd loslc-formsCreate a .env file in the root directory:
# Database
PG_USER=dbadmin
PG_PASSWORD=yourpassword
PG_DATABASE=yourdb
DB_STRING=postgresql://dbadmin:yourpassword@db:5432/yourdb
ALEMBIC_DB_URL=postgresql://dbadmin:yourpassword@db:5432/yourdb
# Ports
FRONTEND_PORT=3000
BACKEND_PORT=8000
# API URLs
NEXT_PUBLIC_API_URL=http://localhost:8000
# Debug mode
DEBUG=True
# Email (Optional)
EMAIL_APP_PASSWORD=your_email_password
APP_EMAIL_ADDRESS=your_email@example.com
EMAIL_TEMPLATES_PATH=/app/templatesdocker-compose up -d --build- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs (when DEBUG=True)
POST /api/v1/auth/register
Content-Type: application/json
{
"username": "string",
"email": "user@example.com",
"password": "string",
"password_confirm": "string",
"name": "string"
}POST /api/v1/auth/login
Content-Type: application/json
{
"email": "user@example.com",
"password": "string"
}GET /api/v1/auth/mePOST /api/v1/forms
Content-Type: application/json
{
"label": "Form Title",
"description": "Optional description"
}GET /api/v1/forms/my?skip=0&limit=10PUT /api/v1/forms/{form_id}
Content-Type: application/json
{
"label": "Updated Title",
"description": "Updated description"
}DELETE /api/v1/forms/{form_id}POST /api/v1/forms/{form_id}/open
POST /api/v1/forms/{form_id}/closePOST /api/v1/forms/{form_id}/fields
{
"label": "Field Label",
"description": "Field description",
"field_type": "Text|Numerical|Boolean|Select|Multiselect",
"required": true,
"possible_answers": "option1,option2,option3", // For Select/Multiselect
"number_bounds": "1:100", // For Numerical (min:max)
"text_bounds": "5:200" // For Text (min_length:max_length)
}PUT /api/v1/forms/fields/{field_id}
{
"label": "Updated Label",
"description": "Updated description",
"required": false
}DELETE /api/v1/forms/fields/{field_id}GET /api/v1/forms/{form_id}GET /api/v1/forms/{form_id}/fieldsPOST /api/v1/forms/responses
Content-Type: application/json
{
"field_id": "uuid",
"value": "response_value"
}PUT /api/v1/forms/responses/{answer_id}
Content-Type: application/json
{
"value": "updated_value"
}POST /api/v1/forms/sessions/submitGET /api/v1/forms/{form_id}/responses?skip=0&limit=10- Python 3.13+
- UV package manager (recommended)
cd backend
pip install uv
uv sync
# Run database migrations
uv run alembic upgrade head
# Start development server
uv run main.pyDB_STRING=postgresql://user:password@localhost:5432/dbname
DEBUG=True- Node.js 18+
- Bun (recommended) or npm/yarn
cd frontend
# Install dependencies
bun install
# Start development server
bun run devNEXT_PUBLIC_API_URL=http://localhost:8000- Cookie-based Sessions: Secure HTTP-only cookies
- Role-based Access Control: Admin and user roles
- Permission System: Resource-level permissions
- Input Validation: Client and server-side validation
- SQL Injection Prevention: SQLModel/SQLAlchemy ORM
- XSS Protection: React's built-in XSS protection
- CORS Configuration: Properly configured CORS policies
- Anonymous Form Filling: No registration required for respondents
- Session Management: Temporary sessions for form filling
- Data Encryption: Sensitive data encryption at rest
CREATE TABLE user (
id VARCHAR PRIMARY KEY,
email VARCHAR UNIQUE NOT NULL,
username VARCHAR NOT NULL,
hashed_password VARCHAR NOT NULL,
name VARCHAR NOT NULL
);CREATE TABLE form (
id UUID PRIMARY KEY,
user_id VARCHAR REFERENCES user(id),
label VARCHAR NOT NULL,
description TEXT,
open BOOLEAN DEFAULT FALSE
);CREATE TABLE formfield (
id UUID PRIMARY KEY,
form_id UUID REFERENCES form(id),
label VARCHAR NOT NULL,
description TEXT NOT NULL,
field_type VARCHAR NOT NULL, -- Text, Numerical, Boolean, Select, Multiselect
required BOOLEAN DEFAULT TRUE,
possible_answers TEXT, -- For Select/Multiselect
number_bounds VARCHAR, -- min:max for Numerical
text_bounds VARCHAR -- min_length:max_length for Text
);CREATE TABLE answersession (
id UUID PRIMARY KEY,
form_id UUID REFERENCES form(id),
submitted BOOLEAN DEFAULT FALSE
);CREATE TABLE fieldanswer (
id UUID PRIMARY KEY,
field_id UUID REFERENCES formfield(id),
session_id UUID REFERENCES answersession(id),
value TEXT
);- Validation: Min/max length bounds
- Format:
text_bounds: "5:200"(min 5, max 200 characters) - Use Cases: Names, descriptions, comments
- Validation: Min/max value bounds
- Format:
number_bounds: "1:100"(min 1, max 100) - Use Cases: Age, quantity, ratings
- Type: Checkbox
- Values:
trueorfalse - Use Cases: Agreements, yes/no questions
- Type: Dropdown (single selection)
- Format:
possible_answers: "option1,option2,option3" - Use Cases: Country selection, categories
- Type: Checkbox group (multiple selections)
- Format:
possible_answers: "option1,option2,option3" - Use Cases: Skills, interests, preferences
- Admin Login: Authenticate to access admin panel
- Create Form: Set title and description
- Add Fields: Configure field types and validation
- Open Form: Make form available for responses
- Monitor: View real-time response analytics
- Access Form: Visit public form URL
- Fill Fields: Complete required and optional fields
- Validate: Real-time validation feedback
- Submit: Submit complete form response
- Confirmation: Receive submission confirmation
# Build and start production containers
docker-compose up -d --buildDEBUG=False
DB_STRING=postgresql://user:password@db:5432/dbname
NEXT_PUBLIC_API_URL=https://api.yourdomain.com- Fork the Repository
- Create Feature Branch:
git checkout -b feature/amazing-feature - Commit Changes:
git commit -m 'Add amazing feature' - Push to Branch:
git push origin feature/amazing-feature - Open Pull Request
- Follow PEP 8 for Python code
- Use TypeScript for frontend development
- Update documentation for API changes
This project is licensed under the MIT License - see the LICENSE file for details.
For support, questions, or feature requests:
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Email: support@loslc.tech
Built with β€οΈ by and for the Linux & Open-Source Lovers community