Project Workshop — TradeFlow Fintech Platform
This is a portfolio submission, not a copy-and-run tutorial. A reviewer must be able to clone it, configure it without guessing, execute the critical path, observe a deliberate failure, run the tests, and understand the most important…
- What you are building
- Architecture
- Acceptance criteria
- Suggested repository structure
- Build plan: vertical slices
FastAPI · Django · Kafka · Redis · PostgreSQL · TimescaleDB · LangGraph · EKS · KEDA · GitHub Actions
Expected effort: 10–16 focused hours · Minimum meaningful tests: 24What you are building
This is a portfolio submission, not a copy-and-run tutorial. A reviewer must be able to clone it, configure it without guessing, execute the critical path, observe a deliberate failure, run the tests, and understand the most important design decision from the README.
Architecture
Critical interaction
Ownership table
| Boundary | Owns | Must not own |
|---|---|---|
| Interface | Parsing, protocol validation, identity extraction, status or presentation mapping | Core business invariants |
| Application/domain | Authorization inputs, state transitions, orchestration, transaction intent | Framework globals or raw transport objects |
| Repository/gateway | One persistence or external protocol, bounded retries, error translation | Product policy |
| Background/UI projection | Recoverable derived state and delivery progress | Hidden authoritative truth |
| Operations | Configuration, health, deployment, telemetry, recovery | Business decisions encoded only in dashboards |
Acceptance criteria
| ID | Required behavior | Evidence |
|---|---|---|
| AC-1.1 | user-service: Django+DRF+JWT+Cognito produces the specified behavior inside 6 microservices | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-1.2 | market-data-service: FastAPI+WebSocket+Kafka producer for price ticks produces the specified behavior inside 6 microservices | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-1.3 | trade-service: FastAPI+Kafka+Redlock+idempotent execution produces the specified behavior inside 6 microservices | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-1.4 | portfolio-service: FastAPI+CQRS+TimescaleDB produces the specified behavior inside 6 microservices | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-1.5 | notification-service: FastAPI+WebSocket+Celery produces the specified behavior inside 6 microservices | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-1.6 | api-gateway: Nginx+FastAPI proxy produces the specified behavior inside 6 microservices | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-2.1 | Market data: external API→WebSocket→Kafka(price-ticks)→portfolio P&L→WebSocket client produces the specified behavior inside Data flows | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-2.2 | Trade execution: client→gateway→trade-service→Redlock→validate→Kafka(trade-events)→portfolio→notification produces the specified behavior inside Data flows | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-2.3 | Outbox pattern for reliable DB→Kafka publishing produces the specified behavior inside Data flows | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.1 | User asks 'Should I buy AAPL?' produces the specified behavior inside LangGraph AI trading assistant | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-3.2 | StateGraph: query→retriever(market data+news)→analysis_agent→risk_agent→human_approval→execute_trade produces the specified behavior inside LangGraph AI trading assistant | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-4.1 | EKS cluster: 6 services with KEDA (Kafka-lag scaling) produces the specified behavior inside Infrastructure & performance | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-4.2 | MSK + ElastiCache Redis Cluster + RDS PostgreSQL+TimescaleDB produces the specified behavior inside Infrastructure & performance | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-4.3 | GitHub Actions per-service CI/CD produces the specified behavior inside Infrastructure & performance | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-4.4 | Full Prometheus+Grafana+Jaeger observability produces the specified behavior inside Infrastructure & performance | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
| AC-4.5 | Target: 10,000 trades/minute with locust benchmark produces the specified behavior inside Infrastructure & performance | Automated assertion, reproducible command, plan, trace, metric, or accessible browser check |
Suggested repository structure
1tradeflow/2├── services/3│ ├── user_service/4│ ├── market_data_service/5│ ├── trade_service/6│ ├── portfolio_service/7│ └── notification_service/8├── gateway/9├── contracts/{openapi,protobuf,events}/10├── assistant/{graph.py,nodes.py,tools.py,policy.py}/11├── infra/{helm,terraform,observability}/12├── tests/{contract,integration,e2e,load}/13└── docs/{adrs,runbooks,threat-model.md}Build plan: vertical slices
| Milestone | Capability | First implementation | Exit condition |
|---|---|---|---|
| 1 | 6 microservices | user-service: Django+DRF+JWT+Cognito; market-data-service: FastAPI+WebSocket+Kafka producer for price ticks; trade-service: FastAPI+Kafka+Redlock+idempotent execution | Demonstration plus focused tests |
| 2 | Data flows | Market data: external API→WebSocket→Kafka(price-ticks)→portfolio P&L→WebSocket client; Trade execution: client→gateway→trade-service→Redlock→validate→Kafka(trade-events)→portfolio→notification; Outbox pattern for reliable DB→Kafka publishing | Demonstration plus focused tests |
| 3 | LangGraph AI trading assistant | User asks 'Should I buy AAPL?'; StateGraph: query→retriever(market data+news)→analysis_agent→risk_agent→human_approval→execute_trade | Demonstration plus focused tests |
| 4 | Infrastructure & performance | EKS cluster: 6 services with KEDA (Kafka-lag scaling); MSK + ElastiCache Redis Cluster + RDS PostgreSQL+TimescaleDB; GitHub Actions per-service CI/CD | Demonstration plus focused tests |
| 5 | Hardening and delivery | Security, recovery, telemetry, performance, documentation | Full acceptance suite and recorded demonstration |
For each milestone, first create a failing acceptance test or a reproducible command. Implement the thinnest path to an observable result, add the nearest durable invariant, inject one expected failure, and refactor only after evidence protects the behavior.
Reference vertical slice
1@transactional2async def place_order(command: PlaceOrder, user: User) -> Order:3 existing = await idempotency.find(user.id, command.idempotency_key)4 if existing:5 return await orders.get(existing.order_id)6 await risk_policy.assert_allowed(user, command)7 order = await orders.insert_pending(command, user.id)8 await outbox.insert(9 event_id=uuid4(),10 topic="trade-orders.v1",11 key=str(user.account_id),12 payload=OrderPlaced.from_order(order).model_dump_json(),13 )14 await idempotency.record(user.id, command.idempotency_key, order.id)15 return orderExpected result
1Order, outbox event, and idempotency record commit together; repeated commands return the original order.Code reading
| Line | Code | Explanation |
|---|---|---|
| 1 | @transactional | Applies a decorator or framework annotation before the following definition is bound. |
| 2 | async def place_order(command: PlaceOrder, user: User) -> Order: | Defines a coroutine function; calling it creates a coroutine object and await drives its execution. |
| 3 | existing = await idempotency.find(user.id, command.idempotency_key) | Starts or resumes asynchronous I/O and yields control until the awaited operation completes. |
| 4 | if existing: | Evaluates the condition and enters this branch only when it is truthy. |
| 5 | return await orders.get(existing.order_id) | Starts or resumes asynchronous I/O and yields control until the awaited operation completes. |
| 6 | await risk_policy.assert_allowed(user, command) | Starts or resumes asynchronous I/O and yields control until the awaited operation completes. |
| 7 | order = await orders.insert_pending(command, user.id) | Starts or resumes asynchronous I/O and yields control until the awaited operation completes. |
| 8 | await outbox.insert( | Starts or resumes asynchronous I/O and yields control until the awaited operation completes. |
| 9 | event_id=uuid4(), | Computes or receives a value and binds it for the next step; the referenced object remains separate from the name. |
| 10 | topic="trade-orders.v1", | Computes or receives a value and binds it for the next step; the referenced object remains separate from the name. |
| 11 | key=str(user.account_id), | Computes or receives a value and binds it for the next step; the referenced object remains separate from the name. |
| 12 | payload=OrderPlaced.from_order(order).model_dump_json(), | Computes or receives a value and binds it for the next step; the referenced object remains separate from the name. |
| 13 | ) | Implements the next python statement in the example's data flow. |
| 14 | await idempotency.record(user.id, command.idempotency_key, order.id) | Starts or resumes asynchronous I/O and yields control until the awaited operation completes. |
| 15 | return order | Returns the observable result to the caller and ends this invocation. |
Risk register
| Area | Failure to reproduce | Required design response |
|---|---|---|
| 6 microservices | Splitting services without database ownership, idempotent events, and operational autonomy creates a distributed monolith. | Keep risk and order-state transitions synchronous with the authoritative write, and scale derived consumers independently by partition lag. |
| Data flows | Compensation is a new business action, not a magical rollback, and outbox publication remains at-least-once. | Use stable command/event IDs and design reconciliation paths. |
| LangGraph AI trading assistant | A route without a bounded termination condition can loop indefinitely. | Keep nodes small, deterministic where possible, and explicit about side effects. |
| Infrastructure & performance | A matrix in a benchmark or algorithm is not a CI matrix, and one headline trades-per-minute number without latency and correctness is not a capacity result. | State payload and consistency assumptions, load test realistic mixes, publish p50/p95/p99 and errors, and prove saturation and rollback behavior. |
Engineering checklist for this stack
- To do: deliver reviewable vertical slices
- To do: keep authoritative and derived state distinct
- To do: make every external effect retry-safe
- To do: integrate security and observability before the final sprint
- To do: publish reproducible demo and failure evidence
Test strategy
Implement at least 24 meaningful cases. A long list of shallow happy-path tests does not satisfy the requirement.
| Risk class | Minimum | Examples |
|---|---|---|
| Happy path and contract | 2 | Correct output, status/schema, durable state |
| Validation and boundaries | 2 | Empty, malformed, extreme, unsupported transition |
| Authorization or trust boundary | 1 | Missing identity, wrong tenant/role, injection or unsafe content |
| Failure and recovery | 2 | Timeout, retry, rollback, reconnect, dependency outage |
| Duplicate or concurrency | 1 | Same identity twice, racing update, redelivery |
| Performance and operations | 16 | Query bound, lag, p95, resource limit, telemetry |
Representative test scaffold
1@pytest.mark.anyio2async def test_retried_order_has_one_authoritative_effect(platform):3 command = place_order(idempotency_key="order-42", account_id="acct-7")4 first = await platform.trade.place(command)5 await platform.outbox.publish_without_ack(first.order_id)6 second = await platform.trade.place(command)7
8 assert second.order_id == first.order_id9 assert await platform.orders.count_for_key("order-42") == 110 assert await platform.outbox.count_for_order(first.order_id) == 111 await platform.consumers.replay()12 assert await platform.portfolio.applied_event_count(first.order_id) == 1Failure drills
- Stop the primary external dependency during the critical path. Capture the failure, cleanup, telemetry, and recovery.
- Repeat the same operation with the same stable identity. Prove one logical outcome or document why repetition is forbidden.
- Crash after durable state changes but before the response, acknowledgement, or projection. Re-run and reconcile.
- Submit the largest supported input and one slightly larger input.
- Remove one permission and prove denial without state change or information leakage.
- Roll back the change or restore the dependency, then run a smoke test and reconciliation check.
Performance experiment
State the dataset, payload distribution, concurrency, rate, duration, cache state, and resource limits before measuring. Publish p50, p95, p99, throughput, error rate, and the technology-specific correctness signal such as query count, consumer lag, duplicate effects, rendered updates, token cost, or recall. Change one variable at a time and retain raw output.
Submission package
- Complete source with a locked/reproducible environment.
- README.md with problem, architecture, setup, commands, configuration, assumptions, and trade-offs.
- Acceptance and risk-focused tests with a short explanation of what mocks intentionally do not cover.
- One design record explaining the most consequential choice and a rejected alternative.
- Security notes, sample non-secret configuration, and cleanup commands.
- A demonstration record: terminal transcript, screenshots, trace, query plan, or metrics dashboard.
- A 5–8 minute walkthrough following input → validation → state → failure → evidence.
Grading rubric
| Dimension | Weight | Full-credit evidence |
|---|---|---|
| Product behavior | 25 | Acceptance criteria pass through real public boundaries |
| Architecture and ownership | 20 | Responsibilities and state authority are explicit |
| Tests and recovery | 20 | Important negative, duplicate, concurrent, and outage cases pass |
| Security and data correctness | 15 | Least privilege, validation, constraints, and secret handling are demonstrated |
| Performance and operations | 10 | Reproducible measurement, useful telemetry, and rollback/recovery |
| Documentation and explanation | 10 | A new reviewer can reproduce and defend the result |
Mastery check
How well can you recall this?
Finished this lesson?