https://github.com/foc-fun/foc-fun
The Starknet App Engine
https://github.com/foc-fun/foc-fun
backend cairo starknet
Last synced: 4 months ago
JSON representation
The Starknet App Engine
- Host: GitHub
- URL: https://github.com/foc-fun/foc-fun
- Owner: foc-fun
- Created: 2024-10-18T01:52:05.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-08-03T05:16:08.000Z (11 months ago)
- Last Synced: 2025-08-03T05:26:45.610Z (11 months ago)
- Topics: backend, cairo, starknet
- Language: TypeScript
- Homepage: https://foc.fun
- Size: 1.55 MB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# FOC Fun - Starknet App Engine
A platform for deploying and managing smart contracts on the Starknet blockchain










## Overview
FOC Fun is a comprehensive Starknet App Engine that provides a registry system for contract classes, automated deployment, event indexing, and a web interface for contract interaction. It serves as a platform for developers to deploy and manage smart contracts on the Starknet blockchain with ease.
## Features
- 🔗 **Smart Contract Registry**: Central registry for managing contract classes and deployments
- 🚀 **Automated Deployment**: Streamlined contract deployment process
- 📊 **Event Indexing**: Real-time blockchain event monitoring and processing
- 🌐 **Web Interface**: User-friendly frontend for contract interaction
- 🔐 **Wallet Integration**: Support for Starknet wallets via Starknet React
- 📈 **Analytics**: Contract usage tracking and metrics
## Tech Stack
### Frontend
- **Next.js 15.1.7** with App Router
- **React 19** with TypeScript
- **Tailwind CSS** for styling
- **Starknet React** for blockchain integration
- **pnpm** package manager
### Backend
- **Go 1.23.1** REST API server
- **PostgreSQL 14.11** for structured data
- **MongoDB** for flexible event storage
- **Redis 7.2.4** for caching
- **Apibara** for blockchain indexing
### Smart Contracts
- **Cairo** (Starknet edition 2024_07)
- **Scarb** build tool
- **Starknet Foundry** for testing
### Infrastructure
- **Docker & Docker Compose** for development
- **Kubernetes with Helm** for production deployment
## Quick Start
### Prerequisites
- Docker and Docker Compose
- Go 1.23.1+
- Node.js 18+ with pnpm
- Scarb (Cairo build tool)
### Development Setup
1. **Clone the repository**
```bash
git clone
cd foc-fun
```
2. **Start all services**
```bash
docker-compose up
```
3. **Frontend development** (separate terminal)
```bash
cd frontend
npm run dev
```
4. **Access the application**
- Frontend: http://localhost:3000
- Backend API: http://localhost:8080
## Essential Commands
### Development
```bash
# Start all services locally
docker-compose up
# Frontend development (port 3000)
cd frontend && npm run dev
# Lint and fix frontend code
cd frontend && npm run lint:fix
# Build everything
make build
# Run smart contract tests
make test
```
### Building
```bash
# Build all components
make build
# Individual builds
make build-backend # Go backend
make build-frontend # Next.js frontend
make build-contracts # Cairo contracts
# Docker builds
make docker-build # Build all Docker images
make docker-push # Push images to registry
```
### Testing
```bash
# Smart contract tests
cd onchain && scarb test
# or
make contracts-test
# Frontend linting
cd frontend && npm run lint
```
### Deployment
```bash
# Kubernetes deployment
make helm-install # Initial deploy
make helm-upgrade # Update deployment
make helm-uninstall # Remove deployment
```
## Architecture
### Core Components
1. **Registry Contract** (`onchain/src/registry.cairo`): Central smart contract managing class registration, contract deployment, and event tracking
2. **Backend API** (`backend/cmd/backend/`): REST API server providing endpoints for contract interaction
3. **Consumer Service** (`backend/cmd/consumer/`): Processes indexed blockchain events from Apibara
4. **Indexer Service** (`indexer/`): Monitors blockchain for registry events
5. **Frontend** (`frontend/`): Next.js app for user interaction with contracts
### Key Directories
```
├── frontend/ # Next.js frontend application
│ ├── src/app/ # App Router pages
│ ├── src/components/ # React components
│ └── src/contract/ # Smart contract interaction logic
├── backend/ # Go backend services
│ ├── routes/ # HTTP route handlers
│ └── indexer/ # Event processing logic
├── onchain/ # Cairo smart contracts
│ └── src/ # Contract source files
├── abis/ # Contract ABI JSON files
└── indexer/ # Blockchain event indexer
```
## Environment Configuration
Key environment variables:
- `FOC_FUN_REGISTRY_CONTRACT`: Registry contract address
- `POSTGRES_PASSWORD`: Database password
- `MONGO_URI`: MongoDB connection string
- `AUTH_TOKEN` / `APIBARA_AUTH_TOKEN`: Apibara authentication
- `NEXT_PUBLIC_REGISTRY_CONTRACT_ADDRESS`: Frontend registry address
- `NEXT_PUBLIC_BACKEND_URL`: Backend API URL
## Development Workflow
1. **Smart contract changes**: Edit in `onchain/src/`, run `scarb build` and `scarb test`
2. **Backend changes**: Edit Go files, rebuild with `make build-backend`
3. **Frontend changes**: Edit in `frontend/src/`, changes hot-reload in `npm run dev`
4. **Full stack testing**: Use `docker-compose up` to run all services together
## Contract Deployment
Contracts are deployed to Starknet Sepolia testnet. The registry contract address is configured in docker-compose.yml and environment configs.
## Contributing
1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Run tests and linting
5. Submit a pull request
## License
This project is licensed under the MIT License - see the LICENSE file for details.
## Support
For support and questions, please open an issue in the GitHub repository.