# somacap/soma-technical-assessment architecture

> Architecture diagram of the GitHub repository somacap/soma-technical-assessment, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/somacap/soma-technical-assessment
- Repository: https://github.com/somacap/soma-technical-assessment

## Overview

##### Project type and purpose
- This is a monolithic full-stack Next.js 13 application (using the App Router) that provides a todo/task management UI, a set of RESTful API routes under `app/api/todos`, and persists data in a SQLite database via Prisma ORM. It also integrates with the external Pexels API to fetch images.

##### File structure
- Top‐level folders:
- `app/` contains both server components (API routes under `app/api/todos`) and client components/pages (`app/page.tsx`, `app/layout.tsx`).
- `lib/prisma.ts` is the data‐access layer initializing the Prisma client.
- `prisma/` holds the SQLite DB (`dev.db`), schema (`schema.prisma`) and migrations.
- Config files: `next.config.mjs`, `tailwind.config.ts`, `postcss.config.mjs`, `tsconfig.json`.
- The API routes follow Next.js conventions:
- `POST /api/todos` and `GET /api/todos` in `app/api/todos/route.ts`
- `GET`, `PATCH`, `DELETE` for individual todos under `app/api/todos/[id]/route.ts`

##### Key insights from the README
- Built on Next.js (React + serverless functions).
- SQLite via Prisma for persistence.
- Task‐enhancement features to add: due dates, Pexels image preview, and task dependency graph.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Frontend Layer"
        Page["app/page.tsx"]:::frontend
        Layout["app/layout.tsx"]:::frontend
        Globals["app/globals.css"]:::frontend
        Fonts["app/fonts"]:::frontend
    end

    subgraph "Backend Layer"
        TodosCRUD["Todos CRUD API\n(app/api/todos/route.ts)"]:::backend
        SingleTodo["Single Todo API\n(app/api/todos/[id]/route.ts)"]:::backend
    end

    subgraph "Data Layer"
        Prisma["Prisma Client\n(lib/prisma.ts)"]:::datalayer
    end

    subgraph "Data Stores"
        SQLite["SQLite Database\ndev.db"]:::datastore
        Schema["Prisma Schema\nschema.prisma"]:::datastore
        Migrations["Migration\n20241008160928_init/migration.sql"]:::datastore
    end

    subgraph "External Services"
        Pexels["Pexels API"]:::external
    end

    %% Data Flow
    Page -->|"fetch GET/POST /api/todos"| TodosCRUD
    Page -->|"fetch GET/PATCH/DELETE /api/todos/[id]"| SingleTodo

    TodosCRUD -->|"prisma.todo.findMany/create"| Prisma
    SingleTodo -->|"prisma.todo.update/delete"| Prisma

    TodosCRUD -->|"GET /v1/search"| Pexels
    SingleTodo -->|"GET /v1/search"| Pexels

    Prisma -->|"SQL queries"| SQLite

    TodosCRUD -->|"response todos list/create"| Page
    SingleTodo -->|"response todo"| Page

    %% Click Events
    click Page "https://github.com/somacap/soma-technical-assessment/blob/master/app/page.tsx"
    click Layout "https://github.com/somacap/soma-technical-assessment/blob/master/app/layout.tsx"
    click Globals "https://github.com/somacap/soma-technical-assessment/blob/master/app/globals.css"
    click Fonts "https://github.com/somacap/soma-technical-assessment/tree/master/app/fonts"
    click TodosCRUD "https://github.com/somacap/soma-technical-assessment/blob/master/app/api/todos/route.ts"
    click SingleTodo "https://github.com/somacap/soma-technical-assessment/blob/master/app/api/todos/[id]/route.ts"
    click Prisma "https://github.com/somacap/soma-technical-assessment/blob/master/lib/prisma.ts"
    click SQLite "https://github.com/somacap/soma-technical-assessment/blob/master/prisma/dev.db"
    click Schema "https://github.com/somacap/soma-technical-assessment/blob/master/prisma/schema.prisma"
    click Migrations "https://github.com/somacap/soma-technical-assessment/blob/master/prisma/migrations/20241008160928_init/migration.sql"

    %% Styles
    classDef frontend fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef backend fill:#90EE90,stroke:#333,stroke-width:1px
    classDef datalayer fill:#20B2AA,stroke:#333,stroke-width:1px
    classDef datastore fill:#9370DB,stroke:#333,stroke-width:1px
    classDef external fill:#FFA500,stroke:#333,stroke-width:1px
```
