A monorepo containing the Hapit application for managing sports playbooks and teams.Project to learn hapi and related stack. The application handles a sports playbook app, users can create and share plays with their teammates.
hapit/- npm
├── backend/ # Node.js Hapi.js API server- Docker
├── frontend/ # Frontend application (coming soon)
└── terraform/ # Infrastructure as code for Kubernetes deployment## How to run it
## Backendnpm install
The backend is a Hapi.js REST API server with authentication and database integration.
**Technology Stack:**npm run dev
- Node.js 22 with Hapi.js framework```
- PostgreSQL (production) / SQLite (development)
- JWT authenticationThe application will be available at `http://localhost:3000` by default
- Kubernetes deployment with Terraform
### Run for production
See [backend/README.md](./backend/README.md) for detailed backend documentation.
```Run for production
## Frontendnpm start
Coming soon.
The application uses an env file to set variables when running locally. Chech .env in the root of the project.
The application is deployed to MicroK8s using Terraform for infrastructure management.
Components:
-
Kubernetes namespace (
hapit)### Building the Image -
PostgreSQL database with persistent storage
-
Backend API service (NodePort on 30080)```bash
-
Init container pattern for database readinessdocker build -t hapit .
See [terraform/README.md](./terraform/README.md) for deployment instructions.
### Running a Container
## Development
```bash
### Backend Developmentdocker run -p 3000:3000 hapit
```bash```
cd backend
npm install### Run in Background
npm run dev # Uses SQLite for local development
``````bash
docker run -d -p 3000:3000 hapit
### Production Deployment```
```bash
cd terraform## Kubernetes Deployment
terraform init
terraform applyThe project supports deployment to MicroK8s using Terraform. The application is deployed to a dedicated `hapit` namespace with a NodePort service accessible on port 30080.
See terraform/README.md for detailed deployment instructions.
ISC
npm testnpm run test:file <path_to_specs>GET /api/teams- List all teamsPOST /api/teams- Create a new teamGET /api/teams/:id- Get specific teamPUT /api/teams/:id- Update teamDELETE /api/teams/:id- Delete team
# Create a play
curl -X POST http://localhost:3000/api/teams \
-H "Content-Type: application/json" \
-d '{"name": "Lions", "description": "Best pickleball team!", "maxMembers": 5}'
# List teams
curl http://localhost:3000/api/teamsCreate a .env file in the root directory:
# Application Configuration
PORT=3000
HOST=0.0.0.0
NODE_ENV=development