A Go-based backend service for TMR (Targeted Memory Reactivation) lab experiment management.
This project provides a REST API service for managing TMR lab experiments, including subject management, lab test administration, and result tracking. It's built with Go and uses MySQL as the database.
- Language: Go 1.22.1
- Framework: Gin Web Framework
- Database: MySQL with GORM
- Container: Docker
- CI/CD: GitHub Actions
- Cloud Services: AWS (ECR, CodeDeploy, S3, EC2)
- Create new test subjects
- Verify subject existence
- Generate unique login IDs for subjects
- Support for pre-tests and post-tests
- Track breathing patterns during tests
- Record cue word presentations
- Store test results and histories
- Temporary file storage for test results
- Automatic file cleanup after expiration (60 minutes)
- Secure file download functionality
- Automated notifications for test events
- Test result summaries with downloadable CSV files
- Real-time updates on experiment progress
- config/: Configuration setup (DB, env)
- dto/: Data Transfer Objects
- entity/: Database entities
- handler/: HTTP request handlers
- model/: Business logic and database operations
- router/: Route definitions
- util/: Utility functions
- main.go: Application entry point
- POST /api/subjects - Create new subject
- GET /api/subjects/check - Check subject existence
- POST /api/labs/breathing - Record breathing history
- POST /api/labs/cue - Record cue presentation
- POST /api/labs/start-test - Start a new test session
- POST /api/labs/test - Record test history
- GET /api/labs/cue - Get target words
- GET /api/files/:filename - Download result files
- GET /api/health - Service health check
The project uses GitHub Actions for CI/CD pipeline:
- Builds Docker image
- Pushes to Amazon ECR
- Deploys to EC2 using AWS CodeDeploy
- AWS credentials
- MySQL database
- Slack webhook URL
- Environment variables setup
- DB_HOST
- DB_USERNAME
- DB_PASSWORD
- DB_NAME
- SLACK_WEBHOOK_URL
- BASE_URL
- Clone the repository
- Install dependencies: go mod download
- Set up environment variables: Copy .env.example to .env and configure
- Run the application: go run main.go
Build the image: docker build -t tmr-backend .
Run the container: docker run -p 8080:8080 -v /path/to/temp_files:/temp_files tmr-backend