Deployment Guide
Relevant source files
The following files were used as context for generating this wiki page:
This guide provides technical instructions for deploying the NEXUS digital account and trial tracking system. NEXUS is a full-stack application consisting of a React-based frontend and a FastAPI backend, utilizing MongoDB as the primary data store.
The deployment process involves configuring environment variables, installing dependencies for both the Python backend and JavaScript frontend, and executing build scripts to generate production-ready assets. The system architecture relies on JWT-based authentication to secure communication between the glassmorphic user interface and the RESTful API service.
Sources: backend/server.py:16-24, frontend/package.json:34-75, frontend/src/App.js:7-10
Infrastructure Requirements
NEXUS requires three primary infrastructure components for a successful deployment:
- Database Layer: A MongoDB instance (accessible via a
MONGO_URLconnection string). - Backend Layer: A Python 3 environment capable of running FastAPI with an ASGI server.
- Frontend Layer: A Node.js environment for building the React application and a web server (like Nginx) to host the static assets.
System Architecture Flow
The following diagram illustrates the interaction between components during deployment and runtime:
This diagram shows how the frontend assets are served to the browser, which then communicates with the FastAPI backend secured by JWT.
Sources: backend/server.py:22-30, frontend/src/App.js:12-65, frontend/README.md:21-27
Backend Deployment
The backend is built with FastAPI and uses the motor driver for asynchronous MongoDB interactions. Deployment requires setting up the Python environment and configuring sensitive credentials.
Environment Configuration
The backend looks for a .env file located in the same directory as the server script.
| Variable | Description | Default/Example |
|---|---|---|
MONGO_URL | MongoDB connection string | mongodb://localhost:27017 |
DB_NAME | Name of the MongoDB database | nexus_db |
JWT_SECRET_KEY | Secret key for signing tokens | nexus-super-secret-key... |
CORS_ORIGINS | Allowed origins for cross-origin requests | http://localhost:3000 |
Sources: backend/server.py:16-35, backend/server.py:461-468
Build and Execution
To deploy the backend:
- Ensure Python 3.x is installed.
- Install dependencies (FastAPI, Motor, Pydantic, PyJWT, Bcrypt, python-dotenv).
- Run the application using an ASGI server like Uvicorn.
# Example execution
uvicorn server:app --host 0.0.0.0 --port 8000
Sources: backend/server.py:26-30, backend_test.py:20-24
Frontend Deployment
The frontend is a React application managed by craco (Create React App Configuration Override) to support Tailwind CSS and custom PostCSS configurations.
Build Scripts
The package.json file defines the standard build lifecycle:
| Command | Action | Description |
|---|---|---|
npm run build | craco build | Compiles React and Tailwind into minified production files in /build. |
npm start | craco start | Starts the development server. |
npm test | craco test | Launches the test runner. |
Sources: frontend/package.json:76-80, frontend/README.md:21-27
Frontend Environment Variables
During the build process, the frontend requires the backend API URL to be injected.
// From frontend/src/App.js
const BACKEND_URL = process.env.REACT_APP_BACKEND_URL;
const API = `${BACKEND_URL}/api`;
Sources: frontend/src/App.js:7-8
Security Configuration
Proper deployment must ensure that authentication mechanisms are correctly initialized. NEXUS utilizes bcrypt for password hashing and HS256 for JWT signing.
Authentication Flow
Deployment Checklist
- Database: Verify MongoDB is running and the
MONGO_URLinbackend/.envis correct. - Backend Dependencies: Ensure
bcryptandPyJWTare installed for security operations. - Frontend Build: Execute
npm run buildwithin the/frontenddirectory. - CORS: Ensure
CORS_ORIGINSin the backend environment includes the production domain of the frontend. - Static Hosting: Serve the
frontend/builddirectory using a production-grade web server.
Sources: backend/server.py:461-468, frontend/package.json:1-110, frontend/README.md:21-30
Conclusion
Successful deployment of NEXUS depends on the synchronization of the FastAPI backend and the React frontend. By configuring the environment variables correctly and executing the production build scripts, the system provides a secure, glassmorphic environment for digital account management. Developers should ensure the JWT_SECRET_KEY is rotated from its default value before production use.
Sources: backend/server.py:33-35, frontend/src/App.js:475-498