REST API service untuk platform crowdfunding Web3 yang dibangun dengan Golang, Fiber, dan PostgreSQL.
- β CRUD operations untuk Projects
- β Investor Tracking - Track investor wallet addresses dengan PostgreSQL arrays
- β Manajemen User Profiles (Upsert)
- β Sistem Comments dengan support untuk nested comments
- β Manajemen External Links untuk setiap project (social media, website, dll)
- β Auto-migration database dengan GORM
- β UUID v7 untuk primary keys (time-ordered, better DB performance)
- β CORS enabled untuk kemudahan pengembangan
- β Request logging
- β Error handling yang konsisten
- β Validasi input
- β Interactive Swagger/OpenAPI Documentation
- Go 1.21 atau lebih tinggi
- PostgreSQL 12 atau lebih tinggi
- Clone repository:
git clone <repository-url>
cd hackathon- Install dependencies:
go mod download- Setup database PostgreSQL dan buat database baru:
CREATE DATABASE web3_crowdfunding;- Copy file
.envdan sesuaikan konfigurasi database:
# File .env sudah ada, sesuaikan dengan konfigurasi PostgreSQL Anda- Jalankan aplikasi:
go run cmd/main/main.goServer akan berjalan di http://localhost:3000
API ini dilengkapi dengan Swagger/OpenAPI documentation yang interaktif!
Akses Swagger UI:
http://localhost:3000/docs/
Fitur Swagger Documentation:
- β Interactive API testing
- β Complete request/response examples
- β Model schemas
- β Try it out functionality
- β Easy sharing dengan partner
Generate ulang Swagger docs:
make swagger
# atau
swag init -g cmd/main/main.go --output docsMendapatkan semua proyek (termasuk investor_wallet_addresses array).
Response:
[
{
"id": "uuid",
"creator_wallet_address": "0x...",
"title": "My Game Project",
"description": "Description here",
"cover_image_url": "https://...",
"developer_name": "Developer Name",
"genre": "RPG",
"game_type": "web3",
"created_at": "2025-10-15T10:00:00Z",
"updated_at": "2025-10-15T10:00:00Z"
}
]Mendapatkan detail proyek berdasarkan ID.
Response:
200 OK: Detail proyek404 Not Found: Proyek tidak ditemukan
Membuat proyek baru.
Request Body:
{
"creator_wallet_address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
"title": "My Awesome Game",
"description": "This is an amazing Web3 game",
"cover_image_url": "https://example.com/image.jpg",
"developer_name": "John Doe",
"genre": "Action",
"game_type": "web3"
}Response:
201 Created: Proyek berhasil dibuat (dengan UUID yang dihasilkan)400 Bad Request: Data tidak valid
Memperbarui proyek.
Request Body:
{
"title": "Updated Title",
"description": "Updated description"
}Response:
200 OK: Proyek berhasil diperbarui404 Not Found: Proyek tidak ditemukan
Mendapatkan semua investor wallet addresses untuk sebuah proyek.
Response:
{
"investors": [
"0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
"0x1234567890abcdef1234567890abcdef12345678"
]
}Menambahkan investor wallet address ke proyek.
Request Body:
{
"wallet_address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb"
}Response:
200 OK: Investor berhasil ditambahkan404 Not Found: Proyek tidak ditemukan409 Conflict: Investor sudah ada400 Bad Request: Format wallet address tidak valid
Menghapus investor dari proyek.
Response:
200 OK: Investor berhasil dihapus404 Not Found: Proyek tidak ditemukan
Mendapatkan profil berdasarkan wallet address.
Response:
200 OK: Detail profil404 Not Found: Profil tidak ditemukan
Membuat atau memperbarui profil (Upsert).
Request Body:
{
"username": "johndoe",
"email": "john@example.com",
"profile_image_url": "https://example.com/avatar.jpg",
"kyc_status": "verified"
}Response:
200 OK: Profil berhasil dibuat/diperbarui400 Bad Request: Data tidak valid409 Conflict: Username atau email sudah digunakan
Mendapatkan semua komentar untuk sebuah proyek.
Response:
[
{
"id": "uuid",
"project_id": "uuid",
"author_wallet_address": "0x...",
"parent_comment_id": null,
"content": "Great project!",
"created_at": "2025-10-15T10:00:00Z",
"updated_at": "2025-10-15T10:00:00Z"
}
]Menambahkan komentar baru.
Request Body:
{
"author_wallet_address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
"content": "This looks amazing!",
"parent_comment_id": "uuid-optional"
}Mendapatkan semua external links untuk sebuah proyek (social media, website, dll).
Response:
[
{
"id": "uuid",
"project_id": "uuid",
"name": "Instagram",
"url": "https://instagram.com/mygame",
"created_at": "2025-10-15T10:00:00Z",
"updated_at": "2025-10-15T10:00:00Z"
},
{
"id": "uuid",
"project_id": "uuid",
"name": "Twitter",
"url": "https://twitter.com/mygame",
"created_at": "2025-10-15T10:00:00Z",
"updated_at": "2025-10-15T10:00:00Z"
}
]Menambahkan external link baru ke proyek.
Request Body:
{
"name": "Instagram",
"url": "https://instagram.com/mygame"
}Response:
201 Created: Link berhasil ditambahkan404 Not Found: Proyek tidak ditemukan400 Bad Request: Data tidak valid
Memperbarui external link.
Request Body:
{
"name": "Instagram Official",
"url": "https://instagram.com/mygame_official"
}Response:
200 OK: Link berhasil diperbarui404 Not Found: Link tidak ditemukan400 Bad Request: Data tidak valid
Menghapus external link.
Response:
200 OK: Link berhasil dihapus404 Not Found: Link tidak ditemukan
Mengecek status API.
Response:
{
"status": "ok",
"message": "Web3 Crowdfunding API is running"
}/hackathon
βββ cmd/
β βββ main/
β βββ main.go # Entry point aplikasi
βββ internal/
β βββ config/
β β βββ config.go # Konfigurasi aplikasi
β βββ database/
β β βββ database.go # Inisialisasi database
β βββ handler/
β β βββ project_handler.go # Project handlers
β β βββ user_profile_handler.go # Profile handlers
β β βββ comment_handler.go # Comment handlers
β β βββ external_link_handler.go # External link handlers
β βββ model/
β β βββ model.go # GORM models (4 tables)
β βββ repository/
β β βββ project_repository.go # Project repository
β β βββ user_profile_repository.go # Profile repository
β β βββ comment_repository.go # Comment repository
β β βββ external_link_repository.go # External link repository
β βββ router/
β βββ router.go # Route definitions
βββ docs/
β βββ docs.go # Generated Swagger docs
β βββ swagger.json # OpenAPI JSON spec
β βββ swagger.yaml # OpenAPI YAML spec
βββ .env # Environment variables
βββ .gitignore
βββ go.mod
βββ go.sum
βββ README.md
Edit file .env untuk mengubah konfigurasi:
# Database Configuration
DB_HOST=localhost
DB_PORT=5432
DB_USER=postgres
DB_PASSWORD=postgres
DB_NAME=web3_crowdfunding
DB_SSLMODE=disable
# Server Configuration
SERVER_PORT=3000id(UUID, Primary Key)creator_wallet_address(VARCHAR(42))title(VARCHAR(255))description(TEXT)cover_image_url(VARCHAR(255))developer_name(VARCHAR(100))genre(VARCHAR(50))game_type(VARCHAR(10))investor_wallet_addresses(TEXT[], Array of wallet addresses)created_at(TIMESTAMPTZ)updated_at(TIMESTAMPTZ)
wallet_address(VARCHAR(42), Primary Key)username(VARCHAR(50), Unique)email(VARCHAR(255), Unique)profile_image_url(VARCHAR(255))kyc_status(VARCHAR(20), Default: 'unverified')created_at(TIMESTAMPTZ)updated_at(TIMESTAMPTZ)
id(UUID, Primary Key)project_id(UUID, Foreign Key)author_wallet_address(VARCHAR(42))parent_comment_id(UUID, Foreign Key, Nullable)content(TEXT)created_at(TIMESTAMPTZ)updated_at(TIMESTAMPTZ)
id(UUID, Primary Key)project_id(UUID, Foreign Key)name(VARCHAR(50)) - e.g., "Instagram", "Twitter", "Website"url(VARCHAR(500)) - The actual linkcreated_at(TIMESTAMPTZ)updated_at(TIMESTAMPTZ)
curl -X POST http://localhost:3000/api/v1/projects \
-H "Content-Type: application/json" \
-d '{
"creator_wallet_address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
"title": "Epic Web3 Game",
"description": "An amazing blockchain game",
"developer_name": "GameDev Studio",
"genre": "RPG",
"game_type": "web3"
}'curl http://localhost:3000/api/v1/projectscurl -X PUT http://localhost:3000/api/v1/profiles/0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb \
-H "Content-Type: application/json" \
-d '{
"username": "gamer123",
"email": "gamer@example.com",
"kyc_status": "verified"
}'curl -X POST http://localhost:3000/api/v1/projects/{project-id}/comments \
-H "Content-Type: application/json" \
-d '{
"author_wallet_address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
"content": "This project looks promising!"
}'curl -X POST http://localhost:3000/api/v1/projects/{project-id}/links \
-H "Content-Type: application/json" \
-d '{
"name": "Instagram",
"url": "https://instagram.com/mygame"
}'curl http://localhost:3000/api/v1/projects/{project-id}/links- API ini tidak memerlukan autentikasi karena state krusial ditangani oleh smart contract
- UUID digunakan untuk memastikan konsistensi antara database off-chain dan smart contract on-chain
- Middleware CORS dikonfigurasi untuk menerima request dari semua origin (untuk development)
- Semua timestamp menggunakan TIMESTAMPTZ untuk timezone awareness
- Auto-migration akan otomatis membuat tabel saat aplikasi pertama kali dijalankan
Untuk production:
- Update CORS configuration untuk membatasi origins
- Set
DB_SSLMODE=requireuntuk koneksi database yang aman - Gunakan environment variables untuk konfigurasi sensitif
- Implementasikan rate limiting
- Setup monitoring dan logging yang proper
MIT License
Backend Engineering Team