Build beautiful forms effortlessly with drag & drop, AI, and real-time analytics π
- User Management: Secure user registration and JWT-based authentication.
- Dynamic Forms: Define complex form structures with various field types (text, email, multiple choice, etc.) via JSON.
- Form CRUD: Full Create, Read, Update, and Delete operations for forms, restricted to owners.
- Response Handling: Submit responses to forms and retrieve collected responses (owner-only access).
- Asynchronous: Built with
asyncio,FastAPI, andSQLAlchemy's async support for high performance. - Data Validation: Leverages Pydantic for robust request and response data validation.
- Database Migrations: Uses Alembic for managing database schema changes.
- Dependency Injection: Makes use of FastAPI's dependency injection system for cleaner code and easier testing.
- Backend Framework: FastAPI
- Database ORM: SQLAlchemy (with async support)
- Database: PostgreSQL (using
asyncpgdriver) - Data Validation: Pydantic
- Migrations: Alembic
- Authentication: JWT with python-jose and passlib
- ASGI Server: Uvicorn
form_builder_backend/
βββ alembic/ # Alembic migration scripts
β βββ versions/
β βββ env.py
βββ app/ # Main application source code
β βββ api/ # API endpoints (routers)
β β βββ v1/
β β βββ endpoints/ # Specific endpoint logic
β β βββ api.py # API router aggregation
β βββ core/ # Core components (config, security)
β βββ crud/ # Database interaction logic (CRUD operations)
β βββ db/ # Database setup (session, base model)
β βββ models/ # SQLAlchemy ORM models
β βββ schemas/ # Pydantic schemas (data validation)
β βββ dependencies.py # FastAPI dependencies
β βββ main.py # FastAPI application entry point
βββ .env # Environment variables (create this file)
βββ .gitignore # Git ignore rules
βββ alembic.ini # Alembic configuration
βββ requirements.txt # Project dependencies
βββ README.md # This file
- Python 3.10 or higher
- PostgreSQL Server (running locally or accessible)
- Git
-
Clone the repository:
git clone https://github.com/Udhay-Adithya/formflow_backend cd form_builder_backend -
Create and activate a virtual environment:
python -m venv venv # On macOS/Linux source venv/bin/activate # On Windows # venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
-
Configure Environment Variables: Create a
.envfile in the project root directory. Copy the contents from.env.example(if provided) or add the following variables, adjusting values as needed:# .env PROJECT_NAME="Formflow" # PostgreSQL Database URL # Format: postgresql+asyncpg://<user>:<password>@<host>:<port>/<database_name> DATABASE_URL=postgresql+asyncpg://user:password@localhost:5432/formflow_db # JWT Settings SECRET_KEY=your_super_secret_key_change_this # Generate a strong secret key (e.g., using openssl rand -hex 32) ALGORITHM=HS256 ACCESS_TOKEN_EXPIRE_MINUTES=60
- Ensure the specified PostgreSQL database exists or create it.
-
Run Database Migrations: Apply the latest database schema changes using Alembic:
alembic upgrade head
Start the development server using Uvicorn:
uvicorn app.main:app --reload --host 0.0.0.0 --port 8000--reload: Enables auto-reloading on code changes (for development).--host 0.0.0.0: Makes the server accessible on your local network.--port 8000: Specifies the port to run on.
The API will be available at http://localhost:8000.
Once the server is running, interactive API documentation is available at:
- Swagger UI:
http://localhost:8000/docs - ReDoc:
http://localhost:8000/redoc
These interfaces allow you to explore and interact with all available API endpoints.
/api/v1/auth: User registration and token generation (login)./api/v1/users: User-related operations (e.g., getting the current user)./api/v1/forms: CRUD operations for forms./api/v1/forms/{form_id}/responses: Submitting and retrieving responses for a specific form.
(Instructions for running tests will be added here once test suites are implemented.)
Contributions are welcome! Please follow standard fork-and-pull-request workflow. Ensure your code adheres to the project's style and includes tests for new features or bug fixes.
This project is licensed under the MIT License - see the LICENSE file for details.