A 4chan-inspired image board API built with Go, Chi, PostgreSQL, and JSONB. Supports boards, posts, threads, user authentication, post flagging, search, and image storage (local or S3).
- Boards: Create/list boards (admin-only creation).
- Posts: Create threads/replies, upload images (local or S3).
- Auth: User/admin registration, login with JWT.
- Flags: Flag posts for moderation, admin review.
- Search: Full-text search on post content and tags.
- Threads: View threads with replies.
- Archiving: Auto-archive threads after 7 days, delete after 30 days.
- Rate-Limiting: Prevent spam on public endpoints.
- Logging: Structured request logging with zerolog.
- Health Checks: Kubernetes-ready health, readiness, and liveness probes.
- CORS Support: Configurable Cross-Origin Resource Sharing.
- API Documentation: Interactive Swagger/OpenAPI documentation.
-
Prerequisites:
- Go 1.23
- Docker, Docker Compose
- AWS credentials (if using S3)
-
Clone Repository:
git clone https://github.com/cobalto/noppera.git cd noppera -
Configure Environment: Copy
.env.exampleto.envand update values:cp .env.example .env
-
Run with Docker:
docker-compose up -d
-
Test Endpoints:
# Health check curl http://localhost:8080/health # Register user curl -X POST http://localhost:8080/auth/register -d '{"username":"test","password":"pass123"}' # Login curl -X POST http://localhost:8080/auth/login -d '{"username":"test","password":"pass123"}' # Create thread curl -X POST http://localhost:8080/boards/g/threads -d '{"title":"Test Thread","content":"Hello","image":"base64image"}' # Search posts curl "http://localhost:8080/posts/search?query=hello" # View thread curl http://localhost:8080/threads/1 # View API documentation open http://localhost:8080/swagger/index.html
DATABASE_URL: PostgreSQL connection string.API_HOST,API_PORT: API server host/port.JWT_SECRET: Secret for JWT signing.STORAGE_TYPE:localors3.UPLOAD_DIR,UPLOAD_URL_PREFIX: Local storage directory and URL base (if STORAGE_TYPE=local).S3_REGION,S3_ACCESS_KEY_ID,S3_SECRET_ACCESS_KEY,S3_BUCKET: S3 settings.MAX_POST_LENGTH,RATE_LIMIT_REQUESTS,RATE_LIMIT_BURST,ARCHIVE_DELETE_DAYS: API settings.LOG_LEVEL,LOG_FILE: Logging settings.CORS_ALLOWED_ORIGINS,CORS_ALLOWED_METHODS,CORS_ALLOWED_HEADERS,CORS_ALLOW_CREDENTIALS: CORS settings.
- cmd/api/ Main application entry point
- internal/handlers/ HTTP handlers for boards, posts, auth, flags, search, threads, health
- internal/models/ Data models and database operations
- internal/storage/ Image storage (local/S3)
- internal/middleware/ Authentication, rate-limiting, logging, CORS
- internal/jobs/ Background jobs (archiving)
- internal/config/ Configuration loading
- docs/ Generated Swagger/OpenAPI documentation
GET /health- Health check with service statusGET /health/ready- Readiness probe for KubernetesGET /health/live- Liveness probe for KubernetesGET /swagger/*- Interactive API documentation
POST /auth/register- Register new userPOST /auth/login- Login and get JWT tokenPOST /auth/register/admin- Register admin user (admin only)
GET /boards- List all boardsPOST /boards- Create new board (admin only)
POST /boards/{boardSlug}/threads- Create new threadPOST /threads/{threadID}/replies- Reply to threadGET /threads/{threadID}- Get thread with repliesDELETE /posts/{postID}/user- Delete own post (authenticated)DELETE /posts/{postID}/admin- Delete any post (admin only)
GET /posts/search- Search posts by content, tags, or boardPOST /posts/{postID}/flag- Flag post for moderationGET /flags- List all flags (admin only)
swag init -g cmd/api/main.go -o ./docsgo build -o noppera ./cmd/api
./noppera