dc1eb9cf34
All checks were successful
Build and Push Docker Image / build_and_push (push) Successful in 15s
|
||
---|---|---|
.gitea/workflows | ||
backend | ||
frontend | ||
docker-compose.yml | ||
Dockerfile | ||
README.md |
Formies
Formies is a form management tool that allows you to create customizable forms, collect submissions, and view collected data. This project combines a Rust backend and a Svelte frontend, packaged as a single Docker container for easy deployment.
Features
📝 Form Management
- Create forms with customizable fields (text, number, date, etc.).
- View all created forms in a centralized dashboard.
🗂️ Submissions
- Submit responses to forms via a user-friendly interface.
- View and manage all form submissions.
⚙️ Backend
- Built with Rust using Actix-Web for high performance and scalability.
- Uses SQLite for local data storage with easy migration to PostgreSQL if needed.
🎨 Frontend
- Built with SvelteKit for a modern and lightweight user experience.
- Responsive design for use across devices.
🚀 Deployment
- Packaged as a single Docker image for seamless deployment.
- Supports CI/CD workflows with Gitea Actions, Drone CI, or GitHub Actions.
Folder Structure
project-root/
├── backend/ # Backend codebase
│ ├── src/
│ │ ├── handlers.rs # Route handlers for Actix-Web
│ │ ├── models.rs # Data models (Form, Submission)
│ │ ├── db.rs # Database initialization
│ │ ├── main.rs # Main entry point for the backend
│ │ └── ... # Additional modules
│ ├── Cargo.toml # Backend dependencies
│ └── Cargo.lock # Locked dependencies
│
├── frontend/ # Frontend codebase
│ ├── public/ # Built static files (after `npm run build`)
│ ├── src/
│ │ ├── lib/ # Shared utilities (e.g., API integration)
│ │ ├── routes/ # Svelte pages
│ │ │ ├── +page.svelte # Dashboard
│ │ │ └── form/ # Form-related pages
│ │ └── main.ts # Frontend entry point
│ ├── package.json # Frontend dependencies
│ ├── svelte.config.js # Svelte configuration
│ └── ... # Additional files
│
├── Dockerfile # Combined Dockerfile for both frontend and backend
├── docker-compose.yml # Docker Compose file for deployment
├── .gitea/ # Gitea Actions workflows
│ └── workflows/
│ └── build_and_deploy.yml
├── .drone.yml # Drone CI configuration
├── README.md # Documentation (this file)
└── ... # Other configuration files
Prerequisites
Docker
- Install Docker: Docker Documentation
Rust (for development)
- Install Rust: Rustup Installation
Node.js (for frontend development)
- Install Node.js: Node.js Downloads
Development
Backend
-
Navigate to the backend/ directory:
cd backend
-
Run the backend server:
cargo run
The backend will be available at http://localhost:8080.
Frontend
-
Navigate to the frontend/ directory:
cd frontend
-
Install dependencies:
npm install
-
Start the development server:
npm run dev
The frontend will be available at http://localhost:5173.
Deployment
Build the Docker Image
-
Build the combined Docker image:
docker build -t your-dockerhub-username/formies-combined .
-
Run the Docker container:
docker run -p 8080:8080 your-dockerhub-username/formies-combined
Access the application at http://localhost:8080.
Using Docker Compose
-
Deploy using
docker-compose.yml
:docker-compose up -d
-
Stop the containers:
docker-compose down
CI/CD Workflow
Gitea Actions
-
Create a file at
.gitea/workflows/build_and_deploy.yml
:name: Build and Deploy on: push: branches: - main jobs: build: runs-on: ubuntu-latest steps: - name: Clone the repository uses: actions/checkout@v3 - name: Set up Docker uses: docker/setup-buildx-action@v2 - name: Log in to Docker Hub run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin - name: Build and Push Docker Image run: | docker build -t your-dockerhub-username/formies-combined . docker push your-dockerhub-username/formies-combined:latest - name: Deploy to Server (optional) run: | ssh -o StrictHostKeyChecking=no ${{ secrets.SERVER_USER }}@${{ secrets.SERVER_IP }} << 'EOF' docker pull your-dockerhub-username/formies-combined:latest docker stop formies || true docker rm formies || true docker run -d --name formies -p 8080:8080 your-dockerhub-username/formies-combined:latest EOF
-
Add secrets in Gitea:
DOCKER_USERNAME
: Your Docker Hub username.DOCKER_PASSWORD
: Your Docker Hub password.SERVER_USER
: SSH username for deployment.SERVER_IP
: IP address of the server.
API Endpoints
Base URL: http://localhost:8080
Method | Endpoint | Description |
---|---|---|
POST | /api/forms |
Create a new form |
GET | /api/forms |
Get all forms |
POST | /api/forms/{id}/submissions |
Submit data to a form |
GET | /api/forms/{id}/submissions |
Get submissions for a specific form |
Future Enhancements
- Authentication: Add user-based authentication for managing forms and submissions.
- Export: Allow exporting submissions to CSV or Excel.
- Scaling: Migrate to PostgreSQL for distributed data handling.
- Monitoring: Integrate tools like Prometheus and Grafana for performance monitoring.
License
This project is licensed under the MIT License. See the LICENSE file for details.