PerBillion is a stock forecasting application built from a React frontend, an Express API gateway, a Spring Boot orchestration service, a Python statsmodels ML engine, MongoDB, and Nginx.
The current codebase is set up for local and Docker Compose development. Production deployment still requires rotated secrets, environment-specific hardening, monitoring, backups, and infrastructure review.
The ML engine exposes six selectable model types:
ARIMASARIMASARIMAXHOLT_WINTERS_ADDITIVEHOLT_WINTERS_MULTIPLICATIVEHOLT_WINTERS_DAMPED
It also supports auto model selection with diagnostics, AICc screening, rolling-origin cross-validation, stability checks, and composite scoring.
React/Vite frontend
|
Nginx
|
+--> Express API Gateway --> MongoDB
|
+--> Spring Boot Orchestrator --> Python ML Engine
|
MongoDB
Current runtime storage is MongoDB. A legacy PostgreSQL schema exists in database/postgres/, but PostgreSQL is not wired into the current Docker Compose stack or the active auth/user code path.
Do not commit real credentials. Copy .env.example to .env, replace all change_me values, and keep .env ignored.
Required for Docker Compose:
MONGO_PASSWORDJWT_SECRETALPHAVANTAGE_API_KEY
Optional for Atlas:
MONGODB_URI
If MONGODB_URI is unset, Docker Compose builds an in-network MongoDB URI using MONGO_PASSWORD. For Spring local overrides, use environment variables or a git-ignored services/spring-orchestrator/src/main/resources/application-local.properties.
cp .env.example .env
# edit .env and replace every change_me value
docker-compose up -d --buildAccess points:
- Frontend:
http://localhost - API gateway through Nginx:
http://localhost/api - API gateway health:
http://localhost/api/health - Spring Swagger UI:
http://localhost/swagger-ui.html - Spring OpenAPI JSON:
http://localhost/api-docs - ML engine direct health:
http://localhost:5001/health
API gateway:
cd services/api-gateway
npm install
npm run devSpring orchestrator:
cd services/spring-orchestrator
# requires Java 21
mvn spring-boot:runML engine:
cd services/ml-engine
pip install -r requirements.txt
python app.pyFrontend:
cd services/frontend
npm install
npm run devThere are 27 active REST handlers in the current source, excluding static file serving and the unused forecast_backup.ts file.
API gateway, 16 handlers:
GET /healthPOST /api/auth/registerPOST /api/auth/loginGET /api/user/profilePUT /api/user/profilePOST /api/user/profile-pictureGET /api/user/preferencesPUT /api/user/preferencesPOST /api/forecast/generateGET /api/forecast/historyGET /api/forecast/:forecastIdGET /api/education/lessonsGET /api/education/lessons/:lessonIdGET /api/education/progressPOST /api/education/progressGET /api/education/stats
Spring orchestrator, 6 handlers:
POST /api/v1/forecastsPOST /api/v1/forecasts/generateGET /api/v1/forecasts/{forecastId}GET /api/v1/forecasts/user/{userId}GET /api/v1/forecasts/ticker/{ticker}DELETE /api/v1/forecasts/{forecastId}
ML engine, 5 handlers:
GET /healthPOST /api/forecastPOST /api/diagnosticsPOST /api/validateGET /api/models
Implemented:
- JWT signing and verification with required
JWT_SECRET - bcrypt password hashing for registration/login
- authentication middleware on user and education routes
- global API rate limiting, auth rate limiting, and forecast generation rate limiting
- Helmet, CORS, request size limits, and basic input validation
Current limitations:
- Forecast gateway routes currently allow anonymous requests and use
anonymousas the user ID when no token is present. - Role helper code exists, but no role-gated route is currently wired.
- CSRF protection is not implemented.
- Production CORS, TLS, logging, backup, and secret-management settings must be reviewed per environment.
curl -X POST http://localhost/api/forecast/generate \
-H "Content-Type: application/json" \
-d '{
"ticker": "AAPL",
"forecastMonths": 12,
"modelType": "auto"
}'PerBillion/
├── services/
│ ├── frontend/ React TypeScript frontend
│ ├── api-gateway/ Express API gateway
│ ├── spring-orchestrator/ Spring Boot orchestration service
│ └── ml-engine/ Python statsmodels ML engine
├── database/
│ ├── mongodb/ MongoDB init scripts
│ └── postgres/ Legacy PostgreSQL schema, not wired by Compose
├── nginx/ Nginx reverse proxy configuration
├── docker-compose.yml
├── .env.example
└── README.md
- Rotate any credential that has ever been committed or shared.
- Store secrets in provider secret managers or environment variables, never in Git.
- Set a strong
JWT_SECRET. - Configure production CORS origins.
- Configure TLS certificates.
- Review Nginx security headers.
- Set up database backups.
- Set up centralized logs, metrics, and alerting.
- Re-run secret scans on the working tree and full Git history after any history rewrite.
Proprietary - All rights reserved.