A Go-based conversion of the Python Tornado backend for the Aspiring Investments platform. This backend provides cloud-based spreadsheet and business application services with AWS S3 storage integration. We are extending for testing the go-libp2p p2p dapps.
- Authentication System: User registration, login, password reset with secure cookie-based sessions
- Cloud Storage: AWS S3-based file and directory management system
- Web Applications: Spreadsheet applications with real-time collaboration features
- Email Services: Amazon SES integration for transactional emails
- Dropbox Integration: OAuth-based Dropbox sync functionality
- Session Management: In-memory session management with automatic cleanup
- RESTful API: Clean REST endpoints for all services
go-backend/
├── cmd/server/ # Application entry point
├── internal/
│ ├── auth/ # Authentication service
│ ├── config/ # Configuration management
│ ├── email/ # Email service (SES)
│ ├── handlers/ # HTTP request handlers
│ ├── models/ # Data models
│ ├── session/ # Session management
│ └── storage/ # Storage interface and S3 implementation
├── pkg/
│ ├── middleware/ # HTTP middleware
│ └── utils/ # Utility functions
└── web/
├── static/ # Static assets
└── templates/ # HTML templates
- Language: Go 1.21+
- Web Framework: Gin
- Cloud Storage: AWS S3
- Email Service: Amazon SES
- Session Store: In-memory cache with TTL
- Authentication: bcrypt password hashing
- Containerization: Docker & Docker Compose
- Reverse Proxy: Nginx
- Go 1.21 or higher
- Docker and Docker Compose
- AWS account with S3 and SES configured
- Nginx (for production deployment)
-
Copy the example environment file:
cp .env.example .env
-
Update the
.env
file with your AWS credentials and configuration:AWS_ACCESS_KEY_ID=your_aws_access_key AWS_SECRET_ACCESS_KEY=your_aws_secret_key AWS_REGION=us-east-1 S3_BUCKET=your-s3-bucket-name FROM_EMAIL=your-verified-ses-email@domain.com
-
Install dependencies:
go mod download
-
Run the application:
go run cmd/server/main.go
-
Access the application:
- Server: http://localhost:8080
- Health check: http://localhost:8080/health
-
Build and run with Docker Compose:
docker-compose up --build
-
Access the application:
- Application: http://localhost
- Backend (direct): http://localhost:8080
For production deployment, use the included nginx configuration with proper SSL certificates and security headers.
POST /iauth
- Multi-purpose authentication (login/register/logout)POST /login
- User loginPOST /register
- User registrationPOST /logout
- User logoutGET /pwreset
- Password reset formPOST /pwreset
- Process password reset
POST /iwebapp
- Web application operations (save/load/list files)GET /browser/:app/:code/:file
- Access web applicationsGET /browser
- Landing page
POST /irunasemailer
- Send emails via SES
GET /browser/:app/dropbox
- Dropbox OAuth operationsPOST /browser/:app/dropbox
- Dropbox file operations
GET /health
- Health check endpoint
- Secure password hashing with bcrypt
- Session-based authentication
- Password reset with secure tokens
- User management with AWS S3 storage
- AWS S3-based file system abstraction
- Directory and file operations
- JSON-based metadata storage
- Hierarchical path structure
- In-memory session storage with TTL
- Automatic cleanup of expired sessions
- Session-based user state management
- Amazon SES integration
- HTML and text email support
- Transactional email templates
The application uses environment variables for configuration:
Variable | Description | Default |
---|---|---|
ENVIRONMENT |
Environment (development/production) | development |
PORT |
Server port | 8080 |
AWS_ACCESS_KEY_ID |
AWS access key | - |
AWS_SECRET_ACCESS_KEY |
AWS secret key | - |
AWS_REGION |
AWS region | us-east-1 |
S3_BUCKET |
S3 bucket name | aspiring-cloud-storage |
FROM_EMAIL |
SES verified sender email | - |
- Secure cookie-based sessions
- Password hashing with bcrypt
- CORS protection
- Rate limiting (via nginx)
- Security headers
- Input validation
- SQL injection prevention (no SQL used)
- Connection pooling for AWS services
- In-memory session caching
- Static file serving via nginx
- Gzip compression
- HTTP/2 support (with proper nginx config)
- Health check endpoint at
/health
- Docker health checks configured
- Nginx upstream health monitoring
- Structured logging
The project follows Go standard project layout:
cmd/
- Application entry pointsinternal/
- Private application codepkg/
- Public library code that can be used by external applicationsweb/
- Web application specific components
- Define models in
internal/models/
- Implement business logic in appropriate service packages
- Create handlers in
internal/handlers/
- Add routes in
cmd/server/main.go
- Add tests in corresponding
_test.go
files
Run tests with:
go test ./...
This Go backend is a direct conversion of the original Python Tornado backend with the following improvements:
- Performance: Significantly faster due to Go's compiled nature and goroutines
- Memory Efficiency: Lower memory footprint compared to Python
- Concurrency: Better handling of concurrent requests
- Type Safety: Compile-time type checking prevents runtime errors
- Deployment: Single binary deployment, no dependency management issues
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
This project maintains the same license as the original Python implementation.