Andrometa Backend is a comprehensive Node.js server that powers the Andrometa gaming platform, handling everything from user authentication to game mechanics, inventory management, and social features. The backend provides a unified API for both web and mobile clients.
- Authentication: Multiple auth methods including email, Google, Apple, and Passport integration
- Game Mechanics: Leaderboards, challenges, and missions for players to complete
- Inventory System: Robust item management with crafting capabilities
- NFT Integration: Collection management, token trading, and fusion mechanics
- Social Features: In-app chat, servers, and real-time notifications
- Marketplace: Secure token/NFT listing and bidding functionality
- Store: In-app purchases with platform-specific verification
- Quests & Achievements: Progression tracking across multiple platforms
- Streaming Support: Integration for content creators
- Framework: Express.js, TypeScript
- Database: Prisma ORM with PostgreSQL
- Authentication: JWT, OAuth2
- Real-time: WebSockets
- Storage: AWS S3
- Payments: Stripe integration
- Node.js 16+
- PostgreSQL
- AWS account for S3 storage
- Stripe account for payments
- Clone the repository
git clone https://github.com/yourusername/andrometa-backend.git
cd andrometa-backend- Install dependencies
npm install- Create a
.envfile in the root directory with the following variables:
# Server
PORT=3000
# Database
DATABASE_URL="postgresql://username:password@localhost:5432/andrometa"
# Authentication
JWT_SECRET="your-jwt-secret"
ADMIN_SECRET_PASS="your-admin-secret"
# AWS
S3_ACCESS_KEY="your-aws-access-key"
S3_SECRET_KEY="your-aws-secret-key"
OUTKAST_S3_BUCKET="your-s3-bucket-name"
MNNT_BUCKET="your-mnnt-bucket-name"
# Stripe
STRIPE_SECRET_KEY="your-stripe-secret-key"
STRIPE_ENDPOINT_SECRET="your-stripe-endpoint-secret"
# Email
AWS_SES_ACCESS_KEY_ID="your-ses-access-key"
AWS_SES_SECRET_ACCESS_KEY="your-ses-secret-key"
EMAIL="no-reply@yourdomain.com"
# Social Auth
DISCORD_TOKEN="your-discord-token"
GOOGLE_API_KEY="your-google-api-key"
# Third-party Integrations
OPENAI_API_KEY="your-openai-api-key"
- Initialize the database
npx prisma migrate dev- Start the development server
npm run dev- The server will be available at http://localhost:3000
The backend is organized into several modules:
- Auth: User registration, login, and session management
- Collections: NFT collection and token management
- Inventory: Player item storage and manipulation
- Missions: Time-based activities for players
- Marketplace: Trading platform for digital assets
- Leaderboard: Competitive player rankings
- Challenges: Player vs player competitions
- Quests: Achievement tracking across platforms
- Store: In-app purchase verification and fulfillment
- Support: User assistance and loyalty features
- Notification: Real-time alerts and updates
Real-time communication is implemented for:
- Chat functionality
- Live stream interaction
- Notification delivery
- Game state updates
- JWT authentication
- Server-side validation
- Signature verification for sensitive operations
- Rate limiting
- Encryption for sensitive data
For detailed API documentation, see API-Docs.md.
AWS Copilot is a tool for developers to build, release, and operate containerized applications on AWS. It simplifies the process of deploying and managing applications on AWS ECS and AWS Fargate.
- AWS Copilot CLI installed
- AWS credentials configured
- Docker installed
- Your application containerized (Dockerfile in root directory)
- Initialize your application with Copilot
copilot app init andrometa-backend- Add a service (e.g., API service)
copilot svc init --name api --svc-type "Load Balanced Web Service" --dockerfile ./Dockerfile- Set up your environments (e.g., test, staging, production)
copilot env init --name test --profile default --app andrometa-backend
copilot env init --name production --profile default --app andrometa-backendCreate or modify the copilot/api/manifest.yml file to configure your service:
name: api
type: Load Balanced Web Service
image:
build: Dockerfile
port: 3000
http:
path: "/"
healthcheck:
path: "/health"
healthy_threshold: 3
unhealthy_threshold: 5
interval: 10s
timeout: 5s
cpu: 256
memory: 512
count: 2
exec: true
variables:
NODE_ENV: production
secrets:
JWT_SECRET: /andrometa/secrets/jwt-secret
DATABASE_URL: /andrometa/secrets/database-url
STRIPE_SECRET_KEY: /andrometa/secrets/stripe-secret-key
# Add all other secrets from your .env file
scaling:
min: 2
max: 10
cpu_percentage: 70- Create a pipeline for your application
copilot pipeline init- This will create a
copilot/pipeline.ymlfile. Modify it to fit your workflow:
name: andrometa-pipeline
version: 1
source:
provider: GitHub
properties:
branch: main
repository: https://github.com/yourusername/andrometa-backend
connection_name: my-github-connection
stages:
- name: test
test_commands:
- npm run test
- name: production
requires_approval: true
automated:
triggers:
- branch: main
test_commands:
- make test- Deploy your pipeline
copilot pipeline updateDeploy to your test environment:
copilot svc deploy --name api --env testOnce verified, deploy to production:
copilot svc deploy --name api --env productionFor the complete Andrometa backend deployment, you'll also need to set up:
- Amazon RDS for PostgreSQL - For your database
- Amazon S3 - For storing NFT images and other assets
- Amazon CloudFront - For content delivery
- AWS Lambda - For serverless functions like NFT generation
- Amazon ElastiCache - For caching frequently accessed data
- Amazon SES - For sending emails
These resources can be managed through the AWS Console
