# MyCrib API (Go) Go implementation of the MyCrib property management API, built with Gin, GORM, Gorush, and GoAdmin. ## Tech Stack - **HTTP Framework**: [Gin](https://github.com/gin-gonic/gin) - **ORM**: [GORM](https://gorm.io/) with PostgreSQL - **Push Notifications**: [Gorush](https://github.com/appleboy/gorush) (embedded) - **Admin Panel**: [GoAdmin](https://github.com/GoAdminGroup/go-admin) - **Background Jobs**: [Asynq](https://github.com/hibiken/asynq) - **Caching**: Redis - **Logging**: [zerolog](https://github.com/rs/zerolog) - **Configuration**: [Viper](https://github.com/spf13/viper) ## Quick Start ### Prerequisites - Go 1.21+ - PostgreSQL 15+ - Redis 7+ ### Development Setup ```bash # Install dependencies make deps # Copy environment file cp .env.example .env # Edit .env with your configuration # Run the API server make run ``` ### Docker Setup ```bash # Start all services make docker-up # View logs make docker-logs # Stop services make docker-down ``` ## Project Structure ``` myCribAPI-go/ ├── cmd/ │ ├── api/main.go # API server entry point │ ├── worker/main.go # Background worker entry point │ └── admin/main.go # GoAdmin server entry point ├── internal/ │ ├── config/ # Configuration management │ ├── models/ # GORM models │ ├── database/ # Database connection │ ├── repositories/ # Data access layer │ ├── services/ # Business logic │ ├── handlers/ # HTTP handlers │ ├── middleware/ # Gin middleware │ ├── dto/ # Request/Response DTOs │ ├── router/ # Route setup │ ├── push/ # Gorush integration │ ├── worker/ # Asynq jobs │ └── admin/ # GoAdmin tables ├── pkg/ │ ├── utils/ # Utilities │ └── errors/ # Error types ├── migrations/ # SQL migrations ├── templates/emails/ # Email templates ├── docker/ # Docker files ├── go.mod └── Makefile ``` ## API Endpoints The API maintains 100% compatibility with the Django version. ### Public Endpoints (No Auth) - `GET /api/health/` - Health check - `POST /api/auth/login/` - Login - `POST /api/auth/register/` - Register - `GET /api/static_data/` - Cached lookups ### Protected Endpoints (Token Auth) - `GET /api/residences/` - List residences - `GET /api/tasks/` - List tasks - `GET /api/tasks/by-residence/:id/` - Kanban board - See full API documentation in the Django project ## Configuration Environment variables (see `.env.example`): | Variable | Description | Default | |----------|-------------|---------| | `PORT` | Server port | 8000 | | `DEBUG` | Debug mode | false | | `SECRET_KEY` | JWT secret | required | | `POSTGRES_*` | Database config | - | | `REDIS_URL` | Redis URL | redis://localhost:6379/0 | | `APNS_*` | iOS push config | - | | `FCM_SERVER_KEY` | Android push key | - | ## Development ```bash # Run tests make test # Run tests with coverage make test-coverage # Run linter make lint # Format code make fmt ``` ## Database This Go version uses the same PostgreSQL database as the Django version. GORM models are mapped to Django's table names: - `auth_user` - Django's User model - `user_authtoken` - Auth tokens - `residence_residence` - Residences - `task_task` - Tasks ## Migration from Django This is a full rewrite that maintains API compatibility. The mobile clients (KMM) work with both versions without changes. ## License Proprietary - MyCrib