Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

Startup Data Manager — Technical Assignment

Project: Startup Company Data Manager

This repository implements the technical assignment: generate startup company data using an AI model (Anthropic Claude) and provide a FastAPI application to manage that data (load into SQLite + CRUD endpoints).

Prerequisites

  • Python 3.10 or newer
  • An Anthropic API key (only required to run the data generator)
  • Modern web browser (Chrome, Firefox, Safari, or Edge)

Quick Setup

1. Clone the Repository

git clone <repository-url>
cd startup-data-api

2. Create Virtual Environment & Install Dependencies

Windows (PowerShell):

python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt

macOS/Linux:

python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt

3. Environment Variables

Copy .env.example to .env if you want a local file (NOT recommended for production). Prefer setting the API key in your shell or CI secrets:

Permanent setup (.env file):

# Create .env file in project root
ANTHROPIC_API_KEY=sk-ant-your-api-key-here

Part 1 — Generate Data (Claude AI)

Run the generator to create startup_data.json:

python generate_data.py

Notes:

  • The generator produces 10 companies (2 per industry: FinTech, HealthTech, EdTech, E-commerce, SaaS)
  • Each company includes 3-4 products with detailed information
  • If ANTHROPIC_API_KEY is missing, generate_data.py will print a clear error and exit
  • The generated file will be saved as startup_data.json in the project root

Part 2 — Start the FastAPI Server

Start the API server:

uvicorn main:app --reload --host 127.0.0.1 --port 8000

The server will start at: http://127.0.0.1:8000

Open your browser and navigate to:

API Endpoints

Health Check

  • GET /health — Check API health and database statistics

Data Loading

  • POST /load-data — Load data from startup_data.json into the database
    • Prevents duplicate entries by checking company names
    • Returns: {loaded: n, skipped: m, errors: []}

Companies CRUD

  • GET /companies?page=1&per_page=10 — Get paginated list of companies
    • Query params: page, per_page, industry
  • GET /companies/{company_id} — Get single company with all products
  • POST /companies — Create new company
  • PUT /companies/{company_id} — Update company details
  • DELETE /companies/{company_id} — Delete company (cascade deletes all products)

Products CRUD

  • GET /products?page=1&per_page=10 — Get paginated list of products
    • Query params: page, per_page, company_id, pricing_model
  • GET /products/{product_id} — Get single product
  • POST /products — Create new product
  • PUT /products/{product_id} — Update product details
  • DELETE /products/{product_id} — Delete product

Frontend Features

The web interface (index.html) provides:

Dashboard

  • View total companies, products, and industries
  • Load data from JSON file with one click

Companies Management

  • Browse all companies with pagination (10 per page)
  • Search companies by name, industry, or tagline
  • View detailed company information with all products
  • Create, update, and delete companies
  • Delete all companies (bulk action)

Products Management

  • Browse all products with pagination (10 per page)
  • Search products by name, description, or pricing model
  • Create, update, and delete products
  • Delete all products (bulk action)

Forms

  • Add new companies with validation
  • Add new products linked to existing companies
  • Update existing companies and products

Repository Structure

startup-data-manager/
├── generate_data.py           # AI data generator (Claude API)
├── startup_data.json          # Generated data file (created by generator)
├── main.py                    # FastAPI application with all endpoints
├── models.py                  # SQLAlchemy database models
├── schemas.py                 # Pydantic validation schemas
├── database.py                # Database configuration (SQLite)
├── index.html                 # Frontend web interface
├── requirements.txt           # Python dependencies
├── .env.example               # Example environment variables
├── .gitignore                 # Git ignore patterns
├── startup.db                 # SQLite database (created on first run)
└── README.md                  # This file

Database Schema

Companies Table

  • id (UUID, Primary Key)
  • name (String, Unique)
  • tagline (String, max 100 chars)
  • description (Text)
  • industry (String: FinTech, HealthTech, EdTech, E-commerce, SaaS)
  • founded_year (Integer)
  • employee_count (Integer)
  • headquarters (String)
  • website_url (String, Optional)

Products Table

  • id (UUID, Primary Key)
  • company_id (UUID, Foreign Key → companies.id)
  • name (String)
  • description (Text)
  • target_audience (String)
  • key_features (Text)
  • pricing_model (String: Free, Freemium, Subscription, Enterprise)

Relationship: One Company → Many Products (cascade delete)

Technology Stack

Backend:

  • FastAPI — Modern Python web framework
  • SQLAlchemy — ORM for database operations
  • SQLite — Lightweight database
  • Pydantic — Data validation
  • Anthropic Claude API — AI data generation

Frontend:

  • JavaScript — No frameworks required
  • CSS3 — Modern dark theme design
  • HTML5 — Semantic markup

Development Workflow

  1. Generate fresh data:

    python generate_data.py
  2. Start the server:

    uvicorn main:app --reload
  3. Access the frontend:

Troubleshooting

Port Already in Use

If port 8000 is already in use, start the server on a different port:

uvicorn main:app --reload --port 8001

Then update API_URL in index.html to match.

Database Errors

To reset the database:

# Delete the database file
rm startup.db  # macOS/Linux
del startup.db  # Windows

# Restart the server to recreate it
uvicorn main:app --reload

Missing API Key

If you see "ANTHROPIC_API_KEY not found", make sure:

  1. You've set the environment variable correctly
  2. You've activated the virtual environment
  3. The key starts with sk-ant-

Video walkthrough

https://drive.google.com/file/d/1k_ctc0kPZYhRn5YZEeOMHXrOZNZd9iJh/view?usp=sharing

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages