A learning project for Elixir, Phoenix, Ecto, and CockroachDB. Pure REST JSON API — no HTML, no frontend.
- Elixir / Phoenix (API mode)
- Ecto (database layer)
- CockroachDB (via Docker)
- Start the database:
docker-compose up -d - Create and migrate:
mix ecto.setup - Start the server:
mix phx.server
| Method | Path | Description |
|---|---|---|
| GET | /api/todo | List all todos |
| GET | /api/todo/:id | Get one todo |
| POST | /api/todo | Create a todo |
| PUT | /api/todo/:id | Update a todo |
| DELETE | /api/todo/:id | Delete a todo |
{
"id": "UUID", //this is automatically generated
"customer": "string",
"type": "string",
"status": "string",
"notes": "string", // can't do text as it's isn't usuable by roach
"deadline": "datetime",
"inserted_at": "auto",
"updated_at": "auto"
}- Scaffold the Phoenix API project
- Write a
docker-compose.ymlfor CockroachDB - Configure Ecto to connect to CockroachDB
- Verify the connection with
mix ecto.create
Concepts: Phoenix project structure, Mix, config layers, Ecto Repo
- Write a migration (defines the
todostable in the DB) - Write the
TodoEcto schema (Elixir struct that maps to the table) - Write the
Todoscontext (module that owns all DB queries)
Concepts: Ecto migrations, schemas, changesets, contexts
- Add routes to
router.ex - Write a
TodoControllerwith all 5 actions - Wire each action to a context function
- Return proper JSON responses
Concepts: Phoenix router, controllers, JSON responses, HTTP status codes
- Test all endpoints with
curlor a REST client - Handle the unhappy paths (missing record, bad input)