this repo has no description
1# sfsu 317 final project
2
3Decentralized collaborative code challenges platform built on ATProto. Create
4challenges and face your friends on various metrics (code length, runtime and
5more!).
6
7The goal is just to have a neat place to challenge for you and your friends to
8compete on dumb golf code challenges or stupid optimization problems. You could
9do a challenge where you have to solve it with the shortest possible python
10code, or the fastest C as an optimization problem, or even the shortest assembly
11generated code (with gcc, no LLVM compilers).
12
13The app is deployed at [compiles.at](https://compiles.at).
14
15
16## data ownership
17
18All your data is yours. You'll connect to the application using your [internet
19handle](https://internethandle.org/) (aka. atproto identity, also known as
20bluesky account).
21
22All the data you'll produce will be stored on your
23[PDS](https://atproto.com/guides/data-repos) (Personal Data Server). When you
24create a challenge, create tests cases, solutions, etc. everything is stored on
25your PDS by default (you can store it privately on the platform, but this is
26opt-in by design). The problems you'll write solutions for will be stored on
27your PDS by default as well.
28
29The goal is to allow users to own their data, be able to change platforms as
30they see fit, even after the project dies. As long as their account exists on
31*THEIR* PDS, they can access their data and continue using it. For the moment,
32we wont permit the creation of new accounts on this app, users will have to
33create it on any other platform on the atmosphere (as it requires more
34unesserary deployment complexity). I want to have the platform as open as
35possible. The user with just have to log in with their handle/did, complete the
36OAuth flow with their PDS, and then they can start using the platform without
37having to create an account on this platform.
38
39To learn more, I invite you to check out atproto documentation, or explore the
40atproto collections linked to my account
41[drawbu.dev](https://pdsls.dev/at://did:plc:pj5vgcebbi6shqj6zapminia).
42
43
44## data / lexicon
45
46This is a draft, but we could imagine the collections:
47```mermaid
48%%{init: {'theme': 'default', 'themeVariables': {'fontFamily': 'monospace'}}}%%
49
50erDiagram
51
52 User["com.example.user (user's PDS)"] {
53 string did "DID"
54 string handle "e.g. alice.bsky.social"
55 blob avatar "profile picture"
56 }
57
58 Problem["com.example.problem (creator's PDS)"] {
59 string rkey "TID"
60 string title ""
61 string description "markdown body"
62 string difficulty "easy | medium | hard"
63 string_array tags "e.g. dp, graphs"
64 string_array supportedLangs "python, js, rust, etc."
65 blob starterCode "optional"
66 datetime createdAt ""
67 }
68
69 TestCase["com.example.testcase (creator's PDS)"] {
70 string rkey "TID"
71 at_uri problem "-> problem"
72 string input ""
73 string expected ""
74 bool hidden "hidden from solvers"
75 }
76
77 Solution["com.example.solution (solver's PDS)"] {
78 string rkey "TID"
79 at_uri problem "-> problem (cross-PDS)"
80 string lang "language used"
81 blob code "solution source"
82 datetime submittedAt ""
83 }
84
85 ExecutionResult["execution_results (centralized DB)"] {
86 uuid id ""
87 string solutionUri "at:// of solution"
88 int runtimeMs ""
89 int memoryKb ""
90 int passedTests ""
91 int totalTests ""
92 jsonb perTestResults "per-test breakdown"
93 timestamp executedAt ""
94 }
95
96 User ||--o{ Problem : "creates"
97 User ||--o{ Solution : "submits"
98 Problem ||--o{ TestCase : "has"
99 Problem ||--o{ Solution : "solved by"
100 Solution ||--o{ ExecutionResult : "produces"
101```
102
103
104## stack + deployment strategy
105
106The app was planned to be a Golang + SvelteKit app deployed on Cloudflare
107workers, but because of too many issues with the Go app compiled to WASM on the
108workers runtime, I decided to switch to a full-stack app using [Tanstack
109Start](https://tanstack.com/start/latest) + [Solid](https://www.solidjs.com/).
110
111The app is going to be deployed automatically on Cloudflare workers by a
112Continuous Integration & Deployment [pipeline](./.github/workflows/frontend.yml)
113using GitHub Actions, with decentralized data ownership using
114[ATProto](https://atproto.com/) and a [Cloudflare
115D1](https://developers.cloudflare.com/d1/) database for storing data alongside
116that won't be stored on the atmosphere. The deployment and database both will be
117deployed on serverless technologies because of its deployment as code strategy
118and near-zero cost for early projects such as this one.
119
120I setuped a reproducible development environment using a
121[Nix](https://nixos.org/) flake. The whole project uses the
122[pnpm](https://pnpm.io/) package manager, and uses
123[Typescript](https://www.typescriptlang.org/) everywhere. It uses [Tanstack
124Start](https://tanstack.com/start/latest/), [Solid](https://www.solidjs.com/),
125[Tailwind](https://tailwindcss.com/). I will use
126[Prisma](https://www.prisma.io/) as a database ORM, alongside [Tanstack
127Query](https://tanstack.com/query/latest/), and the
128[@atcute](https://github.com/mary-ext/atcute) atproto tools ecosystem (OAuth,
129Lexicons, etc.).
130
131For the text editor, I'll probably go with a [Monaco
132Editor](https://microsoft.github.io/monaco-editor/). running on the client-side
133(maybe integrating local WASM lsps later), and will use an external service
134dedicated to executing the code in a containerized, reproducible environment.
135Some examples may include [sprites.dev](https://sprites.dev/) and
136[judge0](https://judge0.com) or even a custom solution with Docker.
137
138
139## acknowledgements
140
141Code competitive platforms:
142- [codewars](https://www.codewars.com/)
143- [leetcode](https://leetcode.com/) (more data-structure focused)
144- [codingame](https://www.codingame.com/) (more game-focused)
145
146ATProto apps using decentralized ATProto data ownership:
147- [bluesky](https://bsky.app/)
148- [tangled](https://tangled.org/)
149- [margin](https://margin.at/)
150
151Inspiration:
152- [npmx.dev](https://repo.npmx.dev/)
153- [pdsls.dev](https://pdsls.dev/)
154
155To be fair, I chose this project both because I wanted a platform like that
156where I could easily create dump contests with my friends, but I also really
157wanted to hack on the atmosphere :)