Skip to content

gforgabs/ai_assisted_coding_interview

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Brex AI Assisted Interview Playground

This is a monorepo containing both the backend and frontend components for the Brex interview playground - a simple message system to get you started coding.

Project Structure

brex-interview-playground/
├── backend-kotlin/    # Kotlin Spring Boot Backend
│   ├── src/
│   │   └── main/
│   │       ├── kotlin/
│   │       │   └── brex/interview/
│   │       │       ├── config/      # Application configuration
│   │       │       ├── controller/  # REST controllers
│   │       │       ├── graphql/     # GraphQL resolvers
│   │       │       ├── model/       # Domain models
│   │       │       ├── dto/         # Data transfer objects
│   │       │       ├── repository/  # Data access layer
│   │       │       └── service/     # Business logic
│   │       └── resources/
│   │           ├── graphql/         # GraphQL schema
│   │           └── schema/          # Database schema
│   └── test/                        # Test files
├── backend-python/   # Python FastAPI Backend (Alternative)
│   ├── src/
│   │   └── app/
│   │       ├── api/
│   │       │   ├── graphql/     # GraphQL schema and resolvers
│   │       │   └── rest/        # REST API endpoints
│   │       ├── database/        # Database configuration
│   │       ├── models/          # SQLAlchemy models
│   │       └── schemas/         # Pydantic schemas
│   └── tests/                   # Test files
├── backend-go/      # Go Backend (Alternative)
│   ├── cmd/
│   │   └── api/                 # Application entry point
│   └── internal/
│       ├── config/              # Configuration constants
│       ├── database/            # Database initialization and seeding
│       ├── dto/                 # Data transfer objects
│       ├── graphql/             # GraphQL schema and resolvers
│       ├── model/               # Domain models
│       ├── repository/          # Data access layer
│       ├── rest/                # REST API handlers
│       └── service/             # Business logic
└── frontend/        # T3 Stack Frontend
    ├── src/
    │   ├── app/              # Next.js app router pages
    │   ├── components/       # React components
    │   ├── graphql/         # GraphQL queries and mutations
    │   ├── lib/             # Utility functions and configurations
    │   ├── styles/          # Global styles and Tailwind config
    │   └── types/           # TypeScript type definitions
    ├── public/              # Static assets
    └── tests/               # Test files

Backend Options

You can choose between three backend implementations:

Kotlin Spring Boot Backend

The Kotlin backend is a Spring Boot application that provides:

  • REST and GraphQL APIs for simple message operations
  • H2 in-memory database
  • Basic message CRUD functionality

Python FastAPI Backend (Alternative)

The Python backend is a FastAPI application that provides:

  • REST and GraphQL APIs for simple message operations
  • SQLAlchemy with SQLite database
  • Strawberry GraphQL integration
  • Pydantic for data validation

Go Backend (Alternative)

The Go backend is a Gorilla Mux-based application that provides:

  • REST and GraphQL APIs for simple message operations
  • GORM with SQLite database
  • gqlgen for GraphQL code generation
  • Clean architecture with repository and service layers

Frontend (T3 Stack)

The frontend is built with the T3 Stack, featuring:

  • Next.js 14 with App Router
  • TypeScript for type safety
  • Tailwind CSS for styling
  • Apollo Client for GraphQL integration
  • GraphQL Code Generator for type-safe GraphQL operations

Prerequisites

For Kotlin backend:

  • JDK 11 or higher
  • Gradle (for building the project)

For Python backend:

  • Python 3.8 or higher
  • Poetry (for dependency management)

For Go backend:

  • Go 1.21 or higher

For frontend:

  • Node.js 18 or higher
  • npm or yarn

Development

Running the Backend

Option 1: Kotlin Backend

  1. Build the Project:

    cd backend-kotlin
    ./gradlew build
  2. Run the Application:

    ./gradlew bootRun --console=plain
  3. Access the Application:

    • REST API: http://localhost:8080/api/
      • i.e. http://localhost:8080/api/messages/latest
    • GraphQL API: http://localhost:8080/graphql

Option 2: Python Backend

  1. Install Poetry (if not already installed):

    curl -sSL https://install.python-poetry.org | python3 -
  2. Install Dependencies:

    cd backend-python
    poetry install
  3. Run the Development Server:

    poetry run uvicorn src.app.main:app --reload --port 8080
  4. Access the Application:

    • REST API: http://localhost:8080/api/
      • i.e. http://localhost:8080/api/messages/latest
    • GraphQL Playground: http://localhost:8080/graphql

Option 3: Go Backend

  1. Install Dependencies:

    cd backend-go
    go mod download
  2. Generate GraphQL Code (first time or after schema changes):

    GOPROXY=https://go-proxy-public.golang.org,direct go run github.com/99designs/gqlgen@v0.17.86 generate
  3. Run the Application:

    GOPROXY=https://go-proxy-public.golang.org,direct go run cmd/api/main.go
  4. Access the Application:

    • REST API: http://localhost:8080/api/
      • i.e. http://localhost:8080/api/messages/latest
    • GraphQL API: http://localhost:8080/graphql

Running the Frontend

  1. Install Dependencies:

    cd frontend
    npm install
  2. Start Development Server:

    npm run dev
  3. Access the Application: Visit http://localhost:3000 to access the application

GraphQL Development

Generating TypeScript Types

The project uses GraphQL Code Generator to automatically generate TypeScript types from the GraphQL schema. Make sure the backend is running when run this command.

npm run codegen

Testing GraphQL

  • Access the GraphQL IDE:

    • For Kotlin backend: http://localhost:8080/graphiql
    • For Python backend: http://localhost:8080/graphql
    • For Go backend: http://localhost:8080/graphql
  • Example Query:

    query {
      latestMessages(limit: 10) {
        id
        content
        createdAt
      }
    }
  • Example Mutation:

    mutation {
      createMessage {
        id
        content
        createdAt
      }
    }

Running Tests

Kotlin Backend Tests:

cd backend-kotlin
./gradlew test

Python Backend Tests:

cd backend-python
poetry run pytest

Go Backend Tests:

cd backend-go
go test ./...

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 31.1%
  • Go 22.6%
  • Kotlin 14.3%
  • Python 14.1%
  • HTML 10.0%
  • JavaScript 7.5%
  • CSS 0.4%