A modern Rust implementation of the SocialCalc (Aspiring Investments) backend using Axum framework for testing rust peer.
- Authentication: JWT-based authentication with bcrypt password hashing
- File Management: PostgreSQL-based file storage with user isolation
- Email Integration: AWS SES integration for email notifications
- Cloud Storage: AWS S3 integration for file storage
- In-App Purchases: Purchase tracking and validation
- RESTful API: Clean REST API with JSON responses
- Framework: Axum (async web framework)
- Database: PostgreSQL with SQLx
- Authentication: JWT + bcrypt
- Cloud Services: AWS S3, AWS SES
- Serialization: Serde JSON
- Async Runtime: Tokio
- Rust 1.70+
- PostgreSQL
- AWS credentials (for S3 and SES)
DATABASE_URL=postgresql://username:password@localhost/aspiring_investments
JWT_SECRET=your-jwt-secret
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
SES_FROM_EMAIL=[email protected]- Clone the repository
- Install dependencies:
cargo build
- Run migrations:
sqlx migrate run
- Start the server:
cargo run
The server will start on http://0.0.0.0:8080
POST /login- User loginPOST /register- User registrationGET /logout- User logoutPOST /lostpw- Password reset requestPOST /pwreset- Password reset
GET /save- List user filesPOST /save- Save filePOST /insert- Get file contentPOST /usersheet- Handle user sheet operations
GET /webapp- Web app operationsPOST /webapp- Web app actions (save, delete, list files)
POST /runasemailer- Send emailsGET /runas- Run applicationsPOST /downloadfile- Download filesGET/POST /htmltopdf- HTML to PDF conversionGET/POST /iconimg- Image handling
The application uses PostgreSQL with the following main tables:
users- User accounts and authenticationfiles- File storage with user isolationin_app_purchases- Purchase tracking
- Password hashing with bcrypt
- JWT token authentication
- User data isolation
- Input validation and sanitization
- CORS support
The API returns consistent JSON responses:
{
"result": "ok|fail",
"data": "response data",
"message": "error message if applicable"
}Run tests:
cargo testRun with hot reload:
cargo watch -x run- Set all required environment variables
- Run database migrations
- Build release binary:
cargo build --release
- Deploy with proper reverse proxy (nginx recommended)