AWS Builder Center
Used Ruby on Rails and AWS Cognito to build a Mini-Jira

Used Ruby on Rails and AWS Cognito to build a Mini-Jira

I built a mini Jira for my portfolio over a weekend because, apparently my side projects needed a project manager. It was my first time using Amazon Cognito to protect an admin dashboard, with Ruby on Rails running project updates in AWS Lambda and DynamoDB storing the data. Public reads go through the Next.js cache, so visitors can check what I’m building without invoking Lambda.

I was curious about Ruby, so I built a tiny Jira for my portfolio

A weekend project with Ruby on Rails, AWS Lambda, DynamoDB, and my first experience with Amazon Cognito.

My portfolio shows projects I've built, but I wanted it to show what I'm working on, too. Something visitors could open and immediately understand: this project is an idea, this one is underway, and this one is finally finished.

That became Buildlog, a small Jira-style board with four stages: Not Started, In Progress, In Review, and Finished. Visitors can browse projects, filter them, and see details. I get an admin dashboard where I can create, edit, publish, archive, move, and delete them.
My side projects now have a project manager. Unfortunately, it's still me.
I picked Ruby because I was curious about it. My portfolio already uses TypeScript and Next.js, so I had a familiar way to build this. But a small feature with a real purpose seemed like a good excuse to try another language. I'd have to write useful code, connect it to my existing application, and deal with whatever broke along the way.

Rails gave that experiment some structure. I could work with its routing and controller conventions while keeping the frontend I already had. Amazon Cognito was another first for me, and protecting an actual admin dashboard gave me a reason to understand more than the login screen.

The result is a working proof of concept with a real AWS backend. Here's how the pieces fit together, including the choices that keep it small and the limitations that come with them.
The first design decision came from the expected traffic. Visitors might read the board throughout the day, while I'd only update it occasionally. Sending every visitor through Rails would make the busiest part of the feature depend on a backend whose main job is handling my edits.
So public reads and administrative operations take different paths:

Activity
Request flow
Read the public board
Visitor → Next.js on Vercel → cached public board data
Fill or refresh that cache
Next.js server → public snapshot in DynamoDB
Manage projects
Admin browser → authenticated Next.js server → API Gateway → Rails on Lambda → DynamoDB
Public reads never invoke the Rails Lambda, including cache misses. The private dashboard does use the protected backend, and its responses aren't shared through the public cache.
That split also let me keep Next.js responsible for the interface. Rails doesn't render the board or serve React assets. It owns the project's business rules and writes.

The Ruby service is a small Rails API application using Action Pack and Railties. Its controllers inherit from  ActionController::API . Rails supplies routing, request handling, and JSON responses; the application's validation rules live in the backend code. Rails supports this narrower API-only setup without requiring a server-rendered frontend.  Rails API-only application guide 
I didn't use Active Record here. Data access goes through the AWS SDK for Ruby to DynamoDB, so there are no SQL migrations or database connection pools in this service. That means this project explores part of Rails, rather than its entire database-backed application workflow.
Running it on Lambda needs a small translation layer. API Gateway delivers an event containing the request method, headers, path, and body. A Ruby handler converts that event into a Rack environment, the interface Rails understands. It puts the request body into an input stream, calls the Rails application, then converts the returned status, headers, and body into Lambda's response format.

There isn't a continuously running web server waiting for connections inside the function. The handler calls Rails when an invocation arrives.

The application loads outside the handler so a warm execution environment can reuse it. A cold start still has to initialize Ruby and Rails. Reuse is possible, not guaranteed, and I haven't measured enough to make performance claims. For a dashboard I use occasionally, that was a reasonable tradeoff.  Lambda execution environment lifecycle 

A plain Ruby handler could have fewer dependencies. I chose Rails because learning its conventions was part of the project. Keeping that reason explicit is more useful than pretending the framework was the only way to update a few records.

The deployment package is built in a Linux environment compatible with the Lambda runtime. That's especially relevant when gems include native dependencies: a package assembled on my Windows machine isn't automatically suitable for Lambda.

Authentication needed more thought than putting a login button above the dashboard. A route can be reachable on the internet while its contents and operations remain protected. Keeping its address out of the UI doesn't provide that protection.

I used a Cognito user pool with self-registration disabled and an admin group for the owner account. The infrastructure is also configured to require authenticator-app MFA. Cognito handles the credential entry; my application doesn't implement its own password database.

The sign-in flow uses the authorization code grant with PKCE. Before redirecting the browser to Cognito, the Next.js server creates a random code verifier and a challenge derived from it:

challenge = BASE64URL(SHA256(verifier))
The challenge goes into the authorization request. After login, Cognito returns an authorization code, and the server exchanges that code for tokens using the original verifier. Cognito checks that the verifier matches the earlier challenge. This helps prevent an intercepted code from being redeemed without the verifier.  Cognito's PKCE flow 

The application also creates  state  and  nonce  values.  state  connects the callback to the login attempt that started it.  nonce  binds the returned ID token to that authentication flow. They serve different purposes from PKCE, so I keep all three checks.

The temporary login values live in a short-lived, encrypted, HttpOnly cookie. When Cognito sends the browser back, the server validates the flow and the ID token, including its signature, issuer, audience, expiration, nonce, and admin-group membership.

There are three tokens involved, with different jobs. The ID token supplies identity information. The access token authorizes requests to the backend. The refresh token lets the server obtain fresh short-lived tokens during the session. Using an ID token as a general-purpose API credential would blur those responsibilities.  Cognito access tokens 

The browser receives an opaque session cookie. The access and refresh tokens stay on the server in a separate DynamoDB sessions table. The database key is a hash of the random session identifier, rather than the cookie value itself.

That cookie is HttpOnly, Secure over HTTPS, and SameSite=Lax. HttpOnly keeps browser JavaScript from reading it; it doesn't make every possible browser attack disappear. For changes to projects, the Next.js server also checks the request's origin before forwarding anything to AWS.
The application enforces its session expiration when reading the session record. DynamoDB TTL handles eventual cleanup, but expired records can remain in the table for a while. Their presence mustn't mean the session is still valid.  DynamoDB TTL behavior 

Once signed in, a save still has to pass authorization. The Next.js server retrieves the session's access token and forwards the request to API Gateway. Its JWT authorizer checks the token against the configured Cognito issuer and client, with read or write scopes required for the appropriate operations. Invalid requests can be rejected before Lambda runs.  API Gateway JWT authorizers 
Rails performs its own token validation and checks the access-token type, expected client, admin group, and required scope. A valid signature means the token came from a trusted issuer. The remaining checks establish whether that token should be allowed to perform this operation.
The data model is deliberately small. The projects table contains a private board record, a public board record, and records used to recognize retried requests.

The private record contains the complete project collection, including drafts and private notes. The public record is a projection: a separate representation containing only the projects and fields that visitors may see. Building that projection in Ruby looks like this:

public_projects = projects
.select { |project| project["visible"] && !project["archived"] }
.map { |project| project.slice(*PUBLIC_FIELDS) }
.sort_by { |project| project["position"] }
 PUBLIC_FIELDS  is an explicit allowlist. It includes things like the title, description, stage, tags, and project links. Private notes aren't included, and unpublished or archived projects don't enter the public snapshot at all.

This matters before rendering. Hiding a field with CSS would still send it to the visitor. In this design, the visitor-facing read doesn't fetch the private board record. The Next.js server also validates the public data against its schema before caching it.

When I save a project, Rails validates the input again, even though the frontend already checks it. That covers allowed fields, text lengths, valid stages, tags, positions, and HTTPS links. Browser validation gives quick feedback; backend validation enforces the rules for every caller.
An update carries the project version I last read. If another edit has already advanced that version, the backend returns a conflict instead of silently overwriting the newer data. Deletion uses the same version check.

There's a second concurrency check at the board level. Because this prototype stores projects together in an aggregate record, even edits to different projects could otherwise overwrite each other. A conditional write checks the board revision before accepting the replacement snapshot.
The actual save uses a DynamoDB transaction to write the private board, its public projection, and a request receipt together. Either all three writes succeed or none do. That prevents a successful database update from leaving the private and public records at different revisions.  DynamoDB transactions 

The receipt handles retries. Each mutation carries an idempotency key, and the backend stores a fingerprint of the operation with its result. While that receipt is retained, retrying the same operation with the same key returns the saved result. Reusing the key with different input produces a conflict. This covers the awkward case where the database accepted a change but the client never received the response.

Keeping the board in aggregate records makes a small public snapshot cheap to fetch and straightforward to publish. It also imposes limits: every change rewrites the snapshot, item size is bounded, and competing writers share a revision. I'd revisit this model before turning the feature into a multi-user project management product.

The Next.js side caches that public snapshot. This implementation uses Next.js 15 and  unstable_cache , which can cache the result of a database operation. A shortened version of the setup is:

const readBoard = unstable_cache(
readPublicSnapshot,
["public-board-v1"],
{ tags: ["public-board"], revalidate: 300 }
);
Here,  readPublicSnapshot  represents the server-only DynamoDB read and public-schema validation. On a cache hit, the stored result is reused. On a miss, the server reads the public item directly from DynamoDB and caches it. This is the Next.js Data Cache, which is distinct from browser caching and from caching the rendered page.  Next.js 15    unstable_cache  

After a successful admin mutation, the Next.js server invalidates the board's cache tag and rendered page path. A subsequent read can then populate the cache from the updated public snapshot. The board page also uses incremental static regeneration.

The five-minute revalidation setting provides a fallback on subsequent traffic. It isn't a timer that pushes updates into every browser, and it isn't a strict freshness guarantee: background revalidation can fail and leave older data available. Existing open tabs still need a refresh or navigation to obtain new content.  Next.js 15 caching and revalidation 

There is also a boundary the database transaction can't cover. DynamoDB may commit successfully, then the process may fail before Vercel's cache is invalidated. Request receipts make retries manageable, and time-based revalidation helps recover stale reads. The database transaction and cache invalidation are separate operations.

Caching doesn't mean every public request involves zero server work, either. A public data request can still execute Next.js code to retrieve a cached result. The useful property here is that public traffic bypasses Rails and can reuse the same sanitized data.
An earlier design included publishing a JSON snapshot to S3. I removed that step because the public DynamoDB record and Next.js cache already covered the requirement. S3 still has a deployment role for private packaged code artifacts, but it isn't part of the board's data publishing or visitor read flow.

Cognito isn't the identity system used when the Next.js server reads DynamoDB. That connection uses Vercel's OIDC federation with AWS STS to obtain temporary AWS credentials. Cognito authenticates the person using the dashboard; federation authenticates the deployed application.  Vercel's AWS OIDC integration 

The AWS trust policy is restricted to the intended Vercel project and environment. The web application's IAM role can read the public board item and manage its session records. It cannot read the private board item or write project data directly. The Lambda execution role has the permissions needed for board operations. This feature therefore doesn't need long-lived AWS access keys stored in Vercel.

I defined the infrastructure in AWS CDK using TypeScript: the tables, Cognito configuration, HTTP API, Lambda, and IAM permissions. Using TypeScript for infrastructure doesn't constrain the application runtime to TypeScript. It let me use familiar tooling to describe AWS resources while trying Ruby in the service itself.

Cost influenced the design, but I haven't benchmarked it against every hosting option. Lambda avoids an always-running Rails instance for this workload, and caching reduces repeated database reads. Requests, execution time, storage, backups, logs, authentication, and hosting can still generate charges. This is a design for a small workload, not a promise of a zero-dollar bill.  AWS Lambda pricing 

Two bugs were especially useful reminders that the boundaries matter.
First, DynamoDB numbers came back through the Ruby SDK as  BigDecimal  values. During JSON serialization, an integer version could become a string, so the frontend received  "2"  where it expected  2 . The fix normalizes those values before serialization, recursively handling nested objects and arrays. A test now covers that round trip.

Second, a custom asset-cache rule caused a hydration error while I was personalizing the UI. The server rendered the updated markup, but the browser reused an older JavaScript bundle. React was comparing two versions of the page. Removing the inappropriate long-lived cache override let Next.js manage its assets, and a hard refresh cleared the stale bundle. That was a browser asset-cache problem, separate from the board's server-side Data Cache.

The backend tests cover mutations, conflicting edits, retried requests, public-data filtering, invalid input, numeric serialization, and token authorization. I also exercised the local frontend against the deployed AWS backend and checked the public cache's miss-to-hit behavior. The hosted Vercel deployment still needs its final end-to-end check; local cache behavior alone doesn't establish that the deployed identity and invalidation paths work.

There are deliberate gaps. This is a single-owner board without real-time collaboration, and the aggregate data model fits that scope. Cold-start measurements and the final hosted verification are still work to do.

I started with curiosity about Ruby and a feature I wanted on my portfolio. It gave me a small Rails application I can keep working on, a first practical experience with Cognito, and a much clearer understanding of what happens between clicking Save and somebody else seeing the result.

Now I just have to move the projects across the board... :)
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article