This repository contains the foundational code for AobaSpace's Platform Core, divided into a Next.js/React frontend and a NestJS backend. This setup is designed for local development using VS Code and Docker Compose.
aobaspace/
├── .vscode/ # VS Code workspace settings and recommendations
├── aobaspace-web/ # Next.js/React Frontend (User Portal, Website)
├── aobaspace-api/ # NestJS Backend (APIs for User, Instance, Billing Management)
├── docker-compose.yml # Orchestrates local development environment (Frontend, Backend, PostgreSQL)
├── README.md # This file
└── .gitignore # Standard Git ignore rules
Before you begin, ensure you have the following installed:
- Node.js (LTS version, e.g., 18.x or 20.x) & npm (or Yarn/pnpm)
- Docker Desktop (includes Docker Engine and Docker Compose)
- VS Code (Visual Studio Code)
-
Clone the Repository (or create the structure manually): If you're starting from scratch, create the
aobaspaceroot folder and theaobaspace-web,aobaspace-api, and.vscodesubfolders. Then, create the files as specified in the project structure. -
Navigate to the root directory:
cd aobaspace -
Create Environment Files: Create
.envfiles in bothaobaspace-web/andaobaspace-api/based on their respective.env.examplefiles.-
aobaspace-web/.env:NEXT_PUBLIC_API_URL=http://localhost:3000/api
-
aobaspace-api/.env:PORT=3000 # Database Configuration POSTGRES_HOST=postgres POSTGRES_PORT=5432 POSTGRES_USER=user POSTGRES_PASSWORD=password POSTGRES_DB=aobaspace_db # Keep DATABASE_URL for local development outside Docker if needed DATABASE_URL="postgresql://user:password@localhost:5432/aobaspace_db" # Application Specific Settings CORS_ORIGIN=http://localhost:3001 # Frontend URL for CORS # Auth0 / Firebase / Other SSO Credentials (placeholders) AUTH0_DOMAIN= AUTH0_CLIENT_ID= AUTH0_CLIENT_SECRET= # Stripe API Keys (placeholders) STRIPE_SECRET_KEY= STRIPE_WEBHOOK_SECRET= # JWT Secret for internal tokens (if you implement custom JWTs) JWT_SECRET=yourSuperSecretJwtKey # Dummy Access Token for testing/development (replace with real JWT generation in production) DUMMY_ACCESS_TOKEN=dummy-jwt-token-abc123
Note: The
aobaspace-api/.envfile is now the single source of truth for these environment variables for both the backend API and the PostgreSQL database service when running with Docker Compose.
-
-
Install Dependencies (Locally - For Running Outside Docker Compose): These steps are primarily for when you want to run the frontend or backend directly on your host machine for faster development iteration, bypassing Docker for the application code. If you are always using
docker-compose up --build, these local installs are not strictly necessary asnpm installhappens within the Dockerfile.- For Frontend (
aobaspace-web):cd aobaspace-web npm install # or yarn install / pnpm install cd ..
- **For Backend (
aobaspace-api):cd aobaspace-api npm install # or yarn install / pnpm install npm install @nestjs/config # Ensure NestJS config package is installed npm install bcryptjs @types/bcryptjs # NEW: Install bcryptjs for password hashing cd ..
- For Frontend (
-
Start Docker Compose Environment (Recommended for Full Stack): This will build the Docker images (if not already built) and start all services (PostgreSQL, Backend API, Frontend Web). Crucially, the Dockerfiles now handle copying the built application code, so local volume mounts for the app directories have been removed from
docker-compose.yml.docker-compose up --build
- Use
docker-compose upwithout--buildfor subsequent starts if you haven't changed Dockerfiles or source code. - Use
docker-compose downto stop and remove containers.
- Use
You might encounter npm warn deprecated messages during npm install. These are warnings, not errors, and typically do not prevent your project from installing or running. They often indicate:
- Transitive Dependencies: A package that one of your direct dependencies relies on is deprecated.
- Outdated Tools: A tool like ESLint might have a newer major version available, but your current configuration (e.g.,
eslint-config-next) might be tied to an older, still functional version.
Recommended Steps to Mitigate Warnings:
-
Run
npm audit fix: Afternpm installin each project, runnpm audit fix. This command attempts to automatically resolve known security vulnerabilities by updating dependencies to compatible, non-vulnerable versions. This can sometimes also resolve deprecation warnings.cd aobaspace-web npm audit fix cd .. cd aobaspace-api npm audit fix cd ..
- If
npm audit fixsuggestsnpm audit fix --force, use it with caution as it can potentially introduce breaking changes by overriding dependency resolutions.
- If
-
Keep Direct Dependencies Updated: Regularly update your direct dependencies (
next,react,eslint,tailwindcss,@nestjs/*,typeorm, etc.) to their latest stable versions. Maintainers of these libraries often update their own transitive dependencies, which can resolve deprecation warnings down the line. -
Acknowledge Transitive Warnings: For some warnings, especially those related to transitive dependencies or older tool versions that your primary frameworks depend on, there might not be an immediate action you can take. You are reliant on the upstream libraries to update their internal dependencies. The project should still function as expected.
You specifically reported a critical vulnerability in next <=14.2.29 with a fix available via npm audit fix --force to next@14.2.30.
Action for this specific issue:
- Navigate to the
aobaspace-webdirectory:cd aobaspace-web - Execute the forced fix:
This command will update
npm audit fix --force
nextto14.2.30(or a newer patched version if available) in yournode_modulesandpackage-lock.json, overriding thepackage.jsonversion range if necessary. - Manually update
package.json(Highly Recommended): After runningnpm audit fix --force, it's good practice to update youraobaspace-web/package.jsonto reflect the new, patched version ofnext.- Open
aobaspace-web/package.json. - Change the line:
"next": "^14.2.4"to:"next": "14.2.30"(or the exact versionnpm audit fix --forceinstalled). - Save the file.
- Run
npm installagain inaobaspace-webto ensurepackage-lock.jsonis perfectly aligned with the updatedpackage.json.
- Open
This ensures your project is on the secure version and avoids the audit warning in the future.
If you're getting "Cannot find module" errors at runtime within the Docker containers, it almost always means the npm run build step inside the Dockerfile failed, or the built artifacts are not being correctly copied/accessed.
Steps to Diagnose Cannot find module errors:
-
Stop all running Docker Compose services:
docker-compose down
-
Force a clean rebuild for
aobaspace-apiand inspect logs:docker-compose build --no-cache aobaspace-api
- Carefully review the output. Look for any
error TSmessages (TypeScript compilation errors) ornpm ERR!messages during theRUN npm installorRUN npm run buildsteps. - If you see errors, copy the full output and share it.
- Carefully review the output. Look for any
-
Force a clean rebuild for
aobaspace-weband inspect logs:docker-compose build --no-cache aobaspace-web
- Carefully review the output. Again, look for any
error TSmessages ornpm ERR!messages during theRUN npm installorRUN npm run buildsteps. - If you see errors, copy the full output and share it.
- Carefully review the output. Again, look for any
Common Causes of Build Failures in Docker:
- Missing Dependencies: Ensure all
dependenciesanddevDependenciesare correctly listed inpackage.jsonfor both projects. Ifnpm installfails in the Dockerfile, the build will break. - TypeScript Compilation Errors: If your TypeScript code has errors,
npm run buildwill fail. Ensure your code compiles locally first (npm run buildin each project directory). - Incorrect File Paths in Dockerfile: While the provided Dockerfiles are standard, double-check that the
COPYcommands are correctly pointing to the source files relative to the Dockercontext.
Once you've diagnosed and fixed any build errors, you can then try docker-compose up --build again.
You can also run the applications directly on your host machine for faster development feedback.
-
Start PostgreSQL (via Docker Compose):
docker-compose up -d postgres
-
Run Backend API (
aobaspace-api):cd aobaspace-api npm run start:dev # For development with hot-reloading # or npm run start:prod for production build
- Ensure your
DATABASE_URLinaobaspace-api/.envis set topostgresql://user:password@localhost:5432/aobaspace_dbif running outside Docker.
- Ensure your
-
Run Frontend Web (
aobaspace-web):cd aobaspace-web npm run dev- Ensure your
NEXT_PUBLIC_API_URLinaobaspace-web/.envis set tohttp://localhost:3000/apiif running outside Docker.
- Ensure your
- Frontend (AobaSpace Portal):
http://localhost:3001 - Backend (AobaSpace API):
http://localhost:3000/api(e.g.,http://localhost:3000/api/usersorhttp://localhost:3000/api/auth)
Open the .vscode/extensions.json file in VS Code and install the recommended extensions. These will significantly enhance your development experience with ESLint, Prettier, Docker, Kubernetes, and Tailwind CSS.