A polling application built with a Go backend (using GORM) and React frontend. The application allows users to create and vote on polls, with authentication and dark/light theme support.
backend/
: Go backend codefrontend/
: React frontend codedb/
: SQLite databasedocker-compose.yaml
: Docker compose file for running the application as containers
- Go 1.21+
- Node.js 18+
- Python 3.x
- SQLite3
-
Clone the repository
-
Set up the database and users:
# Copy the users template and edit with your credentials cp backend/scripts/users_template.yaml backend/scripts/users.yaml # Edit users.yaml with your desired user credentials # Run the database setup scripts cd backend/scripts python add_users.py
-
Install backend dependencies:
cd backend go mod download
-
Install frontend dependencies:
cd frontend npm install
-
Start the backend server:
cd backend # The backend will use the development database path go run main.go
-
Start the frontend development server:
cd frontend npm start
Alternatively, you can run the application using the start.sh
script:
sh ./start.sh
The application will be available at:
- Frontend: http://localhost:3000
- Backend API: http://localhost:8080
-
Configure users:
cp backend/scripts/users_template.yaml backend/scripts/users.yaml # Edit users.yaml with production credentials
-
Build and run containers:
docker compose up --build
The application will be available at:
- Frontend: http://localhost:3000
- Backend API: http://localhost:8080
Create a .env
file in the root directory:
# Backend settings
DB_PATH=/app/poll.db
JWT_SECRET=
SERVER_PORT=8080
# Frontend settings
SERVER_HOST=localhost
FRONTEND_URL=http://localhost:3000
API_URL=http://localhost:8080/api/
BASE_URL=http://localhost:8080/
BIBLE_API_KEY=
ENV_MODE=development
- Development database location:
./poll.db
- Production database location:
/app/poll.db
(inside container) - Database initialization scripts are in
backend/scripts/
- Login endpoint:
POST /api-token-auth/
- Token-based authentication using JWT
- User management through
users.yaml
configuration
- Dark/Light theme toggle
- Real-time vote updates
- User vote tracking
- Member count display
- The backend uses environment mode (
ENV_MODE
) to determine database paths - Frontend API URLs are configured through environment variables
- SQLite database is used for both development and production
- User data is managed through an untracked YAML file for security