Skip to content

Recursion-Labs/atlas

Repository files navigation

Atlas

Atlas is a full‑stack web application developed by Recursion Labs. It consists of a Node/Express API (under the app/ folder), a Next.js frontend (under web/), and infrastructure managed via Terraform (infra/). The repository is structured using Turborepo for monorepo management.


🧱 Architecture Overview

The project is divided into several logical areas:

  • app/ – Backend service written in TypeScript using Express. Includes controllers, middleware, models, and configuration.
  • web/ – Frontend built with Next.js and TailwindCSS. It provides UI components, pages, and global styles.
  • infra/ – Terraform configurations for provisioning cloud resources (Google Cloud / Firebase, Cloud Run, Firestore, etc.).
  • pkg/ – Shared TypeScript definitions and utilities, such as environment variables and custom prompts.
  • __test__/ – Integration or end‑to‑end tests (simple HTML file present in repo).
  • scripts/ – Utility scripts used during development or deployment.
  • keys/ – Service account credentials and Terraform state keys (excluded from source control).

Each workspace folder (app, web, infra) contains its own package.json or configuration to allow independent development while still benefiting from shared tooling.


🚀 Getting Started

Prerequisites

  • Node.js (20.0.x or later recommended)
  • Yarn (preferred) or npm
  • Terraform (for infrastructure)
  • Google Cloud credentials (a service account JSON file located in keys/googleServiceAccount.json)
  • tf-key.json for encrypting Terraform state (managed outside version control)

Initial Setup

  1. Clone the repository and install dependencies at the root:

    git clone https://github.com/Recursion-Labs/atlas.git
    cd atlas
    yarn install
    # or: npm install
  2. Install packages for each workspace if you prefer independent installs:

    cd app && yarn install
    cd ../web && yarn install
  3. Create a .env or configure environment variables as needed. See pkg/config/envVars.ts for expected keys.

Local Development

Backend (app)

cd app
# start in development mode with nodemon
npm run dev
# or yarn dev

The backend listens on port 3001 by default and exposes routes under /api (see app/routes/**). Swagger documentation is available at /swagger.json and served by swagger.js.

Frontend (web)

cd web
npm run dev
# or yarn dev

Next.js starts on port 3000. Open http://localhost:3000 to view the application. Modify components under web/app/components.

Monorepo Tooling

Turborepo commands can orchestrate tasks across packages:

npx turbo run build   # build all workspaces
npx turbo run lint
npx turbo run test

🛠️ Development Details

Backend Structure (app/)

  • Configurationapp/config contains environment, logging, and Firebase setup.
  • Controllersapp/controllers handle incoming HTTP requests (e.g. auth.controller.ts, user.controller.ts).
  • Routes – Organized by feature under app/routes with nested modules for auth and user.
  • Middleware – e.g. auth.middleware.ts to protect routes using JWT or Firebase auth.
  • Modelsuser.model.ts defines data shapes and interacts with Firestore or other storage.
  • Services – Business logic lives here (folder present but may be empty or fleshed out).
  • Handlersasync.handlers.ts and error.handlers.ts centralize promise handling and error responses.

The backend uses tsconfig.json with path aliases defined in moduleAlias.ts for cleaner imports.

Frontend Structure (web/)

  • The Next.js app follows the App Router paradigm with app/layout.tsx and app/page.tsx.
  • Global styles are in app/globals.css.
  • Each feature (e.g. command-center) has its own folder under app.
  • UI components like Navbar, Hero, and GlobeView are reusable and pulled into pages.
  • TypeScript is configured via tsconfig.json, and additional type definitions live in pkg/@types.

Shared Code (pkg/)

This package contains:

  • @types/config.d.ts – Type definitions for environment variables.
  • config/envVars.ts – Utility to load/validate environment variables.
  • prompts/ – Custom CLI prompt definitions (used by scripts or dev tooling).

These modules are referenced using workspace aliases and help maintain DRY principles.


🌐 Infrastructure (infra/)

Terraform is used to provision the following resources in a Google Cloud project:

  • Cloud Run services for backend and frontend (if containerized)
  • Firestore database
  • IAM roles and service accounts
  • Other components may include Pub/Sub, Storage buckets, etc.

Folder hierarchy:

infra/
  environments/
    dev/        # development-specific tf state and variables
    prod/       # production configuration
  modules/      # reusable Terraform modules, e.g., cloudrun, firestore
  vars.tf
  versions.tf   # Terraform provider versions

To deploy infrastructure:

cd infra/environments/dev
terraform init
terraform plan -var-file="terraform.tfvars"
terraform apply -var-file="terraform.tfvars"

⚠️ State files (e.g. terraform.tfstate) are not checked into version control in prod. Use remote backends (GCS or Terraform Cloud) for collaboration.


✅ Testing & Quality

  • Unit and integration tests should reside under __test__/ or within each package's testing framework.
  • Linting, formatting, and type checking are configured via package.json scripts and tsconfig.json.
  • Run all checks with:
    yarn lint
    yarn typecheck
    yarn test

📦 Deployment

  • Frontend – Deployed via Next.js build output. Could be hosted on Vercel, Cloud Run, or static hosting.
  • Backend – Built into a Docker container and deployed to Cloud Run (see infra/modules/cloudrun).
  • CI/CD pipelines are defined in .github/workflows or similar (not shown in repo). Use GitHub Actions or other tools to automate.

🔗 Useful Scripts

Examples of commands in scripts/:

  • bootstrap.sh – set up environment variables
  • deploy.sh – kick off a manual deploy

Inspect the scripts/ directory for project-specific helpers.


📝 Contributing

  1. Fork the repo and create a feature branch.
  2. Run linting and tests before submitting a PR.
  3. Ensure code follows the existing style and includes documentation where appropriate.

Please refer to CONTRIBUTING.md (if present) for detailed guidelines.


📄 License

This project is licensed under the MIT License. See the LICENSE file for details.


For questions, reach out to the Recursion Labs team. Happy coding!

About

AI-powered disaster simulation platform that visualizes earthquakes, floods, cyclones, and wildfires on an interactive Earth map using natural language scenarios.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors